rejestracja
This commit is contained in:
parent
f90a09688a
commit
bcf438dbc0
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,7 +1,9 @@
|
||||
# Generated by Django 2.1.5 on 2020-12-10 20:03
|
||||
# Generated by Django 3.1.4 on 2020-12-20 16:51
|
||||
|
||||
import datetime
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
@ -9,6 +11,7 @@ class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
@ -19,13 +22,13 @@ class Migration(migrations.Migration):
|
||||
('active', models.BooleanField(default=True)),
|
||||
('picture', models.ImageField(blank=True, null=True, upload_to='images/')),
|
||||
('create_date', models.DateField(default=datetime.date.today, verbose_name='Date')),
|
||||
('user_owner', models.TextField(default='', max_length=40)),
|
||||
('type', models.IntegerField(choices=[(1, 'Potrzebuje'), (2, 'Oddam')], default='')),
|
||||
('offer', models.IntegerField(choices=[(1, 'Usługa'), (2, 'Przedmiot')], default='')),
|
||||
('title', models.TextField(default='', max_length=40)),
|
||||
('description', models.TextField(default='', max_length=6000)),
|
||||
('place', models.TextField(default='', max_length=40)),
|
||||
('keywords', models.TextField(default='', max_length=6000)),
|
||||
('user_iden', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
),
|
||||
]
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,6 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
import datetime
|
||||
|
||||
TYPE_T = (
|
||||
@ -10,11 +12,12 @@ TYPE_O = (
|
||||
(1,'Usługa'),
|
||||
(2,'Przedmiot'),
|
||||
)
|
||||
|
||||
class Product(models.Model):
|
||||
active = models.BooleanField(default=True)
|
||||
picture = models.ImageField(null=True, blank=True, upload_to="images/")
|
||||
create_date = models.DateField(("Date"), default=datetime.date.today)
|
||||
user_owner = models.TextField(max_length=40, blank=False, default="")
|
||||
user_iden = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
type = models.IntegerField(choices = TYPE_T, blank=False, default="")
|
||||
offer = models.IntegerField(choices = TYPE_O, blank=False, default="")
|
||||
title = models.TextField(max_length=40, blank=False, default="")
|
||||
|
@ -16,7 +16,7 @@
|
||||
<!--================End Categories Banner Area =================-->
|
||||
|
||||
<!--================Register Area =================-->
|
||||
<form action="{% url 'Dodawanie' %}" method="POST" enctype="multipart/form-data">
|
||||
<form action="{% url 'add_offer' %}" method="POST" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form.media }}
|
||||
{{ form.as_p }}
|
135
SocialHelper/homepage/templates/homepage/create_user.html
Normal file
135
SocialHelper/homepage/templates/homepage/create_user.html
Normal file
@ -0,0 +1,135 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load static %}
|
||||
{% block content %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<body>
|
||||
|
||||
<!--================Categories Banner Area =================-->
|
||||
<section class="solid_banner_area">
|
||||
<div class="container">
|
||||
<div class="solid_banner_inner">
|
||||
<h3>Utwórz nowe konto</h3>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!--================End Categories Banner Area =================-->
|
||||
|
||||
<!--================Register Area =================-->
|
||||
<form action="{% url 'create_user' %}" method="POST" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form.media }}
|
||||
{{ form.as_p }}
|
||||
<section class="track_area p_100">
|
||||
<div class="container">
|
||||
<div class="track_inner">
|
||||
<form class="track_form row">
|
||||
|
||||
<div class="col-lg-12 form-group">
|
||||
<label for="name">Email: <span>*</span></label>
|
||||
<input type="text" class="form-control" id="name" aria-describedby="name" placeholder="" name="email">
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 form-group">
|
||||
<label for="name">Hasło: <span>*</span></label>
|
||||
<input type="password" class="form-control" id="name" aria-describedby="name" placeholder="" name="password">
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 form-group">
|
||||
<input type="submit" class="btn btn-primary update_btn" value="Rejestruj">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</form>
|
||||
<!--================End Track Area =================-->
|
||||
<!--================End Register Area =================-->
|
||||
|
||||
<!--================Footer Area =================-->
|
||||
<footer class="footer_area">
|
||||
<div class="container">
|
||||
<div class="footer_widgets">
|
||||
<div class="row">
|
||||
<div class="col-lg-4 col-md-4 col-6">
|
||||
<aside class="f_widget f_about_widget">
|
||||
<img src="img/logo.png" alt="">
|
||||
<p>Persuit is a Premium PSD Template. Best choice for your online store. Let purchase it to enjoy now</p>
|
||||
<h6>Social:</h6>
|
||||
<ul>
|
||||
<li><a href="#"><i class="social_facebook"></i></a></li>
|
||||
<li><a href="#"><i class="social_twitter"></i></a></li>
|
||||
<li><a href="#"><i class="social_pinterest"></i></a></li>
|
||||
<li><a href="#"><i class="social_instagram"></i></a></li>
|
||||
<li><a href="#"><i class="social_youtube"></i></a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-4 col-6">
|
||||
<aside class="f_widget link_widget f_info_widget">
|
||||
<div class="f_w_title">
|
||||
<h3>Information</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li><a href="#">About us</a></li>
|
||||
<li><a href="#">Delivery information</a></li>
|
||||
<li><a href="#">Terms & Conditions</a></li>
|
||||
<li><a href="#">Help Center</a></li>
|
||||
<li><a href="#">Returns & Refunds</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-4 col-6">
|
||||
<aside class="f_widget link_widget f_service_widget">
|
||||
<div class="f_w_title">
|
||||
<h3>Customer Service</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li><a href="#">My account</a></li>
|
||||
<li><a href="#">Ordr History</a></li>
|
||||
<li><a href="#">Wish List</a></li>
|
||||
<li><a href="#">Newsletter</a></li>
|
||||
<li><a href="#">Contact Us</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-4 col-6">
|
||||
<aside class="f_widget link_widget f_extra_widget">
|
||||
<div class="f_w_title">
|
||||
<h3>Extras</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li><a href="#">Brands</a></li>
|
||||
<li><a href="#">Gift Vouchers</a></li>
|
||||
<li><a href="#">Affiliates</a></li>
|
||||
<li><a href="#">Specials</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-4 col-6">
|
||||
<aside class="f_widget link_widget f_account_widget">
|
||||
<div class="f_w_title">
|
||||
<h3>My Account</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li><a href="#">My account</a></li>
|
||||
<li><a href="#">Ordr History</a></li>
|
||||
<li><a href="#">Wish List</a></li>
|
||||
<li><a href="#">Newsletter</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer_copyright">
|
||||
<h5>© <script>document.write(new Date().getFullYear());</script> <!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
|
||||
Copyright ©<script>document.write(new Date().getFullYear());</script> All rights reserved | This template is made with <i class="fa fa-heart-o" aria-hidden="true"></i> by <a href="https://colorlib.com" target="_blank">Colorlib</a>. Downloaded from <a href="https://themeslab.org/" target="_blank">Themeslab</a>
|
||||
<!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<!--================End Footer Area =================-->
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
@ -79,7 +79,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12 form-group">
|
||||
<input type="submit" class="btn btn-primary update_btn" value="Dodaj">
|
||||
<input type="submit" class="btn btn-primary update_btn" value="Edytuj">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
144
SocialHelper/homepage/templates/homepage/login.html
Normal file
144
SocialHelper/homepage/templates/homepage/login.html
Normal file
@ -0,0 +1,144 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load static %}
|
||||
{% block content %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<body>
|
||||
|
||||
<!--================Categories Banner Area =================-->
|
||||
<section class="solid_banner_area">
|
||||
<div class="container">
|
||||
<div class="solid_banner_inner">
|
||||
<h3>Zaloguj się</h3>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<!--================End Categories Banner Area =================-->
|
||||
|
||||
<!--================Register Area =================-->
|
||||
<form action="{% url 'login' %}" method="POST" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form.media }}
|
||||
{{ form.as_p }}
|
||||
<input type="hidden" name="email" value="">
|
||||
<input type="hidden" name="password" value="">
|
||||
<section class="track_area p_100">
|
||||
<div class="container">
|
||||
<div class="track_inner">
|
||||
<form class="track_form row">
|
||||
|
||||
<div class="col-lg-12 form-group">
|
||||
<label for="name">Email: <span>*</span></label>
|
||||
<input type="text" class="form-control" id="name" aria-describedby="name" placeholder="" name="email">
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 form-group">
|
||||
<label for="name">Hasło: <span>*</span></label>
|
||||
<input type="password" class="form-control" id="name" aria-describedby="name" placeholder="" name="password">
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 form-group">
|
||||
<input type="submit" class="btn btn-primary update_btn" value="Logowanie">
|
||||
</div>
|
||||
|
||||
<div class="col-lg-12 form-group">
|
||||
|
||||
<label for="name">Jeśli nie masz konta możesz je utworzyć tutaj:</label> <br>
|
||||
<a href="create_user"><button type="button" class="btn btn-primary update_btn">REJESTRACJA</button></a>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</form>
|
||||
<!--================End Track Area =================-->
|
||||
<!--================End Register Area =================-->
|
||||
|
||||
<!--================Footer Area =================-->
|
||||
<footer class="footer_area">
|
||||
<div class="container">
|
||||
<div class="footer_widgets">
|
||||
<div class="row">
|
||||
<div class="col-lg-4 col-md-4 col-6">
|
||||
<aside class="f_widget f_about_widget">
|
||||
<img src="img/logo.png" alt="">
|
||||
<p>Persuit is a Premium PSD Template. Best choice for your online store. Let purchase it to enjoy now</p>
|
||||
<h6>Social:</h6>
|
||||
<ul>
|
||||
<li><a href="#"><i class="social_facebook"></i></a></li>
|
||||
<li><a href="#"><i class="social_twitter"></i></a></li>
|
||||
<li><a href="#"><i class="social_pinterest"></i></a></li>
|
||||
<li><a href="#"><i class="social_instagram"></i></a></li>
|
||||
<li><a href="#"><i class="social_youtube"></i></a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-4 col-6">
|
||||
<aside class="f_widget link_widget f_info_widget">
|
||||
<div class="f_w_title">
|
||||
<h3>Information</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li><a href="#">About us</a></li>
|
||||
<li><a href="#">Delivery information</a></li>
|
||||
<li><a href="#">Terms & Conditions</a></li>
|
||||
<li><a href="#">Help Center</a></li>
|
||||
<li><a href="#">Returns & Refunds</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-4 col-6">
|
||||
<aside class="f_widget link_widget f_service_widget">
|
||||
<div class="f_w_title">
|
||||
<h3>Customer Service</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li><a href="#">My account</a></li>
|
||||
<li><a href="#">Ordr History</a></li>
|
||||
<li><a href="#">Wish List</a></li>
|
||||
<li><a href="#">Newsletter</a></li>
|
||||
<li><a href="#">Contact Us</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-4 col-6">
|
||||
<aside class="f_widget link_widget f_extra_widget">
|
||||
<div class="f_w_title">
|
||||
<h3>Extras</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li><a href="#">Brands</a></li>
|
||||
<li><a href="#">Gift Vouchers</a></li>
|
||||
<li><a href="#">Affiliates</a></li>
|
||||
<li><a href="#">Specials</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-4 col-6">
|
||||
<aside class="f_widget link_widget f_account_widget">
|
||||
<div class="f_w_title">
|
||||
<h3>My Account</h3>
|
||||
</div>
|
||||
<ul>
|
||||
<li><a href="#">My account</a></li>
|
||||
<li><a href="#">Ordr History</a></li>
|
||||
<li><a href="#">Wish List</a></li>
|
||||
<li><a href="#">Newsletter</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="footer_copyright">
|
||||
<h5>© <script>document.write(new Date().getFullYear());</script> <!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
|
||||
Copyright ©<script>document.write(new Date().getFullYear());</script> All rights reserved | This template is made with <i class="fa fa-heart-o" aria-hidden="true"></i> by <a href="https://colorlib.com" target="_blank">Colorlib</a>. Downloaded from <a href="https://themeslab.org/" target="_blank">Themeslab</a>
|
||||
<!-- Link back to Colorlib can't be removed. Template is licensed under CC BY 3.0. -->
|
||||
</h5>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<!--================End Footer Area =================-->
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
@ -9,6 +9,7 @@
|
||||
<section class="solid_banner_area">
|
||||
<div class="container">
|
||||
<div class="solid_banner_inner">
|
||||
<h5>{{ username }}
|
||||
<h3>Moje ogłoszenia</h3>
|
||||
</div>
|
||||
</div>
|
||||
@ -61,6 +62,7 @@
|
||||
<p>No polls are available.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
<br><a href="delete_user"><button type="button" class="btn btn-danger pull-right">Usuń Konto</button></a>
|
||||
</div>
|
||||
|
||||
<form action="{% url 'filter' %}" method="post">
|
@ -23,8 +23,8 @@
|
||||
</div>
|
||||
<ul class="navbar-nav justify-content-end">
|
||||
<li class="search_icon"><a href="#"><i class="icon-magnifier icons"></i></a></li>
|
||||
<li class="user_icon"><a href="/homepage/Mojeogloszenia"><i class="icon-user icons"></i></a></li>
|
||||
<li ><a href="/homepage/Dodawanie"><img src="{% static "plus.png"%}" height="20"/></a></li>
|
||||
<li class="user_icon"><a href="/homepage/my_offer"><i class="icon-user icons"></i></a></li>
|
||||
<li ><a href="/homepage/add_offer"><img src="{% static "plus.png"%}" height="20"/></a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
@ -9,9 +9,14 @@ urlpatterns = [
|
||||
path('contact', views.contact, name='contact'),
|
||||
path('regulamin',views.regulamin, name='regulamin'),
|
||||
path('filter', views.filter, name='filter'),
|
||||
path('Dodawanie', views.Dodawanie, name='Dodawanie'),
|
||||
path('Mojeogloszenia', views.Mojeogloszenia, name='Mojeogloszenia'),
|
||||
path('add_offer', views.add_offer, name='add_offer'),
|
||||
path('my_offer', views.my_offer, name='my_offer'),
|
||||
path('<int:offer_id>/delete_offer', views.delete_offer, name='delete_offer'),
|
||||
path('<int:offer_id>/edit_offer', views.edit_offer, name='edit_offer'),
|
||||
|
||||
path('create_user', views.create_user, name='create_user'),
|
||||
path('login', views.login, name='login'),
|
||||
path('delete_user', views.delete_user, name='delete_user'),
|
||||
path('<int:user_id>/delete_user', views.delete_user, name='delete_user'),
|
||||
|
||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
@ -1,7 +1,11 @@
|
||||
from django.shortcuts import get_object_or_404, render, redirect
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.urls import reverse
|
||||
from django.template import loader
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.contrib import messages, auth
|
||||
|
||||
from .models import Product, TYPE_T, TYPE_O
|
||||
|
||||
@ -11,7 +15,7 @@ import datetime
|
||||
|
||||
|
||||
def index(request):
|
||||
all_product = Product.objects.all
|
||||
all_product = Product.objects.filter(active = True)
|
||||
template = loader.get_template('homepage/index.html')
|
||||
types = TYPE_T
|
||||
types_o = TYPE_O
|
||||
@ -32,34 +36,38 @@ def index(request):
|
||||
}
|
||||
return HttpResponse(template.render(context, request))
|
||||
|
||||
|
||||
def contact(request):
|
||||
return render(request , 'homepage/contact.html')
|
||||
|
||||
def regulamin(request):
|
||||
return render(request, 'homepage/regulamin.html')
|
||||
|
||||
def Mojeogloszenia(request):
|
||||
all_product = Product.objects.filter(user_owner = "jedrzejklepacki@wp.pl", active = True).order_by('create_date')
|
||||
template = loader.get_template('homepage/Mojeogloszenia.html')
|
||||
types = TYPE_T
|
||||
types_o = TYPE_O
|
||||
place_local = ""
|
||||
oddam_local = ""
|
||||
potrzebuje_local = ""
|
||||
usluga_local = ""
|
||||
przedmiot_local = ""
|
||||
context = {
|
||||
'all_product': all_product,
|
||||
'types': types,
|
||||
'place_local': place_local,
|
||||
'oddam_local': oddam_local,
|
||||
'potrzebuje_local': potrzebuje_local,
|
||||
'types_o': types_o,
|
||||
'usluga_local': usluga_local,
|
||||
'przedmiot_local': przedmiot_local,
|
||||
}
|
||||
return HttpResponse(template.render(context, request))
|
||||
def my_offer(request):
|
||||
if request.user.is_authenticated:
|
||||
all_product = Product.objects.filter(user_iden = request.user.id, active = True).order_by('create_date')
|
||||
username = request.user.email
|
||||
template = loader.get_template('homepage/my_offer.html')
|
||||
types = TYPE_T
|
||||
types_o = TYPE_O
|
||||
place_local = ""
|
||||
oddam_local = ""
|
||||
potrzebuje_local = ""
|
||||
usluga_local = ""
|
||||
przedmiot_local = ""
|
||||
context = {
|
||||
'all_product': all_product,
|
||||
'types': types,
|
||||
'place_local': place_local,
|
||||
'oddam_local': oddam_local,
|
||||
'potrzebuje_local': potrzebuje_local,
|
||||
'types_o': types_o,
|
||||
'usluga_local': usluga_local,
|
||||
'przedmiot_local': przedmiot_local,
|
||||
'username': username
|
||||
}
|
||||
return HttpResponse(template.render(context, request))
|
||||
else:
|
||||
return redirect(login)
|
||||
|
||||
def filter(request):
|
||||
|
||||
@ -108,39 +116,42 @@ def filter(request):
|
||||
}
|
||||
return HttpResponse(template.render(context, request))
|
||||
|
||||
def Dodawanie(request):
|
||||
if request.method == 'POST':
|
||||
place_local = request.POST['place']
|
||||
type_local = request.POST['type']
|
||||
script_local = request.POST['script']
|
||||
title_local = request.POST['title']
|
||||
data_local = timezone.now()
|
||||
if request.FILES:
|
||||
pic_local = request.FILES['file']
|
||||
else:
|
||||
pic_local = "/images/basic.png"
|
||||
offer_local = request.POST['offer']
|
||||
product = Product(
|
||||
picture = pic_local,
|
||||
create_date = data_local,
|
||||
user_owner = "jedrzejklepacki@wp.pl",
|
||||
type = int(type_local),
|
||||
offer = int(offer_local),
|
||||
title = title_local,
|
||||
description = script_local,
|
||||
place = place_local,
|
||||
keywords = "",
|
||||
)
|
||||
product.save()
|
||||
return redirect(Mojeogloszenia)
|
||||
return render(request , 'homepage/Dodawanie.html')
|
||||
def add_offer(request):
|
||||
if request.user.is_authenticated:
|
||||
if request.method == 'POST':
|
||||
place_local = request.POST['place']
|
||||
type_local = request.POST['type']
|
||||
script_local = request.POST['script']
|
||||
title_local = request.POST['title']
|
||||
data_local = timezone.now()
|
||||
if request.FILES:
|
||||
pic_local = request.FILES['file']
|
||||
else:
|
||||
pic_local = "/images/basic.png"
|
||||
offer_local = request.POST['offer']
|
||||
product = Product(
|
||||
picture = pic_local,
|
||||
create_date = data_local,
|
||||
user_iden = request.user,
|
||||
type = int(type_local),
|
||||
offer = int(offer_local),
|
||||
title = title_local,
|
||||
description = script_local,
|
||||
place = place_local,
|
||||
keywords = "",
|
||||
)
|
||||
product.save()
|
||||
return redirect(my_offer)
|
||||
return render(request , 'homepage/add_offer.html')
|
||||
else:
|
||||
return redirect(login)
|
||||
|
||||
def delete_offer(request, offer_id):
|
||||
instance = Product.objects.get(id=offer_id)
|
||||
instance.active = False
|
||||
instance.save()
|
||||
|
||||
return redirect(Mojeogloszenia)
|
||||
return redirect(my_offer)
|
||||
|
||||
def edit_offer(request, offer_id):
|
||||
instance = Product.objects.get(id=offer_id)
|
||||
@ -170,5 +181,58 @@ def edit_offer(request, offer_id):
|
||||
instance.keywords = ""
|
||||
|
||||
instance.save()
|
||||
return redirect(Mojeogloszenia)
|
||||
return redirect(my_offer)
|
||||
return render(request , 'homepage/edycja_ogloszenia.html', context)
|
||||
|
||||
def create_user(request):
|
||||
if request.method == 'POST':
|
||||
User = get_user_model()
|
||||
email = request.POST['email']
|
||||
password = request.POST['password']
|
||||
if User.objects.filter(email=email).exists():
|
||||
messages.error(request,'Ten adres e-mail jest już używany')
|
||||
return redirect('create_user')
|
||||
else:
|
||||
user = User(
|
||||
username = email,
|
||||
email = email,
|
||||
is_active = True,
|
||||
is_staff = False
|
||||
)
|
||||
user.save()
|
||||
user.set_password(password)
|
||||
user.save()
|
||||
messages.success(request,'Gratulacje, teraz możesz się zalogować!')
|
||||
return redirect(my_offer)
|
||||
return render(request , 'homepage/create_user.html')
|
||||
|
||||
def delete_user(request):
|
||||
User = get_user_model()
|
||||
instant = User.objects.filter(id=request.user.id).first()
|
||||
instant.is_active = False
|
||||
instant.save()
|
||||
messages.success(request,'Konto skasowane!')
|
||||
return redirect(index)
|
||||
|
||||
def edit_user(request, user_id):
|
||||
return True
|
||||
|
||||
def login(request):
|
||||
if request.method == 'POST':
|
||||
username = request.POST['email']
|
||||
password = request.POST['password']
|
||||
user = authenticate(request, username=username, password=password, is_active=True)
|
||||
if user is not None:
|
||||
auth.login(request,user)
|
||||
messages.success(request, 'Jesteś zalogowany!')
|
||||
return redirect(my_offer)
|
||||
else:
|
||||
messages.error(request,'Nieprawidłowe dane logowania!')
|
||||
return redirect(login)
|
||||
return render(request , 'homepage/login.html')
|
||||
|
||||
def logout_user(request):
|
||||
if request.method == 'POST':
|
||||
auth.logout(request)
|
||||
messages.success(request, 'Zostałeś wylogowany!')
|
||||
return render(request, index)
|
||||
|
BIN
SocialHelper/media/images/1.jpg
Normal file
BIN
SocialHelper/media/images/1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
BIN
SocialHelper/media/images/1_4xD9eiF.jpg
Normal file
BIN
SocialHelper/media/images/1_4xD9eiF.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 60 KiB |
Loading…
Reference in New Issue
Block a user