From e889756df0a6a779bd3ba3cb21f1be3892a51199 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Mon, 27 Feb 2023 09:54:43 +0100 Subject: [PATCH 01/21] initialization --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index b4405ebab4..4b315fc7dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ **/__pycache__ *.pyc venv +.idea/ + From 2da789ea627deee851cdc19370457e26f0ad4af4 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Mon, 27 Feb 2023 12:43:49 +0100 Subject: [PATCH 02/21] linting correction --- oc_lettings_site/views.py | 44 ++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/oc_lettings_site/views.py b/oc_lettings_site/views.py index a72db27074..92aa734391 100644 --- a/oc_lettings_site/views.py +++ b/oc_lettings_site/views.py @@ -2,25 +2,35 @@ from .models import Letting, Profile - - -# Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque molestie quam lobortis leo consectetur ullamcorper non id est. Praesent dictum, nulla eget feugiat sagittis, sem mi convallis eros, -# vitae dapibus nisi lorem dapibus sem. Maecenas pharetra purus ipsum, eget consequat ipsum lobortis quis. Phasellus eleifend ex auctor venenatis tempus. -# Aliquam vitae erat ac orci placerat luctus. Nullam elementum urna nisi, pellentesque iaculis enim cursus in. Praesent volutpat porttitor magna, non finibus neque cursus id. +# Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque molestie quam lobortis leo +# consectetur ullamcorper non id est. Praesent dictum, nulla eget feugiat sagittis, sem mi +# convallis eros, vitae dapibus nisi lorem dapibus sem. Maecenas pharetra purus ipsum, eget +# consequat ipsum lobortis quis. Phasellus eleifend ex auctor venenatis tempus.Aliquam vitae erat +# ac orci placerat luctus. Nullam elementum urna nisi, pellentesque iaculis enim cursus in. +# Praesent volutpat porttitor magna, non finibus neque cursus id. def index(request): return render(request, 'index.html') -# Aenean leo magna, vestibulum et tincidunt fermentum, consectetur quis velit. Sed non placerat massa. Integer est nunc, pulvinar a -# tempor et, bibendum id arcu. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Cras eget scelerisque +# Aenean leo magna, vestibulum et tincidunt fermentum, consectetur quis velit. Sed non placerat +# massa. Integer est nunc, pulvinar a tempor et, bibendum id arcu. Vestibulum ante ipsum primis in +# faucibus orci luctus et ultrices posuere cubilia curae; Cras eget scelerisque. + + def lettings_index(request): lettings_list = Letting.objects.all() context = {'lettings_list': lettings_list} return render(request, 'lettings_index.html', context) -#Cras ultricies dignissim purus, vitae hendrerit ex varius non. In accumsan porta nisl id eleifend. Praesent dignissim, odio eu consequat pretium, purus urna vulputate arcu, vitae efficitur -# lacus justo nec purus. Aenean finibus faucibus lectus at porta. Maecenas auctor, est ut luctus congue, dui enim mattis enim, ac condimentum velit libero in magna. Suspendisse potenti. In tempus a nisi sed laoreet. -# Suspendisse porta dui eget sem accumsan interdum. Ut quis urna pellentesque justo mattis ullamcorper ac non tellus. In tristique mauris eu velit fermentum, tempus pharetra est luctus. Vivamus consequat aliquam libero, eget bibendum lorem. Sed non dolor risus. Mauris condimentum auctor elementum. Donec quis nisi ligula. Integer vehicula tincidunt enim, ac lacinia augue pulvinar sit amet. +# Cras ultricies dignissim purus, vitae hendrerit ex varius non. In accumsan porta nisl id +# eleifend. Praesent dignissim, odio eu consequat pretium, purus urna vulputate arcu, vitae +# efficitur lacus justo nec purus. Aenean finibus faucibus lectus at porta. Maecenas auctor, est ut +# luctus congue, dui enim mattis enim, ac condimentum velit libero in magna. Suspendisse potenti. +# In tempus a nisi sed laoreet. Suspendisse porta dui eget sem accumsan interdum. Ut quis urna +# pellentesque justo mattis ullamcorper ac non tellus. In tristique mauris eu velit fermentum, +# tempus pharetra est luctus. Vivamus consequat aliquam libero, eget bibendum lorem. Sed non dolor +# risus. Mauris condimentum auctor elementum. Donec quis nisi ligula. Integer vehicula tincidunt +# enim, ac lacinia augue pulvinar sit amet. def letting(request, letting_id): letting = Letting.objects.get(id=letting_id) context = { @@ -29,16 +39,22 @@ def letting(request, letting_id): } return render(request, 'letting.html', context) -# Sed placerat quam in pulvinar commodo. Nullam laoreet consectetur ex, sed consequat libero pulvinar eget. Fusc -# faucibus, urna quis auctor pharetra, massa dolor cursus neque, quis dictum lacus d +# Sed placerat quam in pulvinar commodo. Nullam laoreet consectetur ex, sed consequat libero +# pulvinar eget. Fusc faucibus, urna quis auctor pharetra, massa dolor cursus neque, quis dictum +# lacus d + + def profiles_index(request): profiles_list = Profile.objects.all() context = {'profiles_list': profiles_list} return render(request, 'profiles_index.html', context) # Aliquam sed metus eget nisi tincidunt ornare accumsan eget lac -# laoreet neque quis, pellentesque dui. Nullam facilisis pharetra vulputate. Sed tincidunt, dolor id facilisis fringilla, eros leo tristique lacus, -# it. Nam aliquam dignissim congue. Pellentesque habitant morbi tristique senectus et netus et males +# laoreet neque quis, pellentesque dui. Nullam facilisis pharetra vulputate. Sed tincidunt, dolor +# id facilisis fringilla, eros leo tristique lacus, it. Nam aliquam dignissim congue. Pellentesque +# habitant morbi tristique senectus et netus et males + + def profile(request, username): profile = Profile.objects.get(user__username=username) context = {'profile': profile} From de96d2d2d15964a38eed2930ab95df311dee5810 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Mon, 27 Feb 2023 20:26:36 +0100 Subject: [PATCH 03/21] adding verbose_name_plural for Adress class --- oc-lettings-site.sqlite3 | Bin 151552 -> 151552 bytes .../migrations/0002_auto_20230227_1830.py | 17 +++++++++++++++++ oc_lettings_site/models.py | 3 +++ 3 files changed, 20 insertions(+) create mode 100644 oc_lettings_site/migrations/0002_auto_20230227_1830.py diff --git a/oc-lettings-site.sqlite3 b/oc-lettings-site.sqlite3 index 3d885414f9f3ed046704e8b09bdcd5c791c82d42..1ef83b17bacf6f5322a8c630c75fcae2c0fd5e88 100644 GIT binary patch delta 390 zcmZozz}c{XbAmLZ-9#B@Ryzj0aIcLi3;3CZxkV?l3#c-2i*9Uu&gJ1I%*vo^?U<h& zpOacrl9`uY9ABJSl4@XJU=*KNT9O}cWME`$U}R(-Z)gFefgD`}BV8kN1w(TyV?!%L zV?857Lqike&9TypL>PrP8SKs%hbu9%GPbZXG}JS)G&3-<Y`!#q`=$AeMhzTHye$lT zhj?2yHdgRzG+8sT`nIq-S`=j%o2Oe;m>cGrCYzd6WgD2}rWIHiW~G>Bn;4X4Pk*Jy z^j{umwz00Ev4SDYY-0lx15<-0Yeujk(;wI~DQpL-lw#yy;@{4|e}{kjX2F8h{HiL< zzKn#dV48l%o=F3!@h}7bBmTpi1sk^W+sZLJGD7@~&0;25W=Bq-w1KXHnXZwAf`O%# QiJ_ILnVzMEiG_tZ08lY#MgRZ+ delta 170 zcmZozz}c{XbAmLZ)kGO*Rx1WQnGG9L7Vt9*amP+(7f{{UXvn=eR(g>LqtGUU-TC4M zx&~&th9(LImR2T)R;Ffpmgc60<|fUT=5N0=pV6p+jgjvV1K**IjXU@_nyeXFeOp)^ zr$4Y~QrP}Vk4cJ=jgkKj1OJ`Pf(@7Wr{A$>(f|rPV&H!S6u7}JC(G=}X=Gpow!_E* L$qow>3k!1qs3tH= diff --git a/oc_lettings_site/migrations/0002_auto_20230227_1830.py b/oc_lettings_site/migrations/0002_auto_20230227_1830.py new file mode 100644 index 0000000000..c83123c0f4 --- /dev/null +++ b/oc_lettings_site/migrations/0002_auto_20230227_1830.py @@ -0,0 +1,17 @@ +# Generated by Django 3.0 on 2023-02-27 17:30 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('oc_lettings_site', '0001_initial'), + ] + + operations = [ + migrations.AlterModelOptions( + name='address', + options={'verbose_name_plural': 'Addresses'}, + ), + ] diff --git a/oc_lettings_site/models.py b/oc_lettings_site/models.py index ed255e8c11..9dac37ae21 100644 --- a/oc_lettings_site/models.py +++ b/oc_lettings_site/models.py @@ -14,6 +14,9 @@ class Address(models.Model): def __str__(self): return f'{self.number} {self.street}' + class Meta: + verbose_name_plural = 'Addresses' + class Letting(models.Model): title = models.CharField(max_length=256) From 656893511c1287ba81b8fc128e8190a9b4f8e367 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Tue, 28 Feb 2023 17:55:16 +0100 Subject: [PATCH 04/21] create lettings app --- lettings/__init__.py | 0 lettings/admin.py | 6 +++++ lettings/apps.py | 5 ++++ lettings/migrations/0001_initial.py | 39 ++++++++++++++++++++++++++++ lettings/migrations/__init__.py | 0 lettings/models.py | 25 ++++++++++++++++++ lettings/tests.py | 3 +++ lettings/views.py | 3 +++ oc-lettings-site.sqlite3 | Bin 151552 -> 163840 bytes oc_lettings_site/settings.py | 1 + 10 files changed, 82 insertions(+) create mode 100644 lettings/__init__.py create mode 100644 lettings/admin.py create mode 100644 lettings/apps.py create mode 100644 lettings/migrations/0001_initial.py create mode 100644 lettings/migrations/__init__.py create mode 100644 lettings/models.py create mode 100644 lettings/tests.py create mode 100644 lettings/views.py diff --git a/lettings/__init__.py b/lettings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lettings/admin.py b/lettings/admin.py new file mode 100644 index 0000000000..8d24982846 --- /dev/null +++ b/lettings/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin +from .models import Letting +from .models import Address + +admin.site.register(Letting) +admin.site.register(Address) diff --git a/lettings/apps.py b/lettings/apps.py new file mode 100644 index 0000000000..b6abff1791 --- /dev/null +++ b/lettings/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class LettingsConfig(AppConfig): + name = 'lettings' diff --git a/lettings/migrations/0001_initial.py b/lettings/migrations/0001_initial.py new file mode 100644 index 0000000000..0992911ff0 --- /dev/null +++ b/lettings/migrations/0001_initial.py @@ -0,0 +1,39 @@ +# Generated by Django 3.0 on 2023-02-28 16:43 + +import django.core.validators +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Address', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('number', models.PositiveIntegerField(validators=[django.core.validators.MaxValueValidator(9999)])), + ('street', models.CharField(max_length=64)), + ('city', models.CharField(max_length=64)), + ('state', models.CharField(max_length=2, validators=[django.core.validators.MinLengthValidator(2)])), + ('zip_code', models.PositiveIntegerField(validators=[django.core.validators.MaxValueValidator(99999)])), + ('country_iso_code', models.CharField(max_length=3, validators=[django.core.validators.MinLengthValidator(3)])), + ], + options={ + 'verbose_name_plural': 'Addresses', + }, + ), + migrations.CreateModel( + name='Letting', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('title', models.CharField(max_length=256)), + ('address', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='lettings.Address')), + ], + ), + ] diff --git a/lettings/migrations/__init__.py b/lettings/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lettings/models.py b/lettings/models.py new file mode 100644 index 0000000000..386d6341b4 --- /dev/null +++ b/lettings/models.py @@ -0,0 +1,25 @@ +from django.db import models +from django.core.validators import MaxValueValidator, MinLengthValidator + + +class Address(models.Model): + number = models.PositiveIntegerField(validators=[MaxValueValidator(9999)]) + street = models.CharField(max_length=64) + city = models.CharField(max_length=64) + state = models.CharField(max_length=2, validators=[MinLengthValidator(2)]) + zip_code = models.PositiveIntegerField(validators=[MaxValueValidator(99999)]) + country_iso_code = models.CharField(max_length=3, validators=[MinLengthValidator(3)]) + + def __str__(self): + return f'{self.number} {self.street}' + + class Meta: + verbose_name_plural = 'Addresses' + + +class Letting(models.Model): + title = models.CharField(max_length=256) + address = models.OneToOneField(Address, on_delete=models.CASCADE) + + def __str__(self): + return self.title diff --git a/lettings/tests.py b/lettings/tests.py new file mode 100644 index 0000000000..7ce503c2dd --- /dev/null +++ b/lettings/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/lettings/views.py b/lettings/views.py new file mode 100644 index 0000000000..91ea44a218 --- /dev/null +++ b/lettings/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/oc-lettings-site.sqlite3 b/oc-lettings-site.sqlite3 index 1ef83b17bacf6f5322a8c630c75fcae2c0fd5e88..7a536c319e36d6c03e4887b5d4f5f07679b88e60 100644 GIT binary patch delta 1108 zcmZuvOH30{6rIaVJDoSv-l8=aYh?=dKb5vq6j@j*L4+6~%EpD33RN1hi&AA{0)@CR zZX_j)G4ZoAy0VbijlrGnOi>dPNr0$vqia_hoj#{T8Yh|a-Z}4`b7yYu>?2`zmfUeR zCmDwE>u>!TTu@X<mPa3=MYigqgKU*}yRV6Cm5a|vr|K{<E>ChYQz&F}m!~3;NHmqr zWeeH#WGoU>!;x4x)+I*|cgK%(N8^W7^=P!KYh{n~nghhr?T(Y6l-_rQS{+1>7LhQh zVFBmy5)NQ168wTs@ioTF#qYMDgL65dUdUL*9b$TXJfE4GBBgkux=%!b!O!>#pWqVC z;S^@@B&v7-g>vzmEx23c7?-mlZa4W?G~!C?&>E{qizR+|z;2bTqVz-hEUif|q{q@? zxfqvbc5&bV@p?8hoiYLy2L}NV$1^(5)Wy(Wacm-;ySyz1n>lC)QLk0M7NBv2#u=aB zr%qzT8KUp6I5yEr^9<EX^GGevP&_NK^KbL4V*6F%s{?lQp&OmJ2N4BiZNJLJ`?iRQ z1rQaAA&NnYff^D&MIS{kMbAoj^TR0H%-quW9%$uYzrG9hK&tX23&)`HItkqeI%?Cx z3^U{nVJ+(x6Mw<9Y?|Son+Dl~wogs(tP{2cDQ^vl>u`=47Vj+-<<oQK1m6-4!+fHU zzBpOy9v!QCYZ|$)_e@`Mq)#469zWG5w>2JX_I~Kp*c=Smw~vgbXuk)+cVce(7%g|x zy|bKgsnO*9f4Ry`8sbo?j>2@4S?x5p^t-j_RoGjZ9)p<KoaiyPoDEZ@eLK<Eq@s<A zzp{P>0^_VA<Tbtu19ozQj1Yxbgs;M?uq5Qm#a)7>O))Xx35(j`2Dtc;P6AO;%WZ(0 z4;o~tMglr%4~g391~@~0>e(?^z3H4>8#LMYW3P|8iFS7rWQ*5pu$MY(lRY%--_fes Wb!XjOdGHY~UR!>~$t&FKPy7R&?l<-T delta 350 zcmZo@;A&XFIYC;`j)8$e6^LQLW1@~Rqus`Y`TQJmyg)%=Zqdo?0_qzZpL1;%l`a)w z<ec2C@4=`t`HH@_v@jP?1t-4=1OIgX68>iXG=5M1C;Y4UkMo;sY?R`kY+`>wjFaD( zf&Vf8G5(eO)A*bCi}_ReJ@}0`HcIkOHuk^Btio$FnLWUBW8)*9%|@}8ikMaSbtki5 z01DjY+pK&4dIB>)<MHY24vg|FO#Y0MrfWGc#&4Wp$GH8tBcqj^F0(s>FvA4~E*s93 z9CtZ{*j}-Tu;wx!WbR|y%pA$6$oGih0&fQ2M4lpEZSLC>8yB(pTd;{I+fFykWt5n{ zK95mwvYtNscFtr*M<xlb=L|xyV1UrZrflNwieSatGg29i*tT~%FxoM)0A;^SZ2YkO cb~dAC3bP8=yy@&07=cdq<Jvy&7GqK=063LhfdBvi diff --git a/oc_lettings_site/settings.py b/oc_lettings_site/settings.py index ffce49d343..ba7ac77948 100644 --- a/oc_lettings_site/settings.py +++ b/oc_lettings_site/settings.py @@ -26,6 +26,7 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', + 'lettings', ] MIDDLEWARE = [ From e06e4713bcfeceee2db5138f2032c0be35e2da92 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Tue, 28 Feb 2023 22:27:35 +0100 Subject: [PATCH 05/21] update urls, views and templates for lettings app --- lettings/views.py | 3 -- .../lettings}/__init__.py | 0 .../lettings}/admin.py | 0 .../lettings}/apps.py | 0 .../lettings}/migrations/0001_initial.py | 0 .../lettings}/migrations/__init__.py | 0 .../lettings}/models.py | 0 .../lettings/templates/__init__.py | 0 .../lettings/templates/lettings/__init__.py | 0 .../lettings/templates/lettings/index.html | 4 +- .../lettings/templates/lettings}/letting.html | 4 +- .../lettings}/tests.py | 0 oc_lettings_site/lettings/urls.py | 10 ++++ oc_lettings_site/lettings/views.py | 35 +++++++++++++ oc_lettings_site/urls.py | 7 +-- oc_lettings_site/views.py | 50 ------------------- templates/index.html | 4 +- 17 files changed, 53 insertions(+), 64 deletions(-) delete mode 100644 lettings/views.py rename {lettings => oc_lettings_site/lettings}/__init__.py (100%) rename {lettings => oc_lettings_site/lettings}/admin.py (100%) rename {lettings => oc_lettings_site/lettings}/apps.py (100%) rename {lettings => oc_lettings_site/lettings}/migrations/0001_initial.py (100%) rename {lettings => oc_lettings_site/lettings}/migrations/__init__.py (100%) rename {lettings => oc_lettings_site/lettings}/models.py (100%) create mode 100644 oc_lettings_site/lettings/templates/__init__.py create mode 100644 oc_lettings_site/lettings/templates/lettings/__init__.py rename templates/lettings_index.html => oc_lettings_site/lettings/templates/lettings/index.html (70%) rename {templates => oc_lettings_site/lettings/templates/lettings}/letting.html (67%) rename {lettings => oc_lettings_site/lettings}/tests.py (100%) create mode 100644 oc_lettings_site/lettings/urls.py create mode 100644 oc_lettings_site/lettings/views.py diff --git a/lettings/views.py b/lettings/views.py deleted file mode 100644 index 91ea44a218..0000000000 --- a/lettings/views.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.shortcuts import render - -# Create your views here. diff --git a/lettings/__init__.py b/oc_lettings_site/lettings/__init__.py similarity index 100% rename from lettings/__init__.py rename to oc_lettings_site/lettings/__init__.py diff --git a/lettings/admin.py b/oc_lettings_site/lettings/admin.py similarity index 100% rename from lettings/admin.py rename to oc_lettings_site/lettings/admin.py diff --git a/lettings/apps.py b/oc_lettings_site/lettings/apps.py similarity index 100% rename from lettings/apps.py rename to oc_lettings_site/lettings/apps.py diff --git a/lettings/migrations/0001_initial.py b/oc_lettings_site/lettings/migrations/0001_initial.py similarity index 100% rename from lettings/migrations/0001_initial.py rename to oc_lettings_site/lettings/migrations/0001_initial.py diff --git a/lettings/migrations/__init__.py b/oc_lettings_site/lettings/migrations/__init__.py similarity index 100% rename from lettings/migrations/__init__.py rename to oc_lettings_site/lettings/migrations/__init__.py diff --git a/lettings/models.py b/oc_lettings_site/lettings/models.py similarity index 100% rename from lettings/models.py rename to oc_lettings_site/lettings/models.py diff --git a/oc_lettings_site/lettings/templates/__init__.py b/oc_lettings_site/lettings/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/oc_lettings_site/lettings/templates/lettings/__init__.py b/oc_lettings_site/lettings/templates/lettings/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/templates/lettings_index.html b/oc_lettings_site/lettings/templates/lettings/index.html similarity index 70% rename from templates/lettings_index.html rename to oc_lettings_site/lettings/templates/lettings/index.html index a14bd501d7..7bdf8030cd 100644 --- a/templates/lettings_index.html +++ b/oc_lettings_site/lettings/templates/lettings/index.html @@ -4,7 +4,7 @@ <h1>Lettings</h1> <ul> {% for letting in lettings_list %} <li> - <a href="{% url 'letting' letting_id=letting.id %}"> + <a href="{% url 'lettings:letting' letting_id=letting.id %}"> {{ letting.title }} </a> </li> @@ -14,4 +14,4 @@ <h1>Lettings</h1> <p>No lettings are available.</p> {% endif %} <div><a href="{% url 'index' %}">Home</a></div> -<div><a href="{% url 'profiles_index' %}">Profiles</a></div> \ No newline at end of file +<!--<div><a href="{% url 'profiles:index' %}">Profiles</a></div>--> \ No newline at end of file diff --git a/templates/letting.html b/oc_lettings_site/lettings/templates/lettings/letting.html similarity index 67% rename from templates/letting.html rename to oc_lettings_site/lettings/templates/lettings/letting.html index 579bb6acee..17eef05ebe 100644 --- a/templates/letting.html +++ b/oc_lettings_site/lettings/templates/lettings/letting.html @@ -3,6 +3,6 @@ <h1>{{ title }}</h1> <p>{{ address.number }} {{ address.street }}</p> <p>{{ address.city }}, {{ address.state }} {{ address.zip_code }}</p> <p>{{ address.country_iso_code }}</p> -<div><a href="{% url 'lettings_index' %}">Back</a></div> +<div><a href="{% url 'lettings:index' %}">Back</a></div> <div><a href="{% url 'index' %}">Home</a></div> -<div><a href="{% url 'profiles_index' %}">Profiles</a></div> \ No newline at end of file +<!--<div><a href="{% url 'profiles:index' %}">Profiles</a></div>--> \ No newline at end of file diff --git a/lettings/tests.py b/oc_lettings_site/lettings/tests.py similarity index 100% rename from lettings/tests.py rename to oc_lettings_site/lettings/tests.py diff --git a/oc_lettings_site/lettings/urls.py b/oc_lettings_site/lettings/urls.py new file mode 100644 index 0000000000..4cc910d76a --- /dev/null +++ b/oc_lettings_site/lettings/urls.py @@ -0,0 +1,10 @@ +from django.urls import path + +from oc_lettings_site.lettings import views + + +app_name = 'lettings' +urlpatterns = [ + path('lettings/', views.index, name='index'), + path('lettings/<int:letting_id>/', views.letting, name='letting'), +] diff --git a/oc_lettings_site/lettings/views.py b/oc_lettings_site/lettings/views.py new file mode 100644 index 0000000000..04d88de380 --- /dev/null +++ b/oc_lettings_site/lettings/views.py @@ -0,0 +1,35 @@ +from django.shortcuts import render +from .models import Letting + + +# Aenean leo magna, vestibulum et tincidunt fermentum, consectetur quis velit. Sed non placerat +# massa. Integer est nunc, pulvinar a tempor et, bibendum id arcu. Vestibulum ante ipsum primis in +# faucibus orci luctus et ultrices posuere cubilia curae; Cras eget scelerisque. + + +def lettings_index(request): + lettings_list = Letting.objects.all() + context = {'lettings_list': lettings_list} + return render(request, 'index.html', context) + + +# Cras ultricies dignissim purus, vitae hendrerit ex varius non. In accumsan porta nisl id +# eleifend. Praesent dignissim, odio eu consequat pretium, purus urna vulputate arcu, vitae +# efficitur lacus justo nec purus. Aenean finibus faucibus lectus at porta. Maecenas auctor, est ut +# luctus congue, dui enim mattis enim, ac condimentum velit libero in magna. Suspendisse potenti. +# In tempus a nisi sed laoreet. Suspendisse porta dui eget sem accumsan interdum. Ut quis urna +# pellentesque justo mattis ullamcorper ac non tellus. In tristique mauris eu velit fermentum, +# tempus pharetra est luctus. Vivamus consequat aliquam libero, eget bibendum lorem. Sed non dolor +# risus. Mauris condimentum auctor elementum. Donec quis nisi ligula. Integer vehicula tincidunt +# enim, ac lacinia augue pulvinar sit amet. +def letting(request, letting_id): + letting = Letting.objects.get(id=letting_id) + context = { + 'title': letting.title, + 'address': letting.address, + } + return render(request, 'letting.html', context) + +# Sed placerat quam in pulvinar commodo. Nullam laoreet consectetur ex, sed consequat libero +# pulvinar eget. Fusc faucibus, urna quis auctor pharetra, massa dolor cursus neque, quis dictum +# lacus d diff --git a/oc_lettings_site/urls.py b/oc_lettings_site/urls.py index f0ff5897ab..84a91633d9 100644 --- a/oc_lettings_site/urls.py +++ b/oc_lettings_site/urls.py @@ -1,13 +1,10 @@ from django.contrib import admin -from django.urls import path +from django.urls import path, include from . import views urlpatterns = [ path('', views.index, name='index'), - path('lettings/', views.lettings_index, name='lettings_index'), - path('lettings/<int:letting_id>/', views.letting, name='letting'), - path('profiles/', views.profiles_index, name='profiles_index'), - path('profiles/<str:username>/', views.profile, name='profile'), + path('', include('oc_lettings_site.lettings.urls')), path('admin/', admin.site.urls), ] diff --git a/oc_lettings_site/views.py b/oc_lettings_site/views.py index 92aa734391..5db76c4362 100644 --- a/oc_lettings_site/views.py +++ b/oc_lettings_site/views.py @@ -1,5 +1,4 @@ from django.shortcuts import render -from .models import Letting, Profile # Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque molestie quam lobortis leo @@ -10,52 +9,3 @@ # Praesent volutpat porttitor magna, non finibus neque cursus id. def index(request): return render(request, 'index.html') - -# Aenean leo magna, vestibulum et tincidunt fermentum, consectetur quis velit. Sed non placerat -# massa. Integer est nunc, pulvinar a tempor et, bibendum id arcu. Vestibulum ante ipsum primis in -# faucibus orci luctus et ultrices posuere cubilia curae; Cras eget scelerisque. - - -def lettings_index(request): - lettings_list = Letting.objects.all() - context = {'lettings_list': lettings_list} - return render(request, 'lettings_index.html', context) - - -# Cras ultricies dignissim purus, vitae hendrerit ex varius non. In accumsan porta nisl id -# eleifend. Praesent dignissim, odio eu consequat pretium, purus urna vulputate arcu, vitae -# efficitur lacus justo nec purus. Aenean finibus faucibus lectus at porta. Maecenas auctor, est ut -# luctus congue, dui enim mattis enim, ac condimentum velit libero in magna. Suspendisse potenti. -# In tempus a nisi sed laoreet. Suspendisse porta dui eget sem accumsan interdum. Ut quis urna -# pellentesque justo mattis ullamcorper ac non tellus. In tristique mauris eu velit fermentum, -# tempus pharetra est luctus. Vivamus consequat aliquam libero, eget bibendum lorem. Sed non dolor -# risus. Mauris condimentum auctor elementum. Donec quis nisi ligula. Integer vehicula tincidunt -# enim, ac lacinia augue pulvinar sit amet. -def letting(request, letting_id): - letting = Letting.objects.get(id=letting_id) - context = { - 'title': letting.title, - 'address': letting.address, - } - return render(request, 'letting.html', context) - -# Sed placerat quam in pulvinar commodo. Nullam laoreet consectetur ex, sed consequat libero -# pulvinar eget. Fusc faucibus, urna quis auctor pharetra, massa dolor cursus neque, quis dictum -# lacus d - - -def profiles_index(request): - profiles_list = Profile.objects.all() - context = {'profiles_list': profiles_list} - return render(request, 'profiles_index.html', context) - -# Aliquam sed metus eget nisi tincidunt ornare accumsan eget lac -# laoreet neque quis, pellentesque dui. Nullam facilisis pharetra vulputate. Sed tincidunt, dolor -# id facilisis fringilla, eros leo tristique lacus, it. Nam aliquam dignissim congue. Pellentesque -# habitant morbi tristique senectus et netus et males - - -def profile(request, username): - profile = Profile.objects.get(user__username=username) - context = {'profile': profile} - return render(request, 'profile.html', context) diff --git a/templates/index.html b/templates/index.html index 0bd6445344..577d23dd3d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,4 +1,4 @@ <title>Holiday Homes</title> <h1>Welcome to Holiday Homes</h1> -<div><a href="{% url 'profiles_index' %}">Profiles</a></div> -<div><a href="{% url 'lettings_index' %}">Lettings</a></div> \ No newline at end of file +<!--<div><a href="{% url 'profiles:index' %}">Profiles</a></div>--> +<div><a href="{% url 'lettings:index' %}">Lettings</a></div> \ No newline at end of file From 0371b6af2c84ffd26697644a36d5e690cf4bb7ba Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Tue, 28 Feb 2023 23:49:41 +0100 Subject: [PATCH 06/21] bugfix: path lettings app and index into views --- oc_lettings_site/lettings/views.py | 2 +- oc_lettings_site/settings.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/oc_lettings_site/lettings/views.py b/oc_lettings_site/lettings/views.py index 04d88de380..521bf216a7 100644 --- a/oc_lettings_site/lettings/views.py +++ b/oc_lettings_site/lettings/views.py @@ -7,7 +7,7 @@ # faucibus orci luctus et ultrices posuere cubilia curae; Cras eget scelerisque. -def lettings_index(request): +def index(request): lettings_list = Letting.objects.all() context = {'lettings_list': lettings_list} return render(request, 'index.html', context) diff --git a/oc_lettings_site/settings.py b/oc_lettings_site/settings.py index ba7ac77948..8a3edc845d 100644 --- a/oc_lettings_site/settings.py +++ b/oc_lettings_site/settings.py @@ -19,14 +19,14 @@ # Application definition INSTALLED_APPS = [ - 'oc_lettings_site.apps.OCLettingsSiteConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'lettings', + 'oc_lettings_site.apps.OCLettingsSiteConfig', + 'oc_lettings_site.lettings', ] MIDDLEWARE = [ From d7d3ddfd9832ec01e0cbf60ed21b04fce7ef142e Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Tue, 28 Feb 2023 23:49:41 +0100 Subject: [PATCH 07/21] insert lettings data from oc_lettings_site --- oc-lettings-site.sqlite3 | Bin 163840 -> 163840 bytes .../migrations/0002_insert_lettings_data.py | 19 ++++++++++++++++++ oc_lettings_site/lettings/views.py | 2 +- oc_lettings_site/settings.py | 4 ++-- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 oc_lettings_site/lettings/migrations/0002_insert_lettings_data.py diff --git a/oc-lettings-site.sqlite3 b/oc-lettings-site.sqlite3 index 7a536c319e36d6c03e4887b5d4f5f07679b88e60..39a592faad21bec79e7ff017f016e3a215281786 100644 GIT binary patch delta 217 zcmZo@;A&{#njp>SG*QNx(P?AC5`Jb;u6dK$1vHts=51`u;c{{iWo3}Hcg#sGDap)B zFE%hRFpAI2D^4vciHC{BrzDmn8W|WF>ly%&p@N}-m4T&|p|PI1rG>G9!R7~2Dy&l6 zd~X=|U-Hl5FXG?Nzk$D-KZM_mUxJ^B@6E=>b9{y(Ld?31a08(XHW5K&(ZrOLqSWGI pHW>kCTgK@hlNco?o9drp6m2qSGhp0iz{H}km?c4AD+|*fc>q95Kr#RT delta 99 zcmV-p0G$7TfC_+s3XmHCL6ICo0YR}~qz?lW3gD9m5Gk>NunM!_8YBf42@e<m59tq@ z4{{H`53mo54^$5}4;Zn5{tg8k5Cc5{m+@i&7?U+G$^jIDForMzwlD$&Afp7ZAhQI3 F{13u#9ispM diff --git a/oc_lettings_site/lettings/migrations/0002_insert_lettings_data.py b/oc_lettings_site/lettings/migrations/0002_insert_lettings_data.py new file mode 100644 index 0000000000..bb9a951cf5 --- /dev/null +++ b/oc_lettings_site/lettings/migrations/0002_insert_lettings_data.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0 on 2023-03-01 08:39 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('lettings', '0001_initial'), + ] + + operations = [ + migrations.RunSQL(""" + INSERT INTO main.lettings_address + SELECT * FROM main.oc_lettings_site_address; + INSERT INTO main.lettings_letting + SELECT * FROM main.oc_lettings_site_letting; + """) + ] diff --git a/oc_lettings_site/lettings/views.py b/oc_lettings_site/lettings/views.py index 04d88de380..521bf216a7 100644 --- a/oc_lettings_site/lettings/views.py +++ b/oc_lettings_site/lettings/views.py @@ -7,7 +7,7 @@ # faucibus orci luctus et ultrices posuere cubilia curae; Cras eget scelerisque. -def lettings_index(request): +def index(request): lettings_list = Letting.objects.all() context = {'lettings_list': lettings_list} return render(request, 'index.html', context) diff --git a/oc_lettings_site/settings.py b/oc_lettings_site/settings.py index ba7ac77948..8a3edc845d 100644 --- a/oc_lettings_site/settings.py +++ b/oc_lettings_site/settings.py @@ -19,14 +19,14 @@ # Application definition INSTALLED_APPS = [ - 'oc_lettings_site.apps.OCLettingsSiteConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'lettings', + 'oc_lettings_site.apps.OCLettingsSiteConfig', + 'oc_lettings_site.lettings', ] MIDDLEWARE = [ From ddd748dcbe589211901930befa23368baa6c5ed9 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Thu, 2 Mar 2023 10:59:45 +0100 Subject: [PATCH 08/21] update urls, views and templates for profiles app --- .../lettings/templates/lettings/index.html | 2 +- .../lettings/templates/lettings/letting.html | 2 +- .../profiles/templates/__init__.py | 0 .../profiles/templates/profiles/__init__.py | 0 .../profiles/templates/profiles}/profile.html | 4 ++-- .../templates/profiles}/profiles_index.html | 4 ++-- oc_lettings_site/profiles/urls..py | 9 ++++++++ oc_lettings_site/profiles/views.py | 21 ++++++++++++++++++- oc_lettings_site/urls.py | 1 + templates/index.html | 2 +- 10 files changed, 37 insertions(+), 8 deletions(-) create mode 100644 oc_lettings_site/profiles/templates/__init__.py create mode 100644 oc_lettings_site/profiles/templates/profiles/__init__.py rename {templates => oc_lettings_site/profiles/templates/profiles}/profile.html (72%) rename {templates => oc_lettings_site/profiles/templates/profiles}/profiles_index.html (70%) create mode 100644 oc_lettings_site/profiles/urls..py diff --git a/oc_lettings_site/lettings/templates/lettings/index.html b/oc_lettings_site/lettings/templates/lettings/index.html index 7bdf8030cd..b53455ef07 100644 --- a/oc_lettings_site/lettings/templates/lettings/index.html +++ b/oc_lettings_site/lettings/templates/lettings/index.html @@ -14,4 +14,4 @@ <h1>Lettings</h1> <p>No lettings are available.</p> {% endif %} <div><a href="{% url 'index' %}">Home</a></div> -<!--<div><a href="{% url 'profiles:index' %}">Profiles</a></div>--> \ No newline at end of file +<div><a href="{% url 'profiles:index' %}">Profiles</a></div> \ No newline at end of file diff --git a/oc_lettings_site/lettings/templates/lettings/letting.html b/oc_lettings_site/lettings/templates/lettings/letting.html index 17eef05ebe..56933ad313 100644 --- a/oc_lettings_site/lettings/templates/lettings/letting.html +++ b/oc_lettings_site/lettings/templates/lettings/letting.html @@ -5,4 +5,4 @@ <h1>{{ title }}</h1> <p>{{ address.country_iso_code }}</p> <div><a href="{% url 'lettings:index' %}">Back</a></div> <div><a href="{% url 'index' %}">Home</a></div> -<!--<div><a href="{% url 'profiles:index' %}">Profiles</a></div>--> \ No newline at end of file +<div><a href="{% url 'profiles:index' %}">Profiles</a></div> \ No newline at end of file diff --git a/oc_lettings_site/profiles/templates/__init__.py b/oc_lettings_site/profiles/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/oc_lettings_site/profiles/templates/profiles/__init__.py b/oc_lettings_site/profiles/templates/profiles/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/templates/profile.html b/oc_lettings_site/profiles/templates/profiles/profile.html similarity index 72% rename from templates/profile.html rename to oc_lettings_site/profiles/templates/profiles/profile.html index 1e62a54baf..9de08b5dbf 100644 --- a/templates/profile.html +++ b/oc_lettings_site/profiles/templates/profiles/profile.html @@ -4,6 +4,6 @@ <h1>{{ profile.user.username }}</h1> <p>Last name: {{ profile.user.last_name }}</p> <p>Email: {{ profile.user.email }}</p> <p>Favorite city: {{ profile.favorite_city }}</p> -<div><a href="{% url 'profiles_index' %}">Back</a></div> +<div><a href="{% url 'profiles:index' %}">Back</a></div> <div><a href="{% url 'index' %}">Home</a></div> -<div><a href="{% url 'lettings_index' %}">Lettings</a></div> \ No newline at end of file +<div><a href="{% url 'lettings:index' %}">Lettings</a></div> \ No newline at end of file diff --git a/templates/profiles_index.html b/oc_lettings_site/profiles/templates/profiles/profiles_index.html similarity index 70% rename from templates/profiles_index.html rename to oc_lettings_site/profiles/templates/profiles/profiles_index.html index 7757515695..0a049ece6f 100644 --- a/templates/profiles_index.html +++ b/oc_lettings_site/profiles/templates/profiles/profiles_index.html @@ -4,7 +4,7 @@ <h1>Profiles</h1> <ul> {% for profile in profiles_list %} <li> - <a href="{% url 'profile' username=profile.user.username %}"> + <a href="{% url 'profiles:profile' username=profile.user.username %}"> {{ profile.user.username }} </a> </li> @@ -14,4 +14,4 @@ <h1>Profiles</h1> <p>No profiles are available.</p> {% endif %} <div><a href="{% url 'index' %}">Home</a></div> -<div><a href="{% url 'lettings_index' %}">Lettings</a></div> \ No newline at end of file +<div><a href="{% url 'lettings:index' %}">Lettings</a></div> \ No newline at end of file diff --git a/oc_lettings_site/profiles/urls..py b/oc_lettings_site/profiles/urls..py new file mode 100644 index 0000000000..8f504b71a0 --- /dev/null +++ b/oc_lettings_site/profiles/urls..py @@ -0,0 +1,9 @@ +from django.urls import path + +from oc_lettings_site.profiles import views + +app_name = 'profiles' +urlpatterns = [ + path('profiles/', views.profiles_index, name='index'), + path('profiles/<str:username>/', views.profile, name='profile'), +] diff --git a/oc_lettings_site/profiles/views.py b/oc_lettings_site/profiles/views.py index 91ea44a218..3732be6976 100644 --- a/oc_lettings_site/profiles/views.py +++ b/oc_lettings_site/profiles/views.py @@ -1,3 +1,22 @@ from django.shortcuts import render +from oc_lettings_site.profiles.models import Profile -# Create your views here. +# Sed placerat quam in pulvinar commodo. Nullam laoreet consectetur ex, sed consequat libero +# pulvinar eget. Fusc faucibus, urna quis auctor pharetra, massa dolor cursus neque, quis dictum +# lacus d + + +def profiles_index(request): + profiles_list = Profile.objects.all() + context = {'profiles_list': profiles_list} + return render(request, 'profiles_index.html', context) + + +# Aliquam sed metus eget nisi tincidunt ornare accumsan eget lac +# laoreet neque quis, pellentesque dui. Nullam facilisis pharetra vulputate. Sed tincidunt, dolor +# id facilisis fringilla, eros leo tristique lacus, it. Nam aliquam dignissim congue. Pellentesque +# habitant morbi tristique senectus et netus et males +def profile(request, username): + profile = Profile.objects.get(user__username=username) + context = {'profile': profile} + return render(request, 'profile.html', context) diff --git a/oc_lettings_site/urls.py b/oc_lettings_site/urls.py index 84a91633d9..d7cfa538d2 100644 --- a/oc_lettings_site/urls.py +++ b/oc_lettings_site/urls.py @@ -6,5 +6,6 @@ urlpatterns = [ path('', views.index, name='index'), path('', include('oc_lettings_site.lettings.urls')), + path('', include('oc_lettings_site.profiles.urls')), path('admin/', admin.site.urls), ] diff --git a/templates/index.html b/templates/index.html index 577d23dd3d..bc9c6663b5 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,4 +1,4 @@ <title>Holiday Homes</title> <h1>Welcome to Holiday Homes</h1> -<!--<div><a href="{% url 'profiles:index' %}">Profiles</a></div>--> +<div><a href="{% url 'profiles:index' %}">Profiles</a></div> <div><a href="{% url 'lettings:index' %}">Lettings</a></div> \ No newline at end of file From 908318c7dc4e2d77e27c83c92866a6ba77dc64ce Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Fri, 3 Mar 2023 15:01:28 +0100 Subject: [PATCH 09/21] update urls, views and templates for finalization --- oc_lettings_site/lettings/views.py | 4 ++-- .../profiles/{profiles_index.html => index.html} | 0 oc_lettings_site/profiles/{urls..py => urls.py} | 3 ++- oc_lettings_site/profiles/views.py | 9 +++++---- 4 files changed, 9 insertions(+), 7 deletions(-) rename oc_lettings_site/profiles/templates/profiles/{profiles_index.html => index.html} (100%) rename oc_lettings_site/profiles/{urls..py => urls.py} (75%) diff --git a/oc_lettings_site/lettings/views.py b/oc_lettings_site/lettings/views.py index 521bf216a7..0e2b827b7b 100644 --- a/oc_lettings_site/lettings/views.py +++ b/oc_lettings_site/lettings/views.py @@ -10,7 +10,7 @@ def index(request): lettings_list = Letting.objects.all() context = {'lettings_list': lettings_list} - return render(request, 'index.html', context) + return render(request, 'lettings/index.html', context) # Cras ultricies dignissim purus, vitae hendrerit ex varius non. In accumsan porta nisl id @@ -28,7 +28,7 @@ def letting(request, letting_id): 'title': letting.title, 'address': letting.address, } - return render(request, 'letting.html', context) + return render(request, 'lettings/letting.html', context) # Sed placerat quam in pulvinar commodo. Nullam laoreet consectetur ex, sed consequat libero # pulvinar eget. Fusc faucibus, urna quis auctor pharetra, massa dolor cursus neque, quis dictum diff --git a/oc_lettings_site/profiles/templates/profiles/profiles_index.html b/oc_lettings_site/profiles/templates/profiles/index.html similarity index 100% rename from oc_lettings_site/profiles/templates/profiles/profiles_index.html rename to oc_lettings_site/profiles/templates/profiles/index.html diff --git a/oc_lettings_site/profiles/urls..py b/oc_lettings_site/profiles/urls.py similarity index 75% rename from oc_lettings_site/profiles/urls..py rename to oc_lettings_site/profiles/urls.py index 8f504b71a0..00decde0f1 100644 --- a/oc_lettings_site/profiles/urls..py +++ b/oc_lettings_site/profiles/urls.py @@ -3,7 +3,8 @@ from oc_lettings_site.profiles import views app_name = 'profiles' + urlpatterns = [ - path('profiles/', views.profiles_index, name='index'), + path('profiles/', views.index, name='index'), path('profiles/<str:username>/', views.profile, name='profile'), ] diff --git a/oc_lettings_site/profiles/views.py b/oc_lettings_site/profiles/views.py index 3732be6976..f0210990e6 100644 --- a/oc_lettings_site/profiles/views.py +++ b/oc_lettings_site/profiles/views.py @@ -1,15 +1,16 @@ from django.shortcuts import render -from oc_lettings_site.profiles.models import Profile +# from oc_lettings_site.profiles.models import Profile +from .models import Profile # Sed placerat quam in pulvinar commodo. Nullam laoreet consectetur ex, sed consequat libero # pulvinar eget. Fusc faucibus, urna quis auctor pharetra, massa dolor cursus neque, quis dictum # lacus d -def profiles_index(request): +def index(request): profiles_list = Profile.objects.all() context = {'profiles_list': profiles_list} - return render(request, 'profiles_index.html', context) + return render(request, 'profiles/index.html', context) # Aliquam sed metus eget nisi tincidunt ornare accumsan eget lac @@ -19,4 +20,4 @@ def profiles_index(request): def profile(request, username): profile = Profile.objects.get(user__username=username) context = {'profile': profile} - return render(request, 'profile.html', context) + return render(request, 'profiles/profile.html', context) From 607ccec643044c3dd152f645ccd76af9d38e50e6 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Fri, 3 Mar 2023 15:04:38 +0100 Subject: [PATCH 10/21] insert profiles data from oc_lettings_site --- oc-lettings-site.sqlite3 | Bin 176128 -> 176128 bytes .../migrations/0002_insert_profiles_data.py | 17 +++++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 oc_lettings_site/profiles/migrations/0002_insert_profiles_data.py diff --git a/oc-lettings-site.sqlite3 b/oc-lettings-site.sqlite3 index b50fcb02d5a498cf134cc57965925871d25aebae..250988e791f2183de3471969b4b1dcb51b10c395 100644 GIT binary patch delta 338 zcmZp8z}4`8Yl1YR`$QRMM)!>gOZb_^xzs1K3+OU&sc&rj$m!%D&dMNb?^sZjpO%@E zT5MooU=*L3SDac@5)TuLPf09EG%_$U)-?bj1p`YfBQq;Q6FoB{14CoW&6!fOS!H<m zt}*bx<e$Y~#J`_^1AjMv2)`M>1V0ns8@_8B8@KU^i3l_6GQy37GFUdh(GzB56mK%v zX28h!ft&9T10!z>18)m&%f`kE-t8^AOm>VM3=E8RzAdbd(;wI~DQthG$0W|k&3}i1 zk$*b_|91ZEn*|G2^H1My&!o!2z`&paQl-ev{|G35n1TN=|KZJo4cqyrANFUG2g%EA zf9B65XRw*2;19n57f^tO|0M(eFa9t5@AzK=mEPnRXJKaKWMyS$WMp9ik<82>l8I&6 H0ww_fvh7{F delta 197 zcmZp8z}4`8Yl1YR>qHr6M%RrAOZb_^xH2cR3+QfaH09cyDK(o_ikt5Z1OH3@S^P!( z`}sHUck_qvoAFEVGx5FI*m#a_^BX;3Mn<tFgKY+kj32le7#Ns%TNwBb@wRMitl-_= zqRV8*$kAlY$m-j|>Nx#@J(I%rS9(n1j9``g+Zp)p@NeHNSg@LZ`gVIJRTgDtUrvxJ tMTq=i2L4C<hc^p0Z0DbT*q=$BMV8r-bNe%YCOL!6ED!$3FI&JQ003;BIp+WX diff --git a/oc_lettings_site/profiles/migrations/0002_insert_profiles_data.py b/oc_lettings_site/profiles/migrations/0002_insert_profiles_data.py new file mode 100644 index 0000000000..61a7a00cbe --- /dev/null +++ b/oc_lettings_site/profiles/migrations/0002_insert_profiles_data.py @@ -0,0 +1,17 @@ +# Generated by Django 3.0 on 2023-03-03 09:20 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('profiles', '0001_initial'), + ] + + operations = [ + migrations.RunSQL(""" + INSERT INTO main.profiles_profile + SELECT * FROM main.oc_lettings_site_profile; + """) + ] From 74ee19b193e64d56c6ae250a1a960f0d5f444513 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Sat, 4 Mar 2023 11:15:24 +0100 Subject: [PATCH 11/21] remove old data and old files --- oc-lettings-site.sqlite3 | Bin 176128 -> 176128 bytes oc_lettings_site/admin.py | 10 ------ .../migrations/0003_remove_old_tables.py | 19 ++++++++++ oc_lettings_site/models.py | 34 ------------------ 4 files changed, 19 insertions(+), 44 deletions(-) delete mode 100644 oc_lettings_site/admin.py create mode 100644 oc_lettings_site/migrations/0003_remove_old_tables.py delete mode 100644 oc_lettings_site/models.py diff --git a/oc-lettings-site.sqlite3 b/oc-lettings-site.sqlite3 index 250988e791f2183de3471969b4b1dcb51b10c395..4d40c5c8621c712d3c8d13eb6e5721ad06b69efe 100644 GIT binary patch delta 436 zcmZp8z}4`8Yl5_(2Ll6xHW0G|F)I-JP1G@F^w^lNgr8Z0^TA|x0evRU2OAq#aJsun zurlacI_4+G=cJaDWagz8#}{Xoq#76)7{?c-=H{2B#^>jx#Fr!{<)juH85kMs8UT@r zf}w$xp`n$brJkjwfuW(%W_79Cta1_zoP5_9_+RqR;xFRg&%c4co1cmA4c|2g+}OB{ zZ}K%gCszI|3{i~JKPE9su(1HyHjLB#*D^`4vH{t0lOyz(GfFHnFpvN`8w6N@SP6&~ zfmi{EIW{)l;oJNrPk@n!L4bjQ|1JMr{&V~XHw!jw<llU--uVGD56iag><Nsr%q-lq z7$<GlNM^j#15x{u|2_X#{@*~gH~FW({Ld)O3^ZaZJJVl&5Mw*L0Mp-o84mVx2A((` zMeZ&x0Zw*~W9;P|wJ^A`F`RvS`En+AMkZeI?FUvcg|o0RFfhGLww)f3$|x~?{W>PW y=?QC@*r)rhWs(Luol$dp&RV82MlK*zPTba(vDtIFUNWQD^aJaFia6IZeFp$9FnPED delta 312 zcmZp8z}4`8Yl5_(I|BoQHW0&r_e33IM)!>gOZb_^xzs1K3+Qib{K&akUFtTg+!Y2M zzH1EpFZpNj7xC}s-@xC^AHr|OFTu~m_lED<#>Q=YldtJHvC0TA+cHl7n8YZ-#v;QH zV*9UUl3-<%;bXR)9HGCQQGAhs!L|S<7J=<74NQOdH#M+4VCH33+0LH8D9g;!%x}iN zT_c(CP7e<Y|4Wc{@A<#-|K2RvaFc)f%m0kh+gTEr{>pD>RA6Fmkl|r3XW)CpH<34k zSDYt~N0GaWOMsJ|;~0B6NA1SOaQ5xx%bDC6nHU(hA6UT@&cfzz#U`F?J3SzkQDXY~ zbxeZO6V@`ZPxoERB+b&KX34%iXDw41BUh8OIlH*6En~CibiHIovFQia0TpqsXZj8R D>H1hF diff --git a/oc_lettings_site/admin.py b/oc_lettings_site/admin.py deleted file mode 100644 index 63328c6dd3..0000000000 --- a/oc_lettings_site/admin.py +++ /dev/null @@ -1,10 +0,0 @@ -from django.contrib import admin - -from .models import Letting -from .models import Address -from .models import Profile - - -admin.site.register(Letting) -admin.site.register(Address) -admin.site.register(Profile) diff --git a/oc_lettings_site/migrations/0003_remove_old_tables.py b/oc_lettings_site/migrations/0003_remove_old_tables.py new file mode 100644 index 0000000000..8738bf330a --- /dev/null +++ b/oc_lettings_site/migrations/0003_remove_old_tables.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0 on 2023-03-04 09:56 + +from django.db import migrations + + +class Migration(migrations.Migration): + initial = True + + dependencies = [ + ('oc_lettings_site', '0002_auto_20230227_1830'), + ] + + operations = [ + migrations.RunSQL(""" + DROP TABLE main.oc_lettings_site_address; + DROP TABLE main.oc_lettings_site_letting; + DROP TABLE main.oc_lettings_site_profile; + """) + ] diff --git a/oc_lettings_site/models.py b/oc_lettings_site/models.py deleted file mode 100644 index 9dac37ae21..0000000000 --- a/oc_lettings_site/models.py +++ /dev/null @@ -1,34 +0,0 @@ -from django.db import models -from django.core.validators import MaxValueValidator, MinLengthValidator -from django.contrib.auth.models import User - - -class Address(models.Model): - number = models.PositiveIntegerField(validators=[MaxValueValidator(9999)]) - street = models.CharField(max_length=64) - city = models.CharField(max_length=64) - state = models.CharField(max_length=2, validators=[MinLengthValidator(2)]) - zip_code = models.PositiveIntegerField(validators=[MaxValueValidator(99999)]) - country_iso_code = models.CharField(max_length=3, validators=[MinLengthValidator(3)]) - - def __str__(self): - return f'{self.number} {self.street}' - - class Meta: - verbose_name_plural = 'Addresses' - - -class Letting(models.Model): - title = models.CharField(max_length=256) - address = models.OneToOneField(Address, on_delete=models.CASCADE) - - def __str__(self): - return self.title - - -class Profile(models.Model): - user = models.OneToOneField(User, on_delete=models.CASCADE) - favorite_city = models.CharField(max_length=64, blank=True) - - def __str__(self): - return self.user.username From 4f7316cd1d5b06436f1e28862e1f3dcf1aedbb80 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Sat, 4 Mar 2023 11:58:27 +0100 Subject: [PATCH 12/21] create home app and move files --- oc_lettings_site/home_site/__init__.py | 0 oc_lettings_site/home_site/apps.py | 5 +++++ oc_lettings_site/home_site/migrations/__init__.py | 0 oc_lettings_site/home_site/templates/__init__.py | 0 .../home_site/templates/home_site/__init__.py | 0 .../home_site/templates/home_site}/index.html | 0 oc_lettings_site/home_site/urls.py | 8 ++++++++ oc_lettings_site/{ => home_site}/views.py | 2 +- oc_lettings_site/lettings/templates/lettings/index.html | 2 +- oc_lettings_site/lettings/templates/lettings/letting.html | 2 +- oc_lettings_site/profiles/templates/profiles/index.html | 2 +- oc_lettings_site/profiles/templates/profiles/profile.html | 2 +- oc_lettings_site/settings.py | 3 ++- oc_lettings_site/urls.py | 4 +--- 14 files changed, 21 insertions(+), 9 deletions(-) create mode 100644 oc_lettings_site/home_site/__init__.py create mode 100644 oc_lettings_site/home_site/apps.py create mode 100644 oc_lettings_site/home_site/migrations/__init__.py create mode 100644 oc_lettings_site/home_site/templates/__init__.py create mode 100644 oc_lettings_site/home_site/templates/home_site/__init__.py rename {templates => oc_lettings_site/home_site/templates/home_site}/index.html (100%) create mode 100644 oc_lettings_site/home_site/urls.py rename oc_lettings_site/{ => home_site}/views.py (92%) diff --git a/oc_lettings_site/home_site/__init__.py b/oc_lettings_site/home_site/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/oc_lettings_site/home_site/apps.py b/oc_lettings_site/home_site/apps.py new file mode 100644 index 0000000000..94297051f1 --- /dev/null +++ b/oc_lettings_site/home_site/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class WebSiteConfig(AppConfig): + name = 'oc_lettings_site.home_site' diff --git a/oc_lettings_site/home_site/migrations/__init__.py b/oc_lettings_site/home_site/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/oc_lettings_site/home_site/templates/__init__.py b/oc_lettings_site/home_site/templates/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/oc_lettings_site/home_site/templates/home_site/__init__.py b/oc_lettings_site/home_site/templates/home_site/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/templates/index.html b/oc_lettings_site/home_site/templates/home_site/index.html similarity index 100% rename from templates/index.html rename to oc_lettings_site/home_site/templates/home_site/index.html diff --git a/oc_lettings_site/home_site/urls.py b/oc_lettings_site/home_site/urls.py new file mode 100644 index 0000000000..f2f6c36b63 --- /dev/null +++ b/oc_lettings_site/home_site/urls.py @@ -0,0 +1,8 @@ +from django.urls import path + +from oc_lettings_site.home_site import views + +app_name = 'home' +urlpatterns = [ + path('', views.index, name='index'), +] \ No newline at end of file diff --git a/oc_lettings_site/views.py b/oc_lettings_site/home_site/views.py similarity index 92% rename from oc_lettings_site/views.py rename to oc_lettings_site/home_site/views.py index 5db76c4362..b4c4b086d0 100644 --- a/oc_lettings_site/views.py +++ b/oc_lettings_site/home_site/views.py @@ -8,4 +8,4 @@ # ac orci placerat luctus. Nullam elementum urna nisi, pellentesque iaculis enim cursus in. # Praesent volutpat porttitor magna, non finibus neque cursus id. def index(request): - return render(request, 'index.html') + return render(request, 'home_site/index.html') diff --git a/oc_lettings_site/lettings/templates/lettings/index.html b/oc_lettings_site/lettings/templates/lettings/index.html index b53455ef07..217cd9423f 100644 --- a/oc_lettings_site/lettings/templates/lettings/index.html +++ b/oc_lettings_site/lettings/templates/lettings/index.html @@ -13,5 +13,5 @@ <h1>Lettings</h1> {% else %} <p>No lettings are available.</p> {% endif %} -<div><a href="{% url 'index' %}">Home</a></div> +<div><a href="{% url 'home:index' %}">Home</a></div> <div><a href="{% url 'profiles:index' %}">Profiles</a></div> \ No newline at end of file diff --git a/oc_lettings_site/lettings/templates/lettings/letting.html b/oc_lettings_site/lettings/templates/lettings/letting.html index 56933ad313..07c99f8b4b 100644 --- a/oc_lettings_site/lettings/templates/lettings/letting.html +++ b/oc_lettings_site/lettings/templates/lettings/letting.html @@ -4,5 +4,5 @@ <h1>{{ title }}</h1> <p>{{ address.city }}, {{ address.state }} {{ address.zip_code }}</p> <p>{{ address.country_iso_code }}</p> <div><a href="{% url 'lettings:index' %}">Back</a></div> -<div><a href="{% url 'index' %}">Home</a></div> +<div><a href="{% url 'home:index' %}">Home</a></div> <div><a href="{% url 'profiles:index' %}">Profiles</a></div> \ No newline at end of file diff --git a/oc_lettings_site/profiles/templates/profiles/index.html b/oc_lettings_site/profiles/templates/profiles/index.html index 0a049ece6f..92e99305cc 100644 --- a/oc_lettings_site/profiles/templates/profiles/index.html +++ b/oc_lettings_site/profiles/templates/profiles/index.html @@ -13,5 +13,5 @@ <h1>Profiles</h1> {% else %} <p>No profiles are available.</p> {% endif %} -<div><a href="{% url 'index' %}">Home</a></div> +<div><a href="{% url 'home:index' %}">Home</a></div> <div><a href="{% url 'lettings:index' %}">Lettings</a></div> \ No newline at end of file diff --git a/oc_lettings_site/profiles/templates/profiles/profile.html b/oc_lettings_site/profiles/templates/profiles/profile.html index 9de08b5dbf..330f1000c4 100644 --- a/oc_lettings_site/profiles/templates/profiles/profile.html +++ b/oc_lettings_site/profiles/templates/profiles/profile.html @@ -5,5 +5,5 @@ <h1>{{ profile.user.username }}</h1> <p>Email: {{ profile.user.email }}</p> <p>Favorite city: {{ profile.favorite_city }}</p> <div><a href="{% url 'profiles:index' %}">Back</a></div> -<div><a href="{% url 'index' %}">Home</a></div> +<div><a href="{% url 'home:index' %}">Home</a></div> <div><a href="{% url 'lettings:index' %}">Lettings</a></div> \ No newline at end of file diff --git a/oc_lettings_site/settings.py b/oc_lettings_site/settings.py index a2f168f015..08f1221f4e 100644 --- a/oc_lettings_site/settings.py +++ b/oc_lettings_site/settings.py @@ -28,6 +28,7 @@ 'oc_lettings_site.apps.OCLettingsSiteConfig', 'oc_lettings_site.lettings', 'oc_lettings_site.profiles', + 'oc_lettings_site.home_site', ] MIDDLEWARE = [ @@ -45,7 +46,7 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(BASE_DIR, 'templates')], + 'DIRS': [os.path.join(BASE_DIR, 'oc_lettings_site/home_site/templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ diff --git a/oc_lettings_site/urls.py b/oc_lettings_site/urls.py index d7cfa538d2..f09f147b4f 100644 --- a/oc_lettings_site/urls.py +++ b/oc_lettings_site/urls.py @@ -1,10 +1,8 @@ from django.contrib import admin from django.urls import path, include -from . import views - urlpatterns = [ - path('', views.index, name='index'), + path('', include('oc_lettings_site.home_site.urls')), path('', include('oc_lettings_site.lettings.urls')), path('', include('oc_lettings_site.profiles.urls')), path('admin/', admin.site.urls), From d7f5cdd6d54e3c1e6dc593fe40a3660421fdab61 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Sat, 4 Mar 2023 14:23:05 +0100 Subject: [PATCH 13/21] linting for flake8 run_ok --- oc_lettings_site/home_site/urls.py | 2 +- oc_lettings_site/lettings/tests.py | 2 +- oc_lettings_site/profiles/tests.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/oc_lettings_site/home_site/urls.py b/oc_lettings_site/home_site/urls.py index f2f6c36b63..9366e51a44 100644 --- a/oc_lettings_site/home_site/urls.py +++ b/oc_lettings_site/home_site/urls.py @@ -5,4 +5,4 @@ app_name = 'home' urlpatterns = [ path('', views.index, name='index'), -] \ No newline at end of file +] diff --git a/oc_lettings_site/lettings/tests.py b/oc_lettings_site/lettings/tests.py index 7ce503c2dd..a79ca8be56 100644 --- a/oc_lettings_site/lettings/tests.py +++ b/oc_lettings_site/lettings/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +# from django.test import TestCase # Create your tests here. diff --git a/oc_lettings_site/profiles/tests.py b/oc_lettings_site/profiles/tests.py index 7ce503c2dd..a79ca8be56 100644 --- a/oc_lettings_site/profiles/tests.py +++ b/oc_lettings_site/profiles/tests.py @@ -1,3 +1,3 @@ -from django.test import TestCase +# from django.test import TestCase # Create your tests here. From e31b92a67898c7f71e79aa0b8eeb5d63c1e2aab5 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Sat, 4 Mar 2023 15:02:46 +0100 Subject: [PATCH 14/21] upgrade django and pytest-django for pytest run --- oc_lettings_site/settings.py | 2 -- requirements.txt | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/oc_lettings_site/settings.py b/oc_lettings_site/settings.py index 08f1221f4e..0148b20299 100644 --- a/oc_lettings_site/settings.py +++ b/oc_lettings_site/settings.py @@ -101,8 +101,6 @@ USE_I18N = True -USE_L10N = True - USE_TZ = True diff --git a/requirements.txt b/requirements.txt index c48c84ea40..84b6289eee 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ -django==3.0 +django==4.1.7 flake8==3.7.0 -pytest-django==3.9.0 \ No newline at end of file +pytest-django==4.5.2 \ No newline at end of file From 68d2a6062dc0d26fe693d7477ee4eba3a7d15291 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Sun, 5 Mar 2023 16:10:40 +0100 Subject: [PATCH 15/21] add home_site tests --- oc-lettings-site.sqlite3 | Bin 176128 -> 176128 bytes .../migrations/0001_initial.py | 0 .../migrations/0002_auto_20230227_1830.py | 0 .../migrations/0003_remove_old_tables.py | 0 oc_lettings_site/home_site/tests.py | 14 ++++++++++++++ oc_lettings_site/migrations/__init__.py | 0 oc_lettings_site/tests.py | 2 -- setup.cfg | 4 ++-- 8 files changed, 16 insertions(+), 4 deletions(-) rename oc_lettings_site/{ => home_site}/migrations/0001_initial.py (100%) rename oc_lettings_site/{ => home_site}/migrations/0002_auto_20230227_1830.py (100%) rename oc_lettings_site/{ => home_site}/migrations/0003_remove_old_tables.py (100%) create mode 100644 oc_lettings_site/home_site/tests.py delete mode 100644 oc_lettings_site/migrations/__init__.py delete mode 100644 oc_lettings_site/tests.py diff --git a/oc-lettings-site.sqlite3 b/oc-lettings-site.sqlite3 index 4d40c5c8621c712d3c8d13eb6e5721ad06b69efe..4f1a478b239c1ae0dc15dbccc4a46074c2709d6c 100644 GIT binary patch delta 1338 zcmah}U2NM_6t<nXanmGj>9#gNNvDm{GSb>{oWvDTNz<l{+q6lObzL<za}vi%lQ>P{ z#7RWeSwjd44`Y^Q1nZB`#9kOI3$)?^5JI3mAf8Z#v`Gx{zzaMe@d84C+ijIVleqFZ zy1w^2_dEBT&%SU^f8n0~(i0uC005j)O{W^HTIh}E2ynJ>{u-(=w_cHT?KsqWr6HYb zr6<iWaP*9aDGMnK!);L}E3n0Axum*ex>ypTJd<OiIi?!TvOFiGY?zI(V(Me>#qGm5 zF^steDcp`xc=MhaZ$V!}A=A&MJv5Fknf6S34Qa<D?+tpjH-RZo`85W1%jD32`LQFK z0nm6vV*&Sx59r`7SVO3gQLs~9AL`Sh-vX%o;m{OlzJ+ySaGQDyeM7oyYW~I>!47m0 zfDQeCq2Kh0>8P<}_^u%xGw38MXapp;%xrb75frA5laxdB&%4r|Nn)llCQ#X=SiqC& z@=S7athkUP`LoH|Y}Otq#av9)7N$pojyXFyoi3gVlM7iNwdisG=gRhBk{Bd0yNz@* ziCmgLa4)bqCY>FO=W{9=vtkbUm#t2N)D5fo3;@VLCn^7R)hxewbwV@EWaZmepXs2P zT$+_E+WQD|*Mz*iVV1i#M&OAelgi1_4b1FiN+pI*6dCDh%>&#~25BWaWzS|r8)V8^ z`OQr?>Paxt<IsJ;af?%SZ<^(gH@vNL`9v|zmD&2`&3=T=r+Br9@5)PC@7%hHv^SAU zf1(<o9cb#d|M;v2UIX;n9l-dvF=F^!|BYUQ+(BU7l6D8CVS4we^B@Daw7ms>KW<Ti zEZB48KqB~I``XmK_jY$!aAv)!-PX2$gh0Pr_M4^>0H(X>dPAxkA*f~d6)W^SxCYz~ zyaan3#ayw<6J?>~%Gqi{lCJ>(crtJ?<PpV;fK~WHp+vcs32r6N<#94zNHAE2t5Z&V zkfp2h%Yo9YnD(3=O<H|I*cY12)6*1TA1jBfp+dn&GxN!bWIdi)V3%$6K$T335$C)R zWL@OiO3s&JQ&l!ggdC%Mj0=h$YK6+g!dPq(pBu}ZW`#f{CRVa|Fj0$gVu4x~R%WUT zei!GAkNZZ`b$_|y57oFrJQtox<tub3k@b^aTRP6vun@y~^Nvj3mCSg(#c_K&G>osD z4YT!OE^p(U6A`*rS`L#%=ah4T&N!y$aeu`TBLa~#uDO7f3e+Q^@tXKhcev}|Q+uF0 zCrQ}#59*3uMlUxzR$fK>`2Q=IMh)>RuUnyB<<1Dy_pmeQ59l@Zgtt-4xku62DW}s$ z?8hqC2ce!G!15>*iR~w)*$G10;FEft2pE<O$J^HR?X5cGE1ig}nvNNNL{^d2hIB@^ zD_)1T;TH4@;On@1UrOD|2k%22%K00RP6^zAu0Z&hBC#NLqW9vnUR{^P0=|4gU}9PJ zP-}-1MCqWxPUR;S{8VvsV6XCJ60B;}|CTbsftD6EZTIZJ0f&WW#c1>}FpB^Cz4squ CPK}cQ delta 658 zcmZ{gPiPZS5XRrU{hQ5hUP8g7)FxY$LeWijvrSE-F;o#MQrm-2@X$Y|QF`&v6zWAx zY!Hcpm4FXCc@Wy7joqeXz1E_~UX(&<h2X8ASV0dWQeRpGFEV^{nC}~Y!xS1yp`pyR z1^N*}CzvEAf$8$&lQ#4_W6uc}@-!-v-*Sozo?4^T63H@oK(Oz#Z}YI6V%=BSjGpH| zpsPT?U4u|15$kH5o}RpUBR`s-oX(AoPfSeZ@_8{Ra5jsagO*A;*2!xs7pbhqE<tF; zY%v9$ab>5t<8!}{U_YqHj}ZAnK9UWxRtppyLf0PQ%t`_LqHhZc>Tpe(`%PSa4|sn~ zUjF&2-TM@&d>v`~+7)$8*-$unTNb1dVMVyZ*WK_Kj0>V=i@^&KI+TNUDpoP^dS|=h zQZN#MdmU7-;-LFJ2UhuzzDvH6ALJLKZxMDp0Op&W<C>kvJO>_O6@%{ey+NRrkXF)4 zPVtt;-#v{5_r8J8fCy&?N<trPWUx+O8hHPhX_!4mJgJ+#sctKk=!y0wyOYUN3fVzG zTtr;rGT;lsALj;uJ~Y_gb_REP$tUKoBeG7`neUQxnCpYM8Mh77HY{7W;wd|svaG0W zcAE(kvv-D>{U2O?2=hZnWoZVfBWj1YtoS{W{7#yYZ~rZ)I4rp{^Z1z{B7}Fd>E_cy zG_i!MPp*Sb%ZqrBPGuoN_ZG1(4kpFmKbb%!8k49e3vCKQ5Duo(Fnf_kvvB0Vu(NQG Q0GTc<;mE=4?L2<{2gk3k8UO$Q diff --git a/oc_lettings_site/migrations/0001_initial.py b/oc_lettings_site/home_site/migrations/0001_initial.py similarity index 100% rename from oc_lettings_site/migrations/0001_initial.py rename to oc_lettings_site/home_site/migrations/0001_initial.py diff --git a/oc_lettings_site/migrations/0002_auto_20230227_1830.py b/oc_lettings_site/home_site/migrations/0002_auto_20230227_1830.py similarity index 100% rename from oc_lettings_site/migrations/0002_auto_20230227_1830.py rename to oc_lettings_site/home_site/migrations/0002_auto_20230227_1830.py diff --git a/oc_lettings_site/migrations/0003_remove_old_tables.py b/oc_lettings_site/home_site/migrations/0003_remove_old_tables.py similarity index 100% rename from oc_lettings_site/migrations/0003_remove_old_tables.py rename to oc_lettings_site/home_site/migrations/0003_remove_old_tables.py diff --git a/oc_lettings_site/home_site/tests.py b/oc_lettings_site/home_site/tests.py new file mode 100644 index 0000000000..2b4b647c4c --- /dev/null +++ b/oc_lettings_site/home_site/tests.py @@ -0,0 +1,14 @@ +import pytest +from django.test import Client +from django.urls import reverse + + +@pytest.fixture +def client(db) -> Client: + return Client() + + +def test_home_index(client: Client): + response = client.get(reverse("home:index"), data={}) + assert response.status_code == 200 + assert "<title>Holiday Homes</title>" in str(response.content) diff --git a/oc_lettings_site/migrations/__init__.py b/oc_lettings_site/migrations/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/oc_lettings_site/tests.py b/oc_lettings_site/tests.py deleted file mode 100644 index 3fd62bb718..0000000000 --- a/oc_lettings_site/tests.py +++ /dev/null @@ -1,2 +0,0 @@ -def test_dummy(): - assert 1 diff --git a/setup.cfg b/setup.cfg index 9346841bbc..e02924b717 100644 --- a/setup.cfg +++ b/setup.cfg @@ -4,5 +4,5 @@ exclude = **/migrations/*,venv [tool:pytest] DJANGO_SETTINGS_MODULE = oc_lettings_site.settings -python_files = tests.py -addopts = -v +python_files = *tests.py +addopts = -v --nomigrations From b034a6ecb8180669efc5a96a92cb26856b8e8074 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Sun, 5 Mar 2023 17:08:52 +0100 Subject: [PATCH 16/21] add lettings tests --- oc_lettings_site/lettings/tests.py | 48 ++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/oc_lettings_site/lettings/tests.py b/oc_lettings_site/lettings/tests.py index a79ca8be56..be4600347a 100644 --- a/oc_lettings_site/lettings/tests.py +++ b/oc_lettings_site/lettings/tests.py @@ -1,3 +1,47 @@ -# from django.test import TestCase +import pytest +from django.test import Client +from django.urls import reverse -# Create your tests here. +from .models import Address, Letting + + +@pytest.fixture +def client(db) -> Client: + return Client() + + +@pytest.fixture +def test_address(db) : + return Address.objects.create( + number=1, + street="my street", + city="my city", + state="France", + zip_code="75001", + country_iso_code="FRA", + ) + + +@pytest.fixture +def test_letting(db, test_address): + return Letting.objects.create(title="My vacation home", address=test_address) + + +def test_index_lettings(client: Client): + response = client.get(reverse("lettings:index"), data={}) + assert response.status_code == 200 + assert "<title>Lettings</title>" in str(response.content) + + +def test_detail_letting(client: Client, test_letting: Letting): + response = client.get(reverse("lettings:letting", args=[1]), data={}) + assert response.status_code == 200 + assert "My vacation home" in str(response.content) + + +def test_str_letting(test_letting: Letting): + assert str(test_letting) == "My vacation home" + + +def test_str_address(test_address: Address): + assert str(test_address) == "1 my street" From 3e3e6ab157def68d553aa87298b26c1f147eea9e Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Sun, 5 Mar 2023 19:33:17 +0100 Subject: [PATCH 17/21] add profiles tests --- oc_lettings_site/profiles/tests.py | 38 ++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/oc_lettings_site/profiles/tests.py b/oc_lettings_site/profiles/tests.py index a79ca8be56..c9e26018b5 100644 --- a/oc_lettings_site/profiles/tests.py +++ b/oc_lettings_site/profiles/tests.py @@ -1,3 +1,37 @@ -# from django.test import TestCase +import pytest +from django.contrib.auth.models import User +from django.test import Client +from django.urls import reverse -# Create your tests here. +from .models import Profile + + +@pytest.fixture +def client(db) -> Client: + return Client() + + +@pytest.fixture +def user_test(db): + return User.objects.create_user(username="User1", password="pwd12345") + + +@pytest.fixture +def profile_test(db, user_test: User): + return Profile.objects.create(user=user_test, favorite_city="Paris") + + +def test_index_profile(client: Client): + response = client.get(reverse("profiles:index"), data={}) + assert response.status_code == 200 + assert "<title>Profiles</title>" in str(response.content) + + +def test_details_profile(client: Client, profile_test: Profile): + response = client.get(reverse("profiles:profile", args=["User1"]), data={}) + assert response.status_code == 200 + assert "<title>User1</title>" in str(response.content) + + +def test_str_profile(profile_test: Profile): + assert str(profile_test) == "User1" From d08dede8866387859c482876f173b6019fb4ae61 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Tue, 7 Mar 2023 14:31:09 +0100 Subject: [PATCH 18/21] add Dockerfile --- .dockerignore | 7 +++++++ Dockerfile | 15 +++++++++++++++ oc_lettings_site/settings.py | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..88c83eef10 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.env +.pytest_cache +__pycache__ +Dockerfile +.git +venv +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..3e8ede0c87 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.10.5-alpine + +WORKDIR /code + +# Add project files to the code/ folder +ADD ./ . + +# Install dependencies +RUN pip install -r requirements.txt + +# Define the default port +EXPOSE 8000 + +# Setup executable command in the container +CMD python manage.py runserver 0.0.0.0:8000 \ No newline at end of file diff --git a/oc_lettings_site/settings.py b/oc_lettings_site/settings.py index 0148b20299..e759c9ced8 100644 --- a/oc_lettings_site/settings.py +++ b/oc_lettings_site/settings.py @@ -13,7 +13,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['0.0.0.0'] # Application definition From 7c9b0ae5d11f088e6118eded93bad49617b67922 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Tue, 7 Mar 2023 18:24:15 +0100 Subject: [PATCH 19/21] add config.yml --- .circleci/config.yml | 24 ++++++++++++++++++++++++ .dockerignore | 2 +- env | 0 setup.cfg | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 .circleci/config.yml create mode 100644 env diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000000..a8d3a6176a --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,24 @@ + # CircleCi version + version: 2.1 + + orbs: + python: circleci/python@2.1.1 + + jobs: + build-and-test: + executor: python/default + steps: + - checkout + - python/install-packages: + pip-dependency-file: requirements.txt + pkg-manager: pip + - run: + command: pytest + name: run pytest + - run: + command: flake8 + name: run linting +workflows: + master: + jobs: + - build-and-test \ No newline at end of file diff --git a/.dockerignore b/.dockerignore index 88c83eef10..276b019c77 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,4 @@ -.env +env .pytest_cache __pycache__ Dockerfile diff --git a/env b/env new file mode 100644 index 0000000000..e69de29bb2 diff --git a/setup.cfg b/setup.cfg index e02924b717..eebe4c449f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [flake8] max-line-length = 99 -exclude = **/migrations/*,venv +exclude = **/migrations/*, env [tool:pytest] DJANGO_SETTINGS_MODULE = oc_lettings_site.settings From 09f8fc8c1a87e1237d42672bb5d7ac5cf567f7fa Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Wed, 8 Mar 2023 11:31:13 +0100 Subject: [PATCH 20/21] bugfix config.yml --- .circleci/config.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a8d3a6176a..cbe8d6b5d5 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,7 +18,7 @@ - run: command: flake8 name: run linting -workflows: - master: - jobs: - - build-and-test \ No newline at end of file + workflows: + master: + jobs: + - build-and-test \ No newline at end of file From 62fe355bec12f13ccf1a8ee59b61880609aae228 Mon Sep 17 00:00:00 2001 From: Cyl94700 <cyrilcouybes@gmail.com> Date: Wed, 8 Mar 2023 11:45:33 +0100 Subject: [PATCH 21/21] bugfix linting --- oc_lettings_site/lettings/tests.py | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/oc_lettings_site/lettings/tests.py b/oc_lettings_site/lettings/tests.py index be4600347a..a77eb96fbb 100644 --- a/oc_lettings_site/lettings/tests.py +++ b/oc_lettings_site/lettings/tests.py @@ -11,7 +11,7 @@ def client(db) -> Client: @pytest.fixture -def test_address(db) : +def test_address(db): return Address.objects.create( number=1, street="my street", diff --git a/setup.cfg b/setup.cfg index eebe4c449f..7d98947ea6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [flake8] max-line-length = 99 -exclude = **/migrations/*, env +exclude = **/migrations/*, venv [tool:pytest] DJANGO_SETTINGS_MODULE = oc_lettings_site.settings