diff --git a/vagus/camper/__pycache__/__init__.cpython-37.pyc b/vagus/camper/__pycache__/__init__.cpython-37.pyc index c10b6b4..45a4852 100644 Binary files a/vagus/camper/__pycache__/__init__.cpython-37.pyc and b/vagus/camper/__pycache__/__init__.cpython-37.pyc differ diff --git a/vagus/camper/__pycache__/__init__.cpython-38.pyc b/vagus/camper/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..174bf8f Binary files /dev/null and b/vagus/camper/__pycache__/__init__.cpython-38.pyc differ diff --git a/vagus/camper/__pycache__/admin.cpython-37.pyc b/vagus/camper/__pycache__/admin.cpython-37.pyc index dd5a94f..662d97a 100644 Binary files a/vagus/camper/__pycache__/admin.cpython-37.pyc and b/vagus/camper/__pycache__/admin.cpython-37.pyc differ diff --git a/vagus/camper/__pycache__/forms.cpython-37.pyc b/vagus/camper/__pycache__/forms.cpython-37.pyc index e32238f..4331f24 100644 Binary files a/vagus/camper/__pycache__/forms.cpython-37.pyc and b/vagus/camper/__pycache__/forms.cpython-37.pyc differ diff --git a/vagus/camper/__pycache__/models.cpython-37.pyc b/vagus/camper/__pycache__/models.cpython-37.pyc index baf6288..eeb35f7 100644 Binary files a/vagus/camper/__pycache__/models.cpython-37.pyc and b/vagus/camper/__pycache__/models.cpython-37.pyc differ diff --git a/vagus/camper/__pycache__/urls.cpython-37.pyc b/vagus/camper/__pycache__/urls.cpython-37.pyc index a7d642f..0149855 100644 Binary files a/vagus/camper/__pycache__/urls.cpython-37.pyc and b/vagus/camper/__pycache__/urls.cpython-37.pyc differ diff --git a/vagus/camper/admin.py b/vagus/camper/admin.py index 186763f..10832dc 100644 --- a/vagus/camper/admin.py +++ b/vagus/camper/admin.py @@ -3,10 +3,7 @@ from .models import Offer, Offer_Category, Image_offer from reservation.models import Reservation # Register your models here. -class ReservationOfferDetail(admin.TabularInline): - model = Reservation - can_delete = False - verbose_name = 'Rezerwację' + class OfferALlDetail(admin.TabularInline): model = Image_offer can_delete = True @@ -14,7 +11,7 @@ class OfferALlDetail(admin.TabularInline): class OfferAdmin(admin.ModelAdmin): model = Offer - inlines = [OfferALlDetail,ReservationOfferDetail] + inlines = [OfferALlDetail] list_display = ('id','title','category','date_added','status','slug') order = 'date_added' diff --git a/vagus/camper/migrations/0003_offer_description.py b/vagus/camper/migrations/0003_offer_description.py new file mode 100644 index 0000000..5768a6e --- /dev/null +++ b/vagus/camper/migrations/0003_offer_description.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.3 on 2021-01-24 16:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('camper', '0002_auto_20210112_1748'), + ] + + operations = [ + migrations.AddField( + model_name='offer', + name='description', + field=models.TextField(default='', max_length=1000), + ), + ] diff --git a/vagus/camper/migrations/__pycache__/0001_initial.cpython-37.pyc b/vagus/camper/migrations/__pycache__/0001_initial.cpython-37.pyc index 785bdd4..82628a6 100644 Binary files a/vagus/camper/migrations/__pycache__/0001_initial.cpython-37.pyc and b/vagus/camper/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/vagus/camper/migrations/__pycache__/0002_auto_20210112_1748.cpython-37.pyc b/vagus/camper/migrations/__pycache__/0002_auto_20210112_1748.cpython-37.pyc index 0100002..90de9a4 100644 Binary files a/vagus/camper/migrations/__pycache__/0002_auto_20210112_1748.cpython-37.pyc and b/vagus/camper/migrations/__pycache__/0002_auto_20210112_1748.cpython-37.pyc differ diff --git a/vagus/camper/migrations/__pycache__/0003_offer_description.cpython-37.pyc b/vagus/camper/migrations/__pycache__/0003_offer_description.cpython-37.pyc new file mode 100644 index 0000000..5417bc4 Binary files /dev/null and b/vagus/camper/migrations/__pycache__/0003_offer_description.cpython-37.pyc differ diff --git a/vagus/camper/migrations/__pycache__/__init__.cpython-37.pyc b/vagus/camper/migrations/__pycache__/__init__.cpython-37.pyc index 9e0fff1..064b0d5 100644 Binary files a/vagus/camper/migrations/__pycache__/__init__.cpython-37.pyc and b/vagus/camper/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/vagus/camper/models.py b/vagus/camper/models.py index b891f33..fda9369 100644 --- a/vagus/camper/models.py +++ b/vagus/camper/models.py @@ -53,6 +53,7 @@ class Offer(models.Model): title = models.CharField(_("Title"), max_length=50,default='Tytuł oferty') slug = models.SlugField(max_length=70, editable = False,default='' , unique=True,) + description = models.TextField(max_length = 1000,default = '') category = models.ForeignKey(Offer_Category ,default= None,on_delete= models.CASCADE) price = models.DecimalField(max_digits=10, decimal_places=2) diff --git a/vagus/camper/views/__pycache__/__init__.cpython-37.pyc b/vagus/camper/views/__pycache__/__init__.cpython-37.pyc index eaf507b..c12aee7 100644 Binary files a/vagus/camper/views/__pycache__/__init__.cpython-37.pyc and b/vagus/camper/views/__pycache__/__init__.cpython-37.pyc differ diff --git a/vagus/camper/views/__pycache__/create_offer.cpython-37.pyc b/vagus/camper/views/__pycache__/create_offer.cpython-37.pyc index 1835f60..5c8b86b 100644 Binary files a/vagus/camper/views/__pycache__/create_offer.cpython-37.pyc and b/vagus/camper/views/__pycache__/create_offer.cpython-37.pyc differ diff --git a/vagus/camper/views/__pycache__/detail_page.cpython-37.pyc b/vagus/camper/views/__pycache__/detail_page.cpython-37.pyc index 86fded3..d5b0288 100644 Binary files a/vagus/camper/views/__pycache__/detail_page.cpython-37.pyc and b/vagus/camper/views/__pycache__/detail_page.cpython-37.pyc differ diff --git a/vagus/camper/views/__pycache__/statistic_offer.cpython-37.pyc b/vagus/camper/views/__pycache__/statistic_offer.cpython-37.pyc index 3622030..b7a03ef 100644 Binary files a/vagus/camper/views/__pycache__/statistic_offer.cpython-37.pyc and b/vagus/camper/views/__pycache__/statistic_offer.cpython-37.pyc differ diff --git a/vagus/camper/views/detail_page.py b/vagus/camper/views/detail_page.py index 4da8cd7..2fb77fd 100644 --- a/vagus/camper/views/detail_page.py +++ b/vagus/camper/views/detail_page.py @@ -6,7 +6,7 @@ from django.views.generic import ( ) from camper.models import Offer, Image_offer from django.http import Http404, HttpResponseRedirect - +from django.core.paginator import Paginator ,EmptyPage, PageNotAnInteger class Home(View): @@ -22,6 +22,9 @@ class OfferListView(ListView): model = Offer template_name = 'offer/offers.html' context_object_name = 'active_offers_list' + paginate_by = 4 + + ordering = ['-date_added'] def get_queryset(self): return Offer.objects.filter(status = 'Active') diff --git a/vagus/media/avatars/default.png b/vagus/media/avatars/default.png new file mode 100644 index 0000000..9d86103 Binary files /dev/null and b/vagus/media/avatars/default.png differ diff --git a/vagus/media/uploads/offer-images/id-1/ford-transit-20-lpg-pilote-kamper-camper-wloclawek-sprzedam-521998036.jpg b/vagus/media/uploads/offer-images/id-1/ford-transit-20-lpg-pilote-kamper-camper-wloclawek-sprzedam-521998036.jpg new file mode 100644 index 0000000..e3c1612 Binary files /dev/null and b/vagus/media/uploads/offer-images/id-1/ford-transit-20-lpg-pilote-kamper-camper-wloclawek-sprzedam-521998036.jpg differ diff --git a/vagus/media/uploads/offer-images/id-2/53943_camper-rapido-powrot-do-trzech-osi_1.jpg b/vagus/media/uploads/offer-images/id-2/53943_camper-rapido-powrot-do-trzech-osi_1.jpg new file mode 100644 index 0000000..56fed87 Binary files /dev/null and b/vagus/media/uploads/offer-images/id-2/53943_camper-rapido-powrot-do-trzech-osi_1.jpg differ diff --git a/vagus/media/uploads/offer-images/id-3/ford-transit-20-lpg-pilote-kamper-camper-wloclawek-sprzedam-521998036.jpg b/vagus/media/uploads/offer-images/id-3/ford-transit-20-lpg-pilote-kamper-camper-wloclawek-sprzedam-521998036.jpg new file mode 100644 index 0000000..e3c1612 Binary files /dev/null and b/vagus/media/uploads/offer-images/id-3/ford-transit-20-lpg-pilote-kamper-camper-wloclawek-sprzedam-521998036.jpg differ diff --git a/vagus/media/uploads/offer-images/id-4/ford-transit-20-lpg-pilote-kamper-camper-wloclawek-sprzedam-521998036.jpg b/vagus/media/uploads/offer-images/id-4/ford-transit-20-lpg-pilote-kamper-camper-wloclawek-sprzedam-521998036.jpg new file mode 100644 index 0000000..e3c1612 Binary files /dev/null and b/vagus/media/uploads/offer-images/id-4/ford-transit-20-lpg-pilote-kamper-camper-wloclawek-sprzedam-521998036.jpg differ diff --git a/vagus/media/uploads/offer-images/id-5/1974_volkswagen_pacomobil_snail_camper_1600310520e8f93aad47a19e2a02.jpg b/vagus/media/uploads/offer-images/id-5/1974_volkswagen_pacomobil_snail_camper_1600310520e8f93aad47a19e2a02.jpg new file mode 100644 index 0000000..cbcf738 Binary files /dev/null and b/vagus/media/uploads/offer-images/id-5/1974_volkswagen_pacomobil_snail_camper_1600310520e8f93aad47a19e2a02.jpg differ diff --git a/vagus/media/uploads/offer-images/id-6/1974_volkswagen_pacomobil_snail_camper_1600310520e8f93aad47a19e2a02.jpg b/vagus/media/uploads/offer-images/id-6/1974_volkswagen_pacomobil_snail_camper_1600310520e8f93aad47a19e2a02.jpg new file mode 100644 index 0000000..cbcf738 Binary files /dev/null and b/vagus/media/uploads/offer-images/id-6/1974_volkswagen_pacomobil_snail_camper_1600310520e8f93aad47a19e2a02.jpg differ diff --git a/vagus/reservation/__pycache__/__init__.cpython-37.pyc b/vagus/reservation/__pycache__/__init__.cpython-37.pyc index 61e8a2f..49d7c0f 100644 Binary files a/vagus/reservation/__pycache__/__init__.cpython-37.pyc and b/vagus/reservation/__pycache__/__init__.cpython-37.pyc differ diff --git a/vagus/reservation/__pycache__/__init__.cpython-38.pyc b/vagus/reservation/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..ee007fa Binary files /dev/null and b/vagus/reservation/__pycache__/__init__.cpython-38.pyc differ diff --git a/vagus/reservation/__pycache__/admin.cpython-37.pyc b/vagus/reservation/__pycache__/admin.cpython-37.pyc index c3085ec..3e64a11 100644 Binary files a/vagus/reservation/__pycache__/admin.cpython-37.pyc and b/vagus/reservation/__pycache__/admin.cpython-37.pyc differ diff --git a/vagus/reservation/__pycache__/forms.cpython-37.pyc b/vagus/reservation/__pycache__/forms.cpython-37.pyc index 8bd0e9c..c17915c 100644 Binary files a/vagus/reservation/__pycache__/forms.cpython-37.pyc and b/vagus/reservation/__pycache__/forms.cpython-37.pyc differ diff --git a/vagus/reservation/__pycache__/models.cpython-37.pyc b/vagus/reservation/__pycache__/models.cpython-37.pyc index 1d6681c..5bd6ec4 100644 Binary files a/vagus/reservation/__pycache__/models.cpython-37.pyc and b/vagus/reservation/__pycache__/models.cpython-37.pyc differ diff --git a/vagus/reservation/__pycache__/urls.cpython-37.pyc b/vagus/reservation/__pycache__/urls.cpython-37.pyc index 3045470..be501ae 100644 Binary files a/vagus/reservation/__pycache__/urls.cpython-37.pyc and b/vagus/reservation/__pycache__/urls.cpython-37.pyc differ diff --git a/vagus/reservation/__pycache__/views.cpython-37.pyc b/vagus/reservation/__pycache__/views.cpython-37.pyc index 1011fad..c343e8a 100644 Binary files a/vagus/reservation/__pycache__/views.cpython-37.pyc and b/vagus/reservation/__pycache__/views.cpython-37.pyc differ diff --git a/vagus/reservation/migrations/0003_auto_20210124_1557.py b/vagus/reservation/migrations/0003_auto_20210124_1557.py new file mode 100644 index 0000000..0d5800d --- /dev/null +++ b/vagus/reservation/migrations/0003_auto_20210124_1557.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.3 on 2021-01-24 14:57 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('reservation', '0002_auto_20210115_0037'), + ] + + operations = [ + migrations.AlterField( + model_name='reservation', + name='reservation_start_date', + field=models.DateField(default=django.utils.timezone.now), + ), + ] diff --git a/vagus/reservation/migrations/__pycache__/0001_initial.cpython-37.pyc b/vagus/reservation/migrations/__pycache__/0001_initial.cpython-37.pyc index 183404f..7031884 100644 Binary files a/vagus/reservation/migrations/__pycache__/0001_initial.cpython-37.pyc and b/vagus/reservation/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/vagus/reservation/migrations/__pycache__/0002_auto_20210115_0037.cpython-37.pyc b/vagus/reservation/migrations/__pycache__/0002_auto_20210115_0037.cpython-37.pyc index 1ff25a6..cac58da 100644 Binary files a/vagus/reservation/migrations/__pycache__/0002_auto_20210115_0037.cpython-37.pyc and b/vagus/reservation/migrations/__pycache__/0002_auto_20210115_0037.cpython-37.pyc differ diff --git a/vagus/reservation/migrations/__pycache__/0003_auto_20210124_1557.cpython-37.pyc b/vagus/reservation/migrations/__pycache__/0003_auto_20210124_1557.cpython-37.pyc new file mode 100644 index 0000000..fe33303 Binary files /dev/null and b/vagus/reservation/migrations/__pycache__/0003_auto_20210124_1557.cpython-37.pyc differ diff --git a/vagus/reservation/migrations/__pycache__/__init__.cpython-37.pyc b/vagus/reservation/migrations/__pycache__/__init__.cpython-37.pyc index 82fe89d..3365502 100644 Binary files a/vagus/reservation/migrations/__pycache__/__init__.cpython-37.pyc and b/vagus/reservation/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/vagus/static/css/style.css b/vagus/static/css/style.css index 186ea05..b1e105b 100644 --- a/vagus/static/css/style.css +++ b/vagus/static/css/style.css @@ -3,6 +3,21 @@ body { color: black; font-family: 'Poppins'; } +body a { + color:black; + text-decoration: none; +} +body a:hover { + color:black; + text-decoration: none; +} +.link { + color:black; + text-decoration: none; +} +.link:hover { + color:black; + text-decoration: none;} .container { width: 1380px; @@ -50,11 +65,9 @@ body { max-width: 85px; } .header-logo a { - color: black; font-family: 'Dosis'; font-size: 32px; font-weight: 600; - text-decoration: none; } /* HEADER NAV */ @@ -65,10 +78,8 @@ body { max-width: 90%; } .header-nav a { - color: black; font-family: 'Poppins'; font-size: 14px; - text-decoration: none; font-weight: 500; padding-left: 15px; padding-right: 15px; @@ -100,8 +111,14 @@ body { .header-nav-bar-text { margin: auto; text-align: center; - font-weight: 600; + } +.header-nav-bar-text a { + font-size: 1em; + font-weight: 600!important; +} + + .header-nav-bar-avatar { min-width: 36px; max-height: 36px; @@ -142,4 +159,128 @@ body { .main-content { padding-left: 20px; padding-right: 20px; -} \ No newline at end of file +} + +/* OFFERS BOX */ + +.offer-box-wrapper{ + margin-top: 50px; + margin-bottom: 50px; + +} + +.offer-box-row{ + display: flex; + flex-direction: row; + flex-wrap: wrap; + justify-content:flex-start; + +} +.offer-box-row div { + margin-left:6px; + +} +.offer-box-wrapper-photo{ + flex:10%; + +} + +.offer-box-wrapper-photo img { + width:400px; + border-radius: 5%; + display: block; + height: auto; /* maintain aspect ratio*/ + margin: auto; +} +.offer-box-wrapper-content{ + margin-top: 10px; + flex:50%; +} +.offer-box-wrapper-content h2 { + font-size:19px; + font-weight: 500; +} +.offer-box-wrapper-content p { + font-size: 12px; +} +.offer-box-wrapper-content a { + color:black; + font-size: 15px; + font-family: 'Poppins'; + text-decoration: none; +} + +.offer-box-wrapper-content ul { + white-space:wrap; + margin-left: 0; padding-left: 0; +} +.offer-box-wrapper-content li { + display: inline; + font-size:11px; +} + +/* OFFERS PAGINATION */ +.page-item.active .page-link { + z-index: 1; + color: #fff; + background-color: #070707 !important; + border-color: #000000 !important; +} + +/* PROFILE */ + +.profile-wrapper { + margin-top: 50px; + width: 100%; +} +.profile-wrapper-row{ + display: flex; + flex-flow:row wrap; + justify-content:flex-start; + min-height: 600px; +} +.profile-wrapper-row-information { + flex:20%; + background-color: crimson; +} +.profile-wrapper-row-content { + flex:70%; + +} + +.profile-information-row { + display: flex; + flex-flow:row wrap; +} + +.profile-information-avatar{ + display: flex; + justify-content: center; + align-items: center; + flex:1 100%; + +} +.profile-information-avatar img { + width: 200px; + height: 200px; + margin:5px; + border-radius: 50%; + border: 0.5px solid black; +} +.profile-information-content { + margin-top:10px; + flex:1 100%; +} + +.profile-email, .profile-date-joined { + color:#48484898; + text-align: center; +} +.profile-date-joined{ + font-size: 0.9em; +} +.profile-logout { + color:black; + text-align: center; + font-weight: 600; +} diff --git a/vagus/template/index.html b/vagus/template/index.html index 7274f47..3fbd86d 100644 --- a/vagus/template/index.html +++ b/vagus/template/index.html @@ -6,7 +6,10 @@ - + + + +
@@ -28,15 +31,21 @@ {% if user.is_authenticated %} {% if user.status != 'Moderator' %} - Witaj, {{ user.first_name }} + Witaj, {{ user.first_name }} {% else %} - Witaj, Adminie + Witaj, Adminie {% endif %} {% else %} - Witaj, nieznajomy + Witaj, nieznajomy {% endif %}
-
+
+ {% if user.avatar %} + + {% else %} + + {%endif%} +
diff --git a/vagus/template/offer/offers.html b/vagus/template/offer/offers.html index a788151..7ae7d57 100644 --- a/vagus/template/offer/offers.html +++ b/vagus/template/offer/offers.html @@ -3,18 +3,60 @@ {% block content %} -{% if active_offers_list %} - {% for Offer in active_offers_list %} - -

{{ Offer.title}}

- {{ Offer.category }} {{ Offer.price }} {{ Offer.created_by }} - - {% for photo in Offer.images.all %} - {% if photo.main_image == True%} - - {% endif %} - {% endfor %} - - {% endfor %} + + {% if active_offers_list %} + {% for Offer in active_offers_list %} + +
+
+
+ {% for photo in Offer.images.all %} + {% if photo.main_image == True%} + + {% endif %} + {% endfor %} +
+
+

{{ Offer.title}}

+

{{ Offer.description|truncatewords:50 }}

+
    +
  • Ilośc miejsc do spania: {{Offer.Places_to_sleep}}
  • +
  • Skrzynia biegów: {{Offer.get_gearbox_display}}
  • +
+
Cena: {{ Offer.price }} PLN / dzień
+
+
+
+ {% endfor %} + {% endif %} + + + +{% endblock %} + + diff --git a/vagus/template/users/profile.html b/vagus/template/users/profile.html new file mode 100644 index 0000000..86bfb30 --- /dev/null +++ b/vagus/template/users/profile.html @@ -0,0 +1,30 @@ +{% extends 'index.html' %} +{% load static %} + +{% block content %} +
+
+
+
+
+ {% if user.avatar %} + + {% else %} + + {%endif%} +
+
+
@{{user.email}}
+
Data dołączenia: {{user.date_joined|date}}
+ +
+
+
+
+ {% for offer in offers%} + {{offer.id}} + {% endfor %} +
+
+
+{% endblock %} diff --git a/vagus/users/__pycache__/__init__.cpython-37.pyc b/vagus/users/__pycache__/__init__.cpython-37.pyc index 1c77e46..6b68d96 100644 Binary files a/vagus/users/__pycache__/__init__.cpython-37.pyc and b/vagus/users/__pycache__/__init__.cpython-37.pyc differ diff --git a/vagus/users/__pycache__/__init__.cpython-38.pyc b/vagus/users/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..86546b9 Binary files /dev/null and b/vagus/users/__pycache__/__init__.cpython-38.pyc differ diff --git a/vagus/users/__pycache__/admin.cpython-37.pyc b/vagus/users/__pycache__/admin.cpython-37.pyc index a49d085..216eb19 100644 Binary files a/vagus/users/__pycache__/admin.cpython-37.pyc and b/vagus/users/__pycache__/admin.cpython-37.pyc differ diff --git a/vagus/users/__pycache__/forms.cpython-37.pyc b/vagus/users/__pycache__/forms.cpython-37.pyc index c0e31a8..3458798 100644 Binary files a/vagus/users/__pycache__/forms.cpython-37.pyc and b/vagus/users/__pycache__/forms.cpython-37.pyc differ diff --git a/vagus/users/__pycache__/models.cpython-37.pyc b/vagus/users/__pycache__/models.cpython-37.pyc index 2ace2f7..d626a50 100644 Binary files a/vagus/users/__pycache__/models.cpython-37.pyc and b/vagus/users/__pycache__/models.cpython-37.pyc differ diff --git a/vagus/users/__pycache__/urls.cpython-37.pyc b/vagus/users/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000..58c5b0d Binary files /dev/null and b/vagus/users/__pycache__/urls.cpython-37.pyc differ diff --git a/vagus/users/__pycache__/views.cpython-37.pyc b/vagus/users/__pycache__/views.cpython-37.pyc new file mode 100644 index 0000000..0e0b4ce Binary files /dev/null and b/vagus/users/__pycache__/views.cpython-37.pyc differ diff --git a/vagus/users/admin.py b/vagus/users/admin.py index 248c61a..5694c0c 100644 --- a/vagus/users/admin.py +++ b/vagus/users/admin.py @@ -24,13 +24,13 @@ class CustomUserAdmin(UserAdmin): list_display = ('id','email', "is_staff", "is_active","is_superuser",'status') fieldsets = ( - (None, {'fields': ('email','first_name','last_name', 'password','status')}), + (None, {'fields': ('email','phone','first_name','last_name', 'password','status','avatar')}), ('Permissions', {'fields': ('is_staff', 'is_active',)}), ) add_fieldsets = ( (None, { 'classes': ('wide',), - 'fields': ('email','first_name','last_name', 'password1', 'password2', 'is_staff', 'is_active','status')} + 'fields': ('email','phone','first_name','last_name', 'password1', 'password2', 'is_staff', 'is_active','status','avatar')} ), ) ordering = ('email',) diff --git a/vagus/users/forms.py b/vagus/users/forms.py index 2fbe130..063b27d 100644 --- a/vagus/users/forms.py +++ b/vagus/users/forms.py @@ -1,20 +1,22 @@ from django import forms from django.contrib.auth.forms import UserCreationForm, UserChangeForm +from phonenumber_field.formfields import PhoneNumberField from .models import Base_User class CustomUserCreationForm(UserCreationForm): - + phone = PhoneNumberField() class Meta(UserCreationForm): model = Base_User - fields = ('email','password',) + fields =['email','password','phone'] + class CustomUserChangeForm(UserChangeForm): - + phone = PhoneNumberField() class Meta: model = Base_User - fields = ('email','password',) + fields = ['email','password','phone'] \ No newline at end of file diff --git a/vagus/users/migrations/0005_base_user_phone.py b/vagus/users/migrations/0005_base_user_phone.py new file mode 100644 index 0000000..4578eb5 --- /dev/null +++ b/vagus/users/migrations/0005_base_user_phone.py @@ -0,0 +1,19 @@ +# Generated by Django 3.1.3 on 2021-01-26 19:13 + +from django.db import migrations +import phonenumber_field.modelfields + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0004_auto_20210114_2051'), + ] + + operations = [ + migrations.AddField( + model_name='base_user', + name='phone', + field=phonenumber_field.modelfields.PhoneNumberField(blank=True, default='', max_length=128, null=True, region=None, unique=True), + ), + ] diff --git a/vagus/users/migrations/__pycache__/0001_initial.cpython-37.pyc b/vagus/users/migrations/__pycache__/0001_initial.cpython-37.pyc index c092717..6c0ad7d 100644 Binary files a/vagus/users/migrations/__pycache__/0001_initial.cpython-37.pyc and b/vagus/users/migrations/__pycache__/0001_initial.cpython-37.pyc differ diff --git a/vagus/users/migrations/__pycache__/0002_auto_20210114_1136.cpython-37.pyc b/vagus/users/migrations/__pycache__/0002_auto_20210114_1136.cpython-37.pyc index cd8c748..82c06e3 100644 Binary files a/vagus/users/migrations/__pycache__/0002_auto_20210114_1136.cpython-37.pyc and b/vagus/users/migrations/__pycache__/0002_auto_20210114_1136.cpython-37.pyc differ diff --git a/vagus/users/migrations/__pycache__/0003_base_user_avatar.cpython-37.pyc b/vagus/users/migrations/__pycache__/0003_base_user_avatar.cpython-37.pyc index a97e078..6affa7b 100644 Binary files a/vagus/users/migrations/__pycache__/0003_base_user_avatar.cpython-37.pyc and b/vagus/users/migrations/__pycache__/0003_base_user_avatar.cpython-37.pyc differ diff --git a/vagus/users/migrations/__pycache__/0004_auto_20210114_2051.cpython-37.pyc b/vagus/users/migrations/__pycache__/0004_auto_20210114_2051.cpython-37.pyc index 302a87d..1a2b76d 100644 Binary files a/vagus/users/migrations/__pycache__/0004_auto_20210114_2051.cpython-37.pyc and b/vagus/users/migrations/__pycache__/0004_auto_20210114_2051.cpython-37.pyc differ diff --git a/vagus/users/migrations/__pycache__/0005_base_user_phone.cpython-37.pyc b/vagus/users/migrations/__pycache__/0005_base_user_phone.cpython-37.pyc new file mode 100644 index 0000000..a87e1fd Binary files /dev/null and b/vagus/users/migrations/__pycache__/0005_base_user_phone.cpython-37.pyc differ diff --git a/vagus/users/migrations/__pycache__/__init__.cpython-37.pyc b/vagus/users/migrations/__pycache__/__init__.cpython-37.pyc index baaa5d2..75c16ed 100644 Binary files a/vagus/users/migrations/__pycache__/__init__.cpython-37.pyc and b/vagus/users/migrations/__pycache__/__init__.cpython-37.pyc differ diff --git a/vagus/users/models.py b/vagus/users/models.py index a586e44..83678eb 100644 --- a/vagus/users/models.py +++ b/vagus/users/models.py @@ -42,7 +42,8 @@ class UserManager(BaseUserManager): class Base_User(AbstractBaseUser,PermissionsMixin): id = models.AutoField(primary_key= True) email = models.EmailField(_('Email'), unique= True) - #phone = PhoneNumberField(null = False, blank = False, unique = True) + phone = PhoneNumberField(null = False, blank = False, unique = True, default = '') + avatar = models.ImageField(upload_to='media/avatars', null = True, blank = True,default='media/avatars/default.png') first_name = models.CharField(_('First Name'), max_length=30, blank = False, default = '') last_name = models.CharField(_('Last name'), max_length=30, blank = False,default = '') @@ -63,7 +64,6 @@ class Base_User(AbstractBaseUser,PermissionsMixin): def __str__(self): return self.email - class Meta: verbose_name = "User" verbose_name_plural = "Users" @@ -71,8 +71,6 @@ class Base_User(AbstractBaseUser,PermissionsMixin): class NormalUser(models.Model): user = models.OneToOneField(Base_User, on_delete=models.CASCADE, blank= True,null = True ) - - #avatar = models.ImageField(upload_to='media/avatars', null = True, blank = True,) birth_date = models.DateField(_('Birth date'),null=True, blank=True) #add fields Country, state, postal code, city, address1, address2 diff --git a/vagus/users/urls.py b/vagus/users/urls.py index e69de29..d155115 100644 --- a/vagus/users/urls.py +++ b/vagus/users/urls.py @@ -0,0 +1,10 @@ +from django.conf.urls import url +from django.urls import path +from django.conf.urls.static import static +from . import views + + +urlpatterns = [ + path('profile', views.ProfileView.as_view(), name = 'profile_view'), + path('logout', views.logout_view, name ='logout_user'), +] \ No newline at end of file diff --git a/vagus/users/views.py b/vagus/users/views.py index 14eca09..544e325 100644 --- a/vagus/users/views.py +++ b/vagus/users/views.py @@ -1,7 +1,17 @@ from django.shortcuts import render from .forms import CustomUserCreationForm from django.shortcuts import render, redirect - +from django.contrib.auth.decorators import login_required +from django.utils.decorators import method_decorator +from .models import Base_User, NormalUser, OwnerUser +from django.views.generic import ( + View, +) +from django.contrib.auth import logout +from django.conf import settings +from django.http import HttpResponseRedirect +from django.contrib import messages +from camper.models import Offer # Create your views here. #REJESTRACJA BASE USERA NASTĘPNIE WYBOR JAKI RODZAJ KONTA UZYTKOWNIK CCHE ZALOZYC @@ -9,7 +19,6 @@ from django.shortcuts import render, redirect class RegisterBaseUser(): # tworzy BaseUsera ze statusem BaseACC dla NormalUser i OwnerUser - def register_create_base_user(self,request): pass @@ -19,11 +28,33 @@ class RegisterBaseUser(): # tworzy BaseUsera ze statusem BaseACC dla NormalUser class UserPickAccStatus(): #uzytkownik wybiera swoj rodzaj konta i uzuieplnia danymi pass -class EditProfile(): #edycja danych w profilu - zmiana hasłą + zmiana danych - pass - class UpgradeProfileToOwnerUser(): #uzytkownik moze w kazdej cwhili zmienic swoje konto na konto firmowe pass class DowngradeProfileToNormalUser(): #uzytkownik moze zawieisc swoje konto firmowa wracajac na status konta NormalUser - pass \ No newline at end of file + pass + +class ProfileView(View): + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["offers"] = Offer.objects.filter(created_by = self.Base_User) + return context + @method_decorator(login_required,name='dispatch') + + def get(self,request): + self.Base_User = request.user + return render(request,'users/profile.html', {'Base_User':Base_User}) + + + + + +class EditProfile(): #edycja danych w profilu - zmiana hasłą + zmiana danych + pass + +def logout_view(request): + logout(request) + messages.success(request,'Zostałeś poprawnie wylogowany') + return HttpResponseRedirect('/') + diff --git a/vagus/vagus/__pycache__/__init__.cpython-37.pyc b/vagus/vagus/__pycache__/__init__.cpython-37.pyc index 75588d8..0d58ad9 100644 Binary files a/vagus/vagus/__pycache__/__init__.cpython-37.pyc and b/vagus/vagus/__pycache__/__init__.cpython-37.pyc differ diff --git a/vagus/vagus/__pycache__/__init__.cpython-38.pyc b/vagus/vagus/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..f4fbe50 Binary files /dev/null and b/vagus/vagus/__pycache__/__init__.cpython-38.pyc differ diff --git a/vagus/vagus/__pycache__/settings.cpython-37.pyc b/vagus/vagus/__pycache__/settings.cpython-37.pyc index e897eef..41133b9 100644 Binary files a/vagus/vagus/__pycache__/settings.cpython-37.pyc and b/vagus/vagus/__pycache__/settings.cpython-37.pyc differ diff --git a/vagus/vagus/__pycache__/settings.cpython-38.pyc b/vagus/vagus/__pycache__/settings.cpython-38.pyc new file mode 100644 index 0000000..618ace7 Binary files /dev/null and b/vagus/vagus/__pycache__/settings.cpython-38.pyc differ diff --git a/vagus/vagus/__pycache__/urls.cpython-37.pyc b/vagus/vagus/__pycache__/urls.cpython-37.pyc index 41043da..b6b606b 100644 Binary files a/vagus/vagus/__pycache__/urls.cpython-37.pyc and b/vagus/vagus/__pycache__/urls.cpython-37.pyc differ diff --git a/vagus/vagus/__pycache__/wsgi.cpython-37.pyc b/vagus/vagus/__pycache__/wsgi.cpython-37.pyc index 677d1c9..877cd1a 100644 Binary files a/vagus/vagus/__pycache__/wsgi.cpython-37.pyc and b/vagus/vagus/__pycache__/wsgi.cpython-37.pyc differ diff --git a/vagus/vagus/settings.py b/vagus/vagus/settings.py index c8cd717..33c4eaf 100644 --- a/vagus/vagus/settings.py +++ b/vagus/vagus/settings.py @@ -43,6 +43,8 @@ INSTALLED_APPS = [ 'address', 'django_extensions', 'reservation', + 'phonenumber_field', + ] MIDDLEWARE = [ @@ -119,6 +121,7 @@ AUTH_PASSWORD_VALIDATORS = [ # https://docs.djangoproject.com/en/3.1/topics/i18n/ AUTH_USER_MODEL = 'users.Base_User' +LOGIN_REDIRECT_URL = '/' LANGUAGE_CODE = 'en-us' diff --git a/vagus/vagus/urls.py b/vagus/vagus/urls.py index f0604bd..69f2684 100644 --- a/vagus/vagus/urls.py +++ b/vagus/vagus/urls.py @@ -15,6 +15,7 @@ Including another URLconf """ from django.contrib import admin from django.urls import path,include +from users import views from camper import views from reservation import views from django.conf.urls.static import static @@ -25,6 +26,7 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns urlpatterns = [ path('admin/', admin.site.urls), + path(r'',include('users.urls')), path(r'', include('camper.urls')), path(r'', include('reservation.urls')),