From db64fd4d59289b31950e6f3ea4e2ef3943202490 Mon Sep 17 00:00:00 2001 From: NM Date: Mon, 18 May 2026 12:25:26 +0200 Subject: [PATCH 1/4] Modification : initial commit, update setup.cfg and .gitignore, add flake8 report --- .gitignore | 2 + flake8-report/back.svg | 73 ++++ flake8-report/file.svg | 64 +++ flake8-report/index.html | 38 ++ .../oc_lettings_site.settings.report.html | 73 ++++ .../oc_lettings_site.settings.source.html | 374 ++++++++++++++++++ .../oc_lettings_site.views.report.html | 226 +++++++++++ .../oc_lettings_site.views.source.html | 305 ++++++++++++++ flake8-report/styles.css | 327 +++++++++++++++ setup.cfg | 4 +- 10 files changed, 1485 insertions(+), 1 deletion(-) create mode 100644 flake8-report/back.svg create mode 100644 flake8-report/file.svg create mode 100644 flake8-report/index.html create mode 100644 flake8-report/oc_lettings_site.settings.report.html create mode 100644 flake8-report/oc_lettings_site.settings.source.html create mode 100644 flake8-report/oc_lettings_site.views.report.html create mode 100644 flake8-report/oc_lettings_site.views.source.html create mode 100644 flake8-report/styles.css diff --git a/.gitignore b/.gitignore index b4405ebab4..cf3238f122 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ **/__pycache__ *.pyc venv +env +.idea \ No newline at end of file diff --git a/flake8-report/back.svg b/flake8-report/back.svg new file mode 100644 index 0000000000..ce80d2e6da --- /dev/null +++ b/flake8-report/back.svg @@ -0,0 +1,73 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/flake8-report/file.svg b/flake8-report/file.svg new file mode 100644 index 0000000000..98706cfe53 --- /dev/null +++ b/flake8-report/file.svg @@ -0,0 +1,64 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/flake8-report/index.html b/flake8-report/index.html new file mode 100644 index 0000000000..2975318f72 --- /dev/null +++ b/flake8-report/index.html @@ -0,0 +1,38 @@ + + + + flake8 violations + + + + +
+
+

flake8 violations

+

Generated on 2026-05-18 12:22 + with mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1 +

+ +
+ + \ No newline at end of file diff --git a/flake8-report/oc_lettings_site.settings.report.html b/flake8-report/oc_lettings_site.settings.report.html new file mode 100644 index 0000000000..2efd087813 --- /dev/null +++ b/flake8-report/oc_lettings_site.settings.report.html @@ -0,0 +1,73 @@ + + + + flake8 violations: oc_lettings_site\settings.py + + + + + +
+
+ +

+ + ⬅ + oc_lettings_site\settings.py + +

+ + +
+ + \ No newline at end of file diff --git a/flake8-report/oc_lettings_site.settings.source.html b/flake8-report/oc_lettings_site.settings.source.html new file mode 100644 index 0000000000..19a962680d --- /dev/null +++ b/flake8-report/oc_lettings_site.settings.source.html @@ -0,0 +1,374 @@ + + + + oc_lettings_site\settings.py - flake8 annotated source + + + + +
+
+

+ + ⬅ + oc_lettings_site\settings.py source + +

+ +
+
1 import os +
+
2   +
+
3 from pathlib import Path +
+
4   +
+
5 # Build paths inside the project like this: os.path.join(BASE_DIR, ...) +
+
6 BASE_DIR = Path(__file__).resolve().parent.parent +
+
7   +
+
8   +
+
9 # Quick-start development settings - unsuitable for production +
+
10 # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ +
+
11   +
+
12 # SECURITY WARNING: keep the secret key used in production secret! +
+
13 SECRET_KEY = 'fp$9^593hsriajg$_%=5trot9g!1qa@ew(o-1#@=&4%=hp46(s' +
+
14   +
+
15 # SECURITY WARNING: don't run with debug turned on in production! +
+
16 DEBUG = True +
+
17   +
+
18 ALLOWED_HOSTS = [] +
+
19   +
+
20   +
+
21 # Application definition +
+
22   +
+
23 INSTALLED_APPS = [ +
+
24 'oc_lettings_site.apps.OCLettingsSiteConfig', +
+
25 'django.contrib.admin', +
+
26 'django.contrib.auth', +
+
27 'django.contrib.contenttypes', +
+
28 'django.contrib.sessions', +
+
29 'django.contrib.messages', +
+
30 'django.contrib.staticfiles', +
+
31 ] +
+
32   +
+
33 MIDDLEWARE = [ +
+
34 'django.middleware.security.SecurityMiddleware', +
+
35 'django.contrib.sessions.middleware.SessionMiddleware', +
+
36 'django.middleware.common.CommonMiddleware', +
+
37 'django.middleware.csrf.CsrfViewMiddleware', +
+
38 'django.contrib.auth.middleware.AuthenticationMiddleware', +
+
39 'django.contrib.messages.middleware.MessageMiddleware', +
+
40 'django.middleware.clickjacking.XFrameOptionsMiddleware', +
+
41 ] +
+
42   +
+
43 ROOT_URLCONF = 'oc_lettings_site.urls' +
+
44   +
+
45 TEMPLATES = [ +
+
46 { +
+
47 'BACKEND': 'django.template.backends.django.DjangoTemplates', +
+
48 'DIRS': [os.path.join(BASE_DIR, 'templates')], +
+
49 'APP_DIRS': True, +
+
50 'OPTIONS': { +
+
51 'context_processors': [ +
+
52 'django.template.context_processors.debug', +
+
53 'django.template.context_processors.request', +
+
54 'django.contrib.auth.context_processors.auth', +
+
55 'django.contrib.messages.context_processors.messages', +
+
56 ], +
+
57 }, +
+
58 }, +
+
59 ] +
+
60   +
+
61 WSGI_APPLICATION = 'oc_lettings_site.wsgi.application' +
+
62   +
+
63   +
+
64 # Database +
+
65 # https://docs.djangoproject.com/en/3.0/ref/settings/#databases +
+
66   +
+
67 DATABASES = { +
+
68 'default': { +
+
69 'ENGINE': 'django.db.backends.sqlite3', +
+
70 'NAME': os.path.join(BASE_DIR, 'oc-lettings-site.sqlite3'), +
+
71 } +
+
72 } +
+
73   +
+
74   +
+
75 # Password validation +
+
76 # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators +
+
77   +
+
78 AUTH_PASSWORD_VALIDATORS = [ +
+
79 { +
+
80 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', +
+
81 }, +
+
82 { +
+
83 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', +
+
84 }, +
+
85 { +
+
86 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', +
+
87 }, +
+
88 { +
+
89 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', +
+
90 }, +
+
91 ] +
+
92   +
+
93   +
+
94 # Internationalization +
+
95 # https://docs.djangoproject.com/en/3.0/topics/i18n/ +
+
96   +
+
97 LANGUAGE_CODE = 'en-us' +
+
98   +
+
99 TIME_ZONE = 'UTC' +
+
100   +
+
101 USE_I18N = True +
+
102   +
+
103 USE_L10N = True +
+
104   +
+
105 USE_TZ = True +
+
106   +
+
107   +
+
108 # Static files (CSS, JavaScript, Images) +
+
109 # https://docs.djangoproject.com/en/3.0/howto/static-files/ +
+
110   +
+
111 STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') +
+
112   +
+
113 STATIC_URL = '/static/' +
+
+
    + +
  • + + E231 + + Missing whitespace after ','
  • + +
114 STATICFILES_DIRS = [BASE_DIR / "static",] +
+ +
+
+ + \ No newline at end of file diff --git a/flake8-report/oc_lettings_site.views.report.html b/flake8-report/oc_lettings_site.views.report.html new file mode 100644 index 0000000000..6787b3915d --- /dev/null +++ b/flake8-report/oc_lettings_site.views.report.html @@ -0,0 +1,226 @@ + + + + flake8 violations: oc_lettings_site\views.py + + + + + +
+
+ +

+ + ⬅ + oc_lettings_site\views.py + +

+ + +
+ + \ No newline at end of file diff --git a/flake8-report/oc_lettings_site.views.source.html b/flake8-report/oc_lettings_site.views.source.html new file mode 100644 index 0000000000..ce67b841c5 --- /dev/null +++ b/flake8-report/oc_lettings_site.views.source.html @@ -0,0 +1,305 @@ + + + + oc_lettings_site\views.py - flake8 annotated source + + + + +
+
+

+ + ⬅ + oc_lettings_site\views.py source + +

+ +
+
1 from django.shortcuts import render +
+
2 from .models import Letting, Profile +
+
3   +
+
4   +
+
5   +
+
6   +
+
+
    + +
  • + + E303 + + Too many blank lines (4)
  • + +
  • + + E501 + + Line too long (198 > 99 characters)
  • + +
7 # 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, +
+
+
    + +
  • + + E501 + + Line too long (153 > 99 characters)
  • + +
8 # vitae dapibus nisi lorem dapibus sem. Maecenas pharetra purus ipsum, eget consequat ipsum lobortis quis. Phasellus eleifend ex auctor venenatis tempus. +
+
+
    + +
  • + + E501 + + Line too long (174 > 99 characters)
  • + +
9 # 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. +
+
+
    + +
  • + + E302 + + Expected 2 blank lines, found 4
  • + +
10 def index(request): +
+
11 return render(request, 'index.html') +
+
12   +
+
+
    + +
  • + + E501 + + Line too long (131 > 99 characters)
  • + +
13 # Aenean leo magna, vestibulum et tincidunt fermentum, consectetur quis velit. Sed non placerat massa. Integer est nunc, pulvinar a +
+
+
    + +
  • + + E501 + + Line too long (140 > 99 characters)
  • + +
14 # tempor et, bibendum id arcu. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Cras eget scelerisque +
+
+
    + +
  • + + E302 + + Expected 2 blank lines, found 1
  • + +
15 def lettings_index(request): +
+
16 lettings_list = Letting.objects.all() +
+
17 context = {'lettings_list': lettings_list} +
+
18 return render(request, 'lettings_index.html', context) +
+
19   +
+
20   +
+
+
    + +
  • + + E265 + + Block comment should start with '# '
  • + +
  • + + E501 + + Line too long (189 > 99 characters)
  • + +
21 #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 +
+
+
    + +
  • + + E501 + + Line too long (216 > 99 characters)
  • + +
22 # 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. +
+
+
    + +
  • + + E501 + + Line too long (391 > 99 characters)
  • + +
23 # 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. +
+
24 def letting(request, letting_id): +
+
25 letting = Letting.objects.get(id=letting_id) +
+
26 context = { +
+
27 'title': letting.title, +
+
28 'address': letting.address, +
+
29 } +
+
30 return render(request, 'letting.html', context) +
+
31   +
+
+
    + +
  • + + E501 + + Line too long (112 > 99 characters)
  • + +
32 # Sed placerat quam in pulvinar commodo. Nullam laoreet consectetur ex, sed consequat libero pulvinar eget. Fusc +
+
33 # faucibus, urna quis auctor pharetra, massa dolor cursus neque, quis dictum lacus d +
+
+
    + +
  • + + E302 + + Expected 2 blank lines, found 1
  • + +
34 def profiles_index(request): +
+
35 profiles_list = Profile.objects.all() +
+
36 context = {'profiles_list': profiles_list} +
+
37 return render(request, 'profiles_index.html', context) +
+
38   +
+
39 # Aliquam sed metus eget nisi tincidunt ornare accumsan eget lac +
+
+
    + +
  • + + E501 + + Line too long (147 > 99 characters)
  • + +
40 # laoreet neque quis, pellentesque dui. Nullam facilisis pharetra vulputate. Sed tincidunt, dolor id facilisis fringilla, eros leo tristique lacus, +
+
+
    + +
  • + + E501 + + Line too long (100 > 99 characters)
  • + +
41 # it. Nam aliquam dignissim congue. Pellentesque habitant morbi tristique senectus et netus et males +
+
+
    + +
  • + + E302 + + Expected 2 blank lines, found 1
  • + +
42 def profile(request, username): +
+
43 profile = Profile.objects.get(user__username=username) +
+
44 context = {'profile': profile} +
+
45 return render(request, 'profile.html', context) +
+ +
+
+ + \ No newline at end of file diff --git a/flake8-report/styles.css b/flake8-report/styles.css new file mode 100644 index 0000000000..6e0e447a6e --- /dev/null +++ b/flake8-report/styles.css @@ -0,0 +1,327 @@ +html { + font-family: sans-serif; + font-size: 90%; +} + +#masthead { + position: fixed; + left: 0; + top: 0; + right: 0; + height: 40%; +} + +h1, h2 { + font-family: sans-serif; + font-weight: normal; +} + +h1 { + color: white; + font-size: 36px; + margin-top: 1em; +} + +h1 img { + margin-right: 0.3em; +} + +h2 { + margin-top: 0; +} + +h1 a { + color: white; +} + +#versions { + color: rgba(255, 255, 255, 0.7); +} + +#page { + position: relative; + max-width: 960px; + margin: 0 auto; +} + +#index { + background-color: white; + box-shadow: 0 0 4px rgba(0, 0, 0, 0.8); + padding: 0; + margin: 0; +} + +#index li { + list-style: none; + margin: 0; + padding: 1px 0; +} + +#index li + li { + border-top: solid silver 1px; +} + +.details p { + margin-left: 3em; + color: #888; +} + +#index a { + display: block; + padding: 0.8em 1em; + cursor: pointer; +} + +#index #all-good { + padding: 1.4em 1em 0.8em; +} + +#all-good .count .tick { + font-size: 2em; +} + +#all-good .count { + float: left; +} + +#all-good h2, +#all-good p { + margin-left: 50px; +} + +#index a:hover { + background-color: #eee; +} + +.count { + display: inline-block; + border-radius: 50%; + text-align: center; + width: 2.5em; + line-height: 2.5em; + height: 2.5em; + color: white; + margin-right: 1em; +} + +.sev-1 { + background-color: #a00; +} +.sev-2 { + background-color: #b80; +} +.sev-3 { + background-color: #28c; +} +.sev-4 { + background-color: #383; +} + +a { + text-decoration: none; +} + +#doc { + background-color: white; + margin: 1em 0; + padding: 1em; + padding-left: 1.2em; + position: relative; + box-shadow: 0 0 4px rgba(0, 0, 0, 0.8); +} + +#doc pre { + margin: 0; + padding: 0.07em; +} + +.violations { + position: absolute; + margin: 1.2em 0 0 3em; + padding: 0.5em 1em; + font-size: 14px; + background-color: white; + box-shadow: 0 0 4px rgba(0, 0, 0, 0.4); + display: none; +} + +.violations .count { + font-size: 70%; +} + +.violations li { + padding: 0.1em 0.3em; + list-style: none; +} + +.line-violations::before { + display: block; + content: ""; + position: absolute; + left: -1em; + width: 14px; + height: 14px; + border-radius: 50%; + background-color: red; +} + +.code:hover .violations { + display: block; +} + +tt { + white-space: pre-wrap; + font-family: Consolas, monospace; + font-size: 10pt; +} + +tt i { + color: silver; + display: inline-block; + text-align: right; + width: 3em; + box-sizing: border-box; + height: 100%; + border-right: solid #eee 1px; + padding-right: 0.2em; +} + +.le { + background-color: #ffe8e8; + cursor: pointer; +} + +.le:hover { + background-color: #fcc; +} + +.details { + clear: both; +} + +#index .details { + border-top-style: none; + margin: 1em; +} + +ul.details { + margin-left: 0; + padding-left: 0; +} + +#index .details li { + list-style: none; + border-top-style: none; + margin: 0.3em 0; + padding: 0; +} + +#srclink { + float: right; + font-size: 36px; + margin: 0; +} + +#srclink a { + color: white; +} + +#index .details a { + padding: 0; + color: inherit; +} + +.le { + background-color: #ffe8e8; + cursor: pointer; +} + +.le.sev-1 { + background-color: #f88; +} +.le.sev-2 { + background-color: #fda; +} +.le.sev-3 { + background-color: #adf; +} + +img { + height: 1.2em; + vertical-align: -0.35em; +} + +pre { line-height: 125%; } +td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +.hll { background-color: #ffffcc } +.c { color: #3D7B7B; font-style: italic } /* Comment */ +.err { border: 1px solid #F00 } /* Error */ +.k { color: #008000; font-weight: bold } /* Keyword */ +.o { color: #666 } /* Operator */ +.ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */ +.cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */ +.cp { color: #9C6500 } /* Comment.Preproc */ +.cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */ +.c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */ +.cs { color: #3D7B7B; font-style: italic } /* Comment.Special */ +.gd { color: #A00000 } /* Generic.Deleted */ +.ge { font-style: italic } /* Generic.Emph */ +.ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ +.gr { color: #E40000 } /* Generic.Error */ +.gh { color: #000080; font-weight: bold } /* Generic.Heading */ +.gi { color: #008400 } /* Generic.Inserted */ +.go { color: #717171 } /* Generic.Output */ +.gp { color: #000080; font-weight: bold } /* Generic.Prompt */ +.gs { font-weight: bold } /* Generic.Strong */ +.gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.gt { color: #04D } /* Generic.Traceback */ +.kc { color: #008000; font-weight: bold } /* Keyword.Constant */ +.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ +.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ +.kp { color: #008000 } /* Keyword.Pseudo */ +.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ +.kt { color: #B00040 } /* Keyword.Type */ +.m { color: #666 } /* Literal.Number */ +.s { color: #BA2121 } /* Literal.String */ +.na { color: #687822 } /* Name.Attribute */ +.nb { color: #008000 } /* Name.Builtin */ +.nc { color: #00F; font-weight: bold } /* Name.Class */ +.no { color: #800 } /* Name.Constant */ +.nd { color: #A2F } /* Name.Decorator */ +.ni { color: #717171; font-weight: bold } /* Name.Entity */ +.ne { color: #CB3F38; font-weight: bold } /* Name.Exception */ +.nf { color: #00F } /* Name.Function */ +.nl { color: #767600 } /* Name.Label */ +.nn { color: #00F; font-weight: bold } /* Name.Namespace */ +.nt { color: #008000; font-weight: bold } /* Name.Tag */ +.nv { color: #19177C } /* Name.Variable */ +.ow { color: #A2F; font-weight: bold } /* Operator.Word */ +.w { color: #BBB } /* Text.Whitespace */ +.mb { color: #666 } /* Literal.Number.Bin */ +.mf { color: #666 } /* Literal.Number.Float */ +.mh { color: #666 } /* Literal.Number.Hex */ +.mi { color: #666 } /* Literal.Number.Integer */ +.mo { color: #666 } /* Literal.Number.Oct */ +.sa { color: #BA2121 } /* Literal.String.Affix */ +.sb { color: #BA2121 } /* Literal.String.Backtick */ +.sc { color: #BA2121 } /* Literal.String.Char */ +.dl { color: #BA2121 } /* Literal.String.Delimiter */ +.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ +.s2 { color: #BA2121 } /* Literal.String.Double */ +.se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */ +.sh { color: #BA2121 } /* Literal.String.Heredoc */ +.si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */ +.sx { color: #008000 } /* Literal.String.Other */ +.sr { color: #A45A77 } /* Literal.String.Regex */ +.s1 { color: #BA2121 } /* Literal.String.Single */ +.ss { color: #19177C } /* Literal.String.Symbol */ +.bp { color: #008000 } /* Name.Builtin.Pseudo */ +.fm { color: #00F } /* Name.Function.Magic */ +.vc { color: #19177C } /* Name.Variable.Class */ +.vg { color: #19177C } /* Name.Variable.Global */ +.vi { color: #19177C } /* Name.Variable.Instance */ +.vm { color: #19177C } /* Name.Variable.Magic */ +.il { color: #666 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 9346841bbc..2c33038dd1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,8 @@ [flake8] +format = html +htmldir = flake8-report max-line-length = 99 -exclude = **/migrations/*,venv +exclude = **/migrations/*,env [tool:pytest] DJANGO_SETTINGS_MODULE = oc_lettings_site.settings From d401c94f00bf0b3c0935073fb37db647f9c43f66 Mon Sep 17 00:00:00 2001 From: NM Date: Mon, 18 May 2026 17:41:32 +0200 Subject: [PATCH 2/4] File change and modification : make migrations into two new apps ; update urls, views and templates accordingly to new apps ; update admin.py into new apps --- .gitignore | 5 +- lettings/__init__.py | 0 lettings/admin.py | 8 +++ lettings/apps.py | 5 ++ lettings/migrations/0001_initial.py | 36 +++++++++++++ .../migrations/0002_auto_20260518_1543.py | 48 ++++++++++++++++++ .../migrations/0003_auto_20260518_1551.py | 19 +++++++ lettings/migrations/__init__.py | 0 {oc_lettings_site => lettings}/models.py | 9 ---- .../templates/lettings/index.html | 4 +- .../templates/lettings}/letting.html | 4 +- lettings/tests.py | 3 ++ lettings/urls.py | 10 ++++ lettings/views.py | 23 +++++++++ oc-lettings-site.sqlite3 | Bin 151552 -> 180224 bytes oc_lettings_site/admin.py | 10 ---- .../migrations/0002_auto_20260518_1551.py | 30 +++++++++++ oc_lettings_site/settings.py | 2 + oc_lettings_site/urls.py | 8 ++- oc_lettings_site/views.py | 37 -------------- profiles/__init__.py | 0 profiles/admin.py | 6 +++ profiles/apps.py | 5 ++ profiles/migrations/0001_initial.py | 25 +++++++++ .../migrations/0002_auto_20260518_1548.py | 27 ++++++++++ .../migrations/0003_auto_20260518_1551.py | 21 ++++++++ profiles/migrations/__init__.py | 0 profiles/models.py | 10 ++++ .../templates/profiles/index.html | 4 +- .../templates/profiles}/profile.html | 4 +- profiles/tests.py | 3 ++ profiles/urls.py | 10 ++++ profiles/views.py | 20 ++++++++ templates/base.html | 4 +- templates/index.html | 4 +- 35 files changed, 330 insertions(+), 74 deletions(-) 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/0002_auto_20260518_1543.py create mode 100644 lettings/migrations/0003_auto_20260518_1551.py create mode 100644 lettings/migrations/__init__.py rename {oc_lettings_site => lettings}/models.py (75%) rename templates/lettings_index.html => lettings/templates/lettings/index.html (89%) rename {templates => lettings/templates/lettings}/letting.html (95%) create mode 100644 lettings/tests.py create mode 100644 lettings/urls.py create mode 100644 lettings/views.py create mode 100644 oc_lettings_site/migrations/0002_auto_20260518_1551.py create mode 100644 profiles/__init__.py create mode 100644 profiles/admin.py create mode 100644 profiles/apps.py create mode 100644 profiles/migrations/0001_initial.py create mode 100644 profiles/migrations/0002_auto_20260518_1548.py create mode 100644 profiles/migrations/0003_auto_20260518_1551.py create mode 100644 profiles/migrations/__init__.py create mode 100644 profiles/models.py rename templates/profiles_index.html => profiles/templates/profiles/index.html (88%) rename {templates => profiles/templates/profiles}/profile.html (96%) create mode 100644 profiles/tests.py create mode 100644 profiles/urls.py create mode 100644 profiles/views.py diff --git a/.gitignore b/.gitignore index cf3238f122..923c196816 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ *.pyc venv env -.idea \ No newline at end of file +.idea +backup.sqlite3 +oc-lettings-site_old.sqlite3 +flake8-report \ No newline at end of file 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..4633a55339 --- /dev/null +++ b/lettings/admin.py @@ -0,0 +1,8 @@ +from django.contrib import admin + +from lettings.models import Address, Letting + + +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..9a008d3d77 --- /dev/null +++ b/lettings/migrations/0001_initial.py @@ -0,0 +1,36 @@ +# Generated by Django 3.0 on 2026-05-18 12:53 + +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)])), + ], + ), + 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, related_name='new_letting', to='lettings.Address')), + ], + ), + ] diff --git a/lettings/migrations/0002_auto_20260518_1543.py b/lettings/migrations/0002_auto_20260518_1543.py new file mode 100644 index 0000000000..47cb6b8db2 --- /dev/null +++ b/lettings/migrations/0002_auto_20260518_1543.py @@ -0,0 +1,48 @@ +# Generated by Django 3.0 on 2026-05-18 13:43 + +from django.db import migrations + + +def copy_address(apps, schema_editor): + OldAddress = apps.get_model('oc_lettings_site', 'Address') + NewAddress = apps.get_model('lettings', 'Address') + + for obj in OldAddress.objects.all(): + NewAddress.objects.create( + id=obj.id, + number=obj.number, + street=obj.street, + city=obj.city, + state=obj.state, + zip_code=obj.zip_code, + country_iso_code=obj.country_iso_code, + ) + + +def copy_lettings(apps, schema_editor): + OldLetting = apps.get_model('oc_lettings_site', 'Letting') + NewLetting = apps.get_model('lettings', 'Letting') + NewAddress = apps.get_model('lettings', 'Address') + + for obj in OldLetting.objects.all(): + + new_address = NewAddress.objects.get(id=obj.address.id) + + NewLetting.objects.create( + id=obj.id, + title=obj.title, + address=new_address, + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ('lettings', '0001_initial'), + ('oc_lettings_site', '0001_initial'), + ] + + operations = [ + migrations.RunPython(copy_address), + migrations.RunPython(copy_lettings), + ] diff --git a/lettings/migrations/0003_auto_20260518_1551.py b/lettings/migrations/0003_auto_20260518_1551.py new file mode 100644 index 0000000000..11b098bd67 --- /dev/null +++ b/lettings/migrations/0003_auto_20260518_1551.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0 on 2026-05-18 13:51 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('lettings', '0002_auto_20260518_1543'), + ] + + operations = [ + migrations.AlterField( + model_name='letting', + name='address', + field=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/oc_lettings_site/models.py b/lettings/models.py similarity index 75% rename from oc_lettings_site/models.py rename to lettings/models.py index ed255e8c11..8e76ef00d2 100644 --- a/oc_lettings_site/models.py +++ b/lettings/models.py @@ -1,6 +1,5 @@ from django.db import models from django.core.validators import MaxValueValidator, MinLengthValidator -from django.contrib.auth.models import User class Address(models.Model): @@ -21,11 +20,3 @@ class Letting(models.Model): 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 diff --git a/templates/lettings_index.html b/lettings/templates/lettings/index.html similarity index 89% rename from templates/lettings_index.html rename to lettings/templates/lettings/index.html index 92857a78d9..a85f3a348e 100644 --- a/templates/lettings_index.html +++ b/lettings/templates/lettings/index.html @@ -20,7 +20,7 @@

Lettings

@@ -36,7 +36,7 @@

Lettings

Home - + Profiles diff --git a/templates/letting.html b/lettings/templates/lettings/letting.html similarity index 95% rename from templates/letting.html rename to lettings/templates/lettings/letting.html index 7e5f3a73fd..252d68035e 100644 --- a/templates/letting.html +++ b/lettings/templates/lettings/letting.html @@ -25,14 +25,14 @@

{{ 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/urls.py b/lettings/urls.py new file mode 100644 index 0000000000..8b261ec831 --- /dev/null +++ b/lettings/urls.py @@ -0,0 +1,10 @@ +from django.urls import path + +from . import views + +app_name = 'lettings' + +urlpatterns = [ + path('', views.index, name='index'), + path('/', views.letting, name='letting'), +] diff --git a/lettings/views.py b/lettings/views.py new file mode 100644 index 0000000000..fc357cad20 --- /dev/null +++ b/lettings/views.py @@ -0,0 +1,23 @@ +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 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, 'lettings/letting.html', context) diff --git a/oc-lettings-site.sqlite3 b/oc-lettings-site.sqlite3 index 3d885414f9f3ed046704e8b09bdcd5c791c82d42..92f150a14ef936c2ea5bdcf1208527af89ca775b 100644 GIT binary patch delta 3359 zcmcgvZ){W76~E`b=YP-7?9hMlEh9s~I+Of5pMva%4)FW|% zZJ?`$5~rYPtJF2k#GCk1zO)rXQ|nr(RjHzdPIT%AL?@<6B_(KGr?E0^l?wZ?RoQ(v z&ml3<%D&9;JHF@KbAIRCbMHCtX6CGEX2$$NeeEDZsDnIi^61I)y}1tAHi$Y$Ku0(R z-z5~aaHz<`(`he2LHT?WWI6=Zl3Srs=-TI@GW| zK9!w3lpaszBuSDJ$)ownL_i9JrI0_8@P|TvmGMa-pFiUC%RM1~PpG>y8i@uY;XVho zA5Z1;>CD*wWZxZ$c27&Y>^kJz9-kaZR4@{`bUsA_2|P$30jV=82cuG?Z&UR`?zay{ z)-NO&o$d)rok4#j><`N}0^nJj34bD;N$1na@hYoOPbkzGmi)3D>9bZZe*>@bM)sj- zfOrkbb<}HR?PS^i)oUmc2uR`5f%=y@rvsV9+X&ynXK)t3gI~wbVMe@-zmFfs4(t$1 z#loD(V+Yy>nbh$_Lis!cjzNwHHbG^(6WV~YT3H`df~f3--dej>nj9U?rgAwwzJ?wF zil*nt`0Jqjd;%Ozs(iDJ?FOrjSl#Eru483l^)S?dF#lZF;IO0~PgAv?4cIOi{b4dQ zHkp`6k7bkj^kgQtnJ3DEcn4tx=kc@n5FWxjZp44Wzryc}cW|&+_`Mjjat-yXjx}I` z3M(tqmSA2d)F%1)VC?D^LHq*YPw-`Y4xh%eIEPbs5X*QgHi=&p3)jS0oxq`n`byZ^ zZ=G2cR(Yx8*9x`Cd3o=LtR(c$8}svyej-cm=z|3CxrfD;bZgk zLmYTOIF=@Rr+JaA9JGQknj%=Kim+=%IPw%p*{ZO!mV<2|kmXj?d=$=1;j}DtP)oB0 zrwQ9vgd6NSr> zLzbQ_?L2UaSMP@v{*PH4(eC{L87#a(oRZ!Dm8ad+D>U3rL8LETPXEX+DxgZNlT30{14eEL-*q7x^nZYrJmM z8J^U=p_}I3)a_=Q#5o~rX*XYo@1lJ~d2lYi={x2#%py7Mi2Po&`+V?hET8&!Dr#<-q>AvItfA0o3EosM|u@M=?lth8K_m34}zOBpMe+4o+P*#y&Tfp2V7L4e0&4~ zdh$jC@3(wZ;$3y74HEupNee=pM_D=y^Bh9#^UASt*i$~2hCZ5lV1O^dO;&o9I}7A= z7#9`8RTy&cKj!!I9lX)>XVV4KX;ap;&(vZ<#>HYGZ#23k9RiO}P;TCU216HNTK$5; zErH9>sWBad8TJuoTl?DD+L_EaNt&EmnYueD(7IYvRn)_+>Zwh%xt&6qm0vD_)7adm zaqkeW&DlyltgW_+2hG~uLOt-xZZ%XdHRhGf4H9az#++6e4+Y|t3pb#?{L)8|w7vK) zSK_ArjbHf()ND~t8TqK!2QPWl%LU0RY9mi;sdnZPR&F#h%|^y@5{Z{ACyRxrEiJR# z8Qt(nT|9M6iso|iGoy#64o!uR9-c^zA03Oz8F}KFobe}PNFln@Za&B;?(na?uB9H)-pI;7CSN;FC*be!Dap#Ut=;D zFN?2<8N7fO^ykRm>&3!P^j6~qbj3a}0JAn)a`)cSx_d*bYki^Jn^6WQ;faA(;|0*u zHW8&Dl^0W`?^pA!>)|TX%8p5RS5Lwo(rVCOnW+FJ?vu2st5kCkdqi*7%%-ag_5RW| z&gys4PV<0`&9FY=Y6os-i#t8)cBV7=)L2T{Iso4PPn!#YvUnIyEA11|t7OOFEgmnx z!j=F4 delta 792 zcmY*W-Aj{U6o1b1zI*33-O=gX)aka+h-$hobz9Ak3e=$HML}KI{90!D5!?QNy|ZpI zLLK-(7bZcNq2e0x7F~p1WS7f=q7-EXkyi%Ygps{7iahY}oacAW`8|i-bSup^sFX78NoCxRWgya3^KGej8Q#iahzL({v=1`Bh2Lp-FX=J>ZRR zi3*Jbzv5jC;|pBGQ9OrrXiSQ~vKP$LQhK=py(DU*arIVjLqF!d7%8#S%=o z0/', views.letting, name='letting'), - path('profiles/', views.profiles_index, name='profiles_index'), - path('profiles//', views.profile, name='profile'), + path('lettings/', include('lettings.urls')), + path('profiles/', include('profiles.urls')), path('admin/', admin.site.urls), ] diff --git a/oc_lettings_site/views.py b/oc_lettings_site/views.py index a72db27074..22eaa0dcbe 100644 --- a/oc_lettings_site/views.py +++ b/oc_lettings_site/views.py @@ -1,7 +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 consectetur ullamcorper non id est. Praesent dictum, nulla eget feugiat sagittis, sem mi convallis eros, @@ -9,37 +6,3 @@ # 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 -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/profiles/__init__.py b/profiles/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/profiles/admin.py b/profiles/admin.py new file mode 100644 index 0000000000..9f66e5c835 --- /dev/null +++ b/profiles/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin + +from profiles.models import Profile + + +admin.site.register(Profile) diff --git a/profiles/apps.py b/profiles/apps.py new file mode 100644 index 0000000000..5501fdad35 --- /dev/null +++ b/profiles/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ProfilesConfig(AppConfig): + name = 'profiles' diff --git a/profiles/migrations/0001_initial.py b/profiles/migrations/0001_initial.py new file mode 100644 index 0000000000..069a3babcc --- /dev/null +++ b/profiles/migrations/0001_initial.py @@ -0,0 +1,25 @@ +# Generated by Django 3.0 on 2026-05-18 12:53 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='Profile', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('favorite_city', models.CharField(blank=True, max_length=64)), + ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='new_profile', to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/profiles/migrations/0002_auto_20260518_1548.py b/profiles/migrations/0002_auto_20260518_1548.py new file mode 100644 index 0000000000..7be66c52bf --- /dev/null +++ b/profiles/migrations/0002_auto_20260518_1548.py @@ -0,0 +1,27 @@ +# Generated by Django 3.0 on 2026-05-18 13:48 + +from django.db import migrations + + +def copy_profile(apps, schema_editor): + OldProfile = apps.get_model('oc_lettings_site', 'Profile') + NewProfile = apps.get_model('profiles', 'Profile') + + for obj in OldProfile.objects.all(): + NewProfile.objects.create( + id=obj.id, + user=obj.user, + favorite_city=obj.favorite_city, + ) + + +class Migration(migrations.Migration): + + dependencies = [ + ('profiles', '0001_initial'), + ('oc_lettings_site', '0001_initial'), + ] + + operations = [ + migrations.RunPython(copy_profile), + ] diff --git a/profiles/migrations/0003_auto_20260518_1551.py b/profiles/migrations/0003_auto_20260518_1551.py new file mode 100644 index 0000000000..61fbe40024 --- /dev/null +++ b/profiles/migrations/0003_auto_20260518_1551.py @@ -0,0 +1,21 @@ +# Generated by Django 3.0 on 2026-05-18 13:51 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('profiles', '0002_auto_20260518_1548'), + ] + + operations = [ + migrations.AlterField( + model_name='profile', + name='user', + field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/profiles/migrations/__init__.py b/profiles/migrations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/profiles/models.py b/profiles/models.py new file mode 100644 index 0000000000..84c85c1001 --- /dev/null +++ b/profiles/models.py @@ -0,0 +1,10 @@ +from django.db import models +from django.contrib.auth.models import User + + +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 diff --git a/templates/profiles_index.html b/profiles/templates/profiles/index.html similarity index 88% rename from templates/profiles_index.html rename to profiles/templates/profiles/index.html index 4ad1daf92f..563b7a0166 100644 --- a/templates/profiles_index.html +++ b/profiles/templates/profiles/index.html @@ -18,7 +18,7 @@

Profiles

@@ -34,7 +34,7 @@

Profiles

Home - + Lettings
diff --git a/templates/profile.html b/profiles/templates/profiles/profile.html similarity index 96% rename from templates/profile.html rename to profiles/templates/profiles/profile.html index d150d30e63..4b1af37496 100644 --- a/templates/profile.html +++ b/profiles/templates/profiles/profile.html @@ -24,14 +24,14 @@

{{ profile.user.username }}

diff --git a/profiles/tests.py b/profiles/tests.py new file mode 100644 index 0000000000..7ce503c2dd --- /dev/null +++ b/profiles/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/profiles/urls.py b/profiles/urls.py new file mode 100644 index 0000000000..b33a49ae2d --- /dev/null +++ b/profiles/urls.py @@ -0,0 +1,10 @@ +from django.urls import path + +from . import views + +app_name = 'profiles' + +urlpatterns = [ + path('', views.index, name='index'), + path('/', views.profile, name='profile'), +] diff --git a/profiles/views.py b/profiles/views.py new file mode 100644 index 0000000000..7d2af649c5 --- /dev/null +++ b/profiles/views.py @@ -0,0 +1,20 @@ +from django.shortcuts import render + +from profiles.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 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, 'profiles/profile.html', context) + diff --git a/templates/base.html b/templates/base.html index ab7addba01..403b342755 100644 --- a/templates/base.html +++ b/templates/base.html @@ -24,10 +24,10 @@
Logo Orange County Lettings diff --git a/templates/index.html b/templates/index.html index 71a8e61a46..fc9a76c7ab 100644 --- a/templates/index.html +++ b/templates/index.html @@ -14,10 +14,10 @@

Welcome to Holiday Homes

From ac51dad279227da7b2d838ad6eb254db6b6f106b Mon Sep 17 00:00:00 2001 From: NM Date: Tue, 19 May 2026 09:29:22 +0200 Subject: [PATCH 3/4] Modification : update code after flake8 linting report in order to comfy Pep 8 convention --- flake8-report/back.svg | 73 ---- flake8-report/file.svg | 64 --- flake8-report/index.html | 38 -- .../oc_lettings_site.settings.report.html | 73 ---- .../oc_lettings_site.settings.source.html | 374 ------------------ .../oc_lettings_site.views.report.html | 226 ----------- .../oc_lettings_site.views.source.html | 305 -------------- flake8-report/styles.css | 327 --------------- lettings/admin.py | 1 - lettings/views.py | 17 +- oc_lettings_site/settings.py | 2 +- oc_lettings_site/views.py | 9 +- profiles/views.py | 12 +- 13 files changed, 26 insertions(+), 1495 deletions(-) delete mode 100644 flake8-report/back.svg delete mode 100644 flake8-report/file.svg delete mode 100644 flake8-report/index.html delete mode 100644 flake8-report/oc_lettings_site.settings.report.html delete mode 100644 flake8-report/oc_lettings_site.settings.source.html delete mode 100644 flake8-report/oc_lettings_site.views.report.html delete mode 100644 flake8-report/oc_lettings_site.views.source.html delete mode 100644 flake8-report/styles.css diff --git a/flake8-report/back.svg b/flake8-report/back.svg deleted file mode 100644 index ce80d2e6da..0000000000 --- a/flake8-report/back.svg +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - diff --git a/flake8-report/file.svg b/flake8-report/file.svg deleted file mode 100644 index 98706cfe53..0000000000 --- a/flake8-report/file.svg +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - diff --git a/flake8-report/index.html b/flake8-report/index.html deleted file mode 100644 index 2975318f72..0000000000 --- a/flake8-report/index.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - flake8 violations - - - - -
-
-

flake8 violations

-

Generated on 2026-05-18 12:22 - with mccabe: 0.6.1, pycodestyle: 2.5.0, pyflakes: 2.1.1 -

- -
- - \ No newline at end of file diff --git a/flake8-report/oc_lettings_site.settings.report.html b/flake8-report/oc_lettings_site.settings.report.html deleted file mode 100644 index 2efd087813..0000000000 --- a/flake8-report/oc_lettings_site.settings.report.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - flake8 violations: oc_lettings_site\settings.py - - - - - -
- - - \ No newline at end of file diff --git a/flake8-report/oc_lettings_site.settings.source.html b/flake8-report/oc_lettings_site.settings.source.html deleted file mode 100644 index 19a962680d..0000000000 --- a/flake8-report/oc_lettings_site.settings.source.html +++ /dev/null @@ -1,374 +0,0 @@ - - - - oc_lettings_site\settings.py - flake8 annotated source - - - - -
-
-

- - ⬅ - oc_lettings_site\settings.py source - -

- -
-
1 import os -
-
2   -
-
3 from pathlib import Path -
-
4   -
-
5 # Build paths inside the project like this: os.path.join(BASE_DIR, ...) -
-
6 BASE_DIR = Path(__file__).resolve().parent.parent -
-
7   -
-
8   -
-
9 # Quick-start development settings - unsuitable for production -
-
10 # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ -
-
11   -
-
12 # SECURITY WARNING: keep the secret key used in production secret! -
-
13 SECRET_KEY = 'fp$9^593hsriajg$_%=5trot9g!1qa@ew(o-1#@=&4%=hp46(s' -
-
14   -
-
15 # SECURITY WARNING: don't run with debug turned on in production! -
-
16 DEBUG = True -
-
17   -
-
18 ALLOWED_HOSTS = [] -
-
19   -
-
20   -
-
21 # Application definition -
-
22   -
-
23 INSTALLED_APPS = [ -
-
24 'oc_lettings_site.apps.OCLettingsSiteConfig', -
-
25 'django.contrib.admin', -
-
26 'django.contrib.auth', -
-
27 'django.contrib.contenttypes', -
-
28 'django.contrib.sessions', -
-
29 'django.contrib.messages', -
-
30 'django.contrib.staticfiles', -
-
31 ] -
-
32   -
-
33 MIDDLEWARE = [ -
-
34 'django.middleware.security.SecurityMiddleware', -
-
35 'django.contrib.sessions.middleware.SessionMiddleware', -
-
36 'django.middleware.common.CommonMiddleware', -
-
37 'django.middleware.csrf.CsrfViewMiddleware', -
-
38 'django.contrib.auth.middleware.AuthenticationMiddleware', -
-
39 'django.contrib.messages.middleware.MessageMiddleware', -
-
40 'django.middleware.clickjacking.XFrameOptionsMiddleware', -
-
41 ] -
-
42   -
-
43 ROOT_URLCONF = 'oc_lettings_site.urls' -
-
44   -
-
45 TEMPLATES = [ -
-
46 { -
-
47 'BACKEND': 'django.template.backends.django.DjangoTemplates', -
-
48 'DIRS': [os.path.join(BASE_DIR, 'templates')], -
-
49 'APP_DIRS': True, -
-
50 'OPTIONS': { -
-
51 'context_processors': [ -
-
52 'django.template.context_processors.debug', -
-
53 'django.template.context_processors.request', -
-
54 'django.contrib.auth.context_processors.auth', -
-
55 'django.contrib.messages.context_processors.messages', -
-
56 ], -
-
57 }, -
-
58 }, -
-
59 ] -
-
60   -
-
61 WSGI_APPLICATION = 'oc_lettings_site.wsgi.application' -
-
62   -
-
63   -
-
64 # Database -
-
65 # https://docs.djangoproject.com/en/3.0/ref/settings/#databases -
-
66   -
-
67 DATABASES = { -
-
68 'default': { -
-
69 'ENGINE': 'django.db.backends.sqlite3', -
-
70 'NAME': os.path.join(BASE_DIR, 'oc-lettings-site.sqlite3'), -
-
71 } -
-
72 } -
-
73   -
-
74   -
-
75 # Password validation -
-
76 # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators -
-
77   -
-
78 AUTH_PASSWORD_VALIDATORS = [ -
-
79 { -
-
80 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', -
-
81 }, -
-
82 { -
-
83 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', -
-
84 }, -
-
85 { -
-
86 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', -
-
87 }, -
-
88 { -
-
89 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', -
-
90 }, -
-
91 ] -
-
92   -
-
93   -
-
94 # Internationalization -
-
95 # https://docs.djangoproject.com/en/3.0/topics/i18n/ -
-
96   -
-
97 LANGUAGE_CODE = 'en-us' -
-
98   -
-
99 TIME_ZONE = 'UTC' -
-
100   -
-
101 USE_I18N = True -
-
102   -
-
103 USE_L10N = True -
-
104   -
-
105 USE_TZ = True -
-
106   -
-
107   -
-
108 # Static files (CSS, JavaScript, Images) -
-
109 # https://docs.djangoproject.com/en/3.0/howto/static-files/ -
-
110   -
-
111 STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') -
-
112   -
-
113 STATIC_URL = '/static/' -
-
-
    - -
  • - - E231 - - Missing whitespace after ','
  • - -
114 STATICFILES_DIRS = [BASE_DIR / "static",] -
- -
-
- - \ No newline at end of file diff --git a/flake8-report/oc_lettings_site.views.report.html b/flake8-report/oc_lettings_site.views.report.html deleted file mode 100644 index 6787b3915d..0000000000 --- a/flake8-report/oc_lettings_site.views.report.html +++ /dev/null @@ -1,226 +0,0 @@ - - - - flake8 violations: oc_lettings_site\views.py - - - - - -
-
- -

- - ⬅ - oc_lettings_site\views.py - -

- - -
- - \ No newline at end of file diff --git a/flake8-report/oc_lettings_site.views.source.html b/flake8-report/oc_lettings_site.views.source.html deleted file mode 100644 index ce67b841c5..0000000000 --- a/flake8-report/oc_lettings_site.views.source.html +++ /dev/null @@ -1,305 +0,0 @@ - - - - oc_lettings_site\views.py - flake8 annotated source - - - - -
-
-

- - ⬅ - oc_lettings_site\views.py source - -

- -
-
1 from django.shortcuts import render -
-
2 from .models import Letting, Profile -
-
3   -
-
4   -
-
5   -
-
6   -
-
-
    - -
  • - - E303 - - Too many blank lines (4)
  • - -
  • - - E501 - - Line too long (198 > 99 characters)
  • - -
7 # 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, -
-
-
    - -
  • - - E501 - - Line too long (153 > 99 characters)
  • - -
8 # vitae dapibus nisi lorem dapibus sem. Maecenas pharetra purus ipsum, eget consequat ipsum lobortis quis. Phasellus eleifend ex auctor venenatis tempus. -
-
-
    - -
  • - - E501 - - Line too long (174 > 99 characters)
  • - -
9 # 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. -
-
-
    - -
  • - - E302 - - Expected 2 blank lines, found 4
  • - -
10 def index(request): -
-
11 return render(request, 'index.html') -
-
12   -
-
-
    - -
  • - - E501 - - Line too long (131 > 99 characters)
  • - -
13 # Aenean leo magna, vestibulum et tincidunt fermentum, consectetur quis velit. Sed non placerat massa. Integer est nunc, pulvinar a -
-
-
    - -
  • - - E501 - - Line too long (140 > 99 characters)
  • - -
14 # tempor et, bibendum id arcu. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Cras eget scelerisque -
-
-
    - -
  • - - E302 - - Expected 2 blank lines, found 1
  • - -
15 def lettings_index(request): -
-
16 lettings_list = Letting.objects.all() -
-
17 context = {'lettings_list': lettings_list} -
-
18 return render(request, 'lettings_index.html', context) -
-
19   -
-
20   -
-
-
    - -
  • - - E265 - - Block comment should start with '# '
  • - -
  • - - E501 - - Line too long (189 > 99 characters)
  • - -
21 #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 -
-
-
    - -
  • - - E501 - - Line too long (216 > 99 characters)
  • - -
22 # 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. -
-
-
    - -
  • - - E501 - - Line too long (391 > 99 characters)
  • - -
23 # 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. -
-
24 def letting(request, letting_id): -
-
25 letting = Letting.objects.get(id=letting_id) -
-
26 context = { -
-
27 'title': letting.title, -
-
28 'address': letting.address, -
-
29 } -
-
30 return render(request, 'letting.html', context) -
-
31   -
-
-
    - -
  • - - E501 - - Line too long (112 > 99 characters)
  • - -
32 # Sed placerat quam in pulvinar commodo. Nullam laoreet consectetur ex, sed consequat libero pulvinar eget. Fusc -
-
33 # faucibus, urna quis auctor pharetra, massa dolor cursus neque, quis dictum lacus d -
-
-
    - -
  • - - E302 - - Expected 2 blank lines, found 1
  • - -
34 def profiles_index(request): -
-
35 profiles_list = Profile.objects.all() -
-
36 context = {'profiles_list': profiles_list} -
-
37 return render(request, 'profiles_index.html', context) -
-
38   -
-
39 # Aliquam sed metus eget nisi tincidunt ornare accumsan eget lac -
-
-
    - -
  • - - E501 - - Line too long (147 > 99 characters)
  • - -
40 # laoreet neque quis, pellentesque dui. Nullam facilisis pharetra vulputate. Sed tincidunt, dolor id facilisis fringilla, eros leo tristique lacus, -
-
-
    - -
  • - - E501 - - Line too long (100 > 99 characters)
  • - -
41 # it. Nam aliquam dignissim congue. Pellentesque habitant morbi tristique senectus et netus et males -
-
-
    - -
  • - - E302 - - Expected 2 blank lines, found 1
  • - -
42 def profile(request, username): -
-
43 profile = Profile.objects.get(user__username=username) -
-
44 context = {'profile': profile} -
-
45 return render(request, 'profile.html', context) -
- -
-
- - \ No newline at end of file diff --git a/flake8-report/styles.css b/flake8-report/styles.css deleted file mode 100644 index 6e0e447a6e..0000000000 --- a/flake8-report/styles.css +++ /dev/null @@ -1,327 +0,0 @@ -html { - font-family: sans-serif; - font-size: 90%; -} - -#masthead { - position: fixed; - left: 0; - top: 0; - right: 0; - height: 40%; -} - -h1, h2 { - font-family: sans-serif; - font-weight: normal; -} - -h1 { - color: white; - font-size: 36px; - margin-top: 1em; -} - -h1 img { - margin-right: 0.3em; -} - -h2 { - margin-top: 0; -} - -h1 a { - color: white; -} - -#versions { - color: rgba(255, 255, 255, 0.7); -} - -#page { - position: relative; - max-width: 960px; - margin: 0 auto; -} - -#index { - background-color: white; - box-shadow: 0 0 4px rgba(0, 0, 0, 0.8); - padding: 0; - margin: 0; -} - -#index li { - list-style: none; - margin: 0; - padding: 1px 0; -} - -#index li + li { - border-top: solid silver 1px; -} - -.details p { - margin-left: 3em; - color: #888; -} - -#index a { - display: block; - padding: 0.8em 1em; - cursor: pointer; -} - -#index #all-good { - padding: 1.4em 1em 0.8em; -} - -#all-good .count .tick { - font-size: 2em; -} - -#all-good .count { - float: left; -} - -#all-good h2, -#all-good p { - margin-left: 50px; -} - -#index a:hover { - background-color: #eee; -} - -.count { - display: inline-block; - border-radius: 50%; - text-align: center; - width: 2.5em; - line-height: 2.5em; - height: 2.5em; - color: white; - margin-right: 1em; -} - -.sev-1 { - background-color: #a00; -} -.sev-2 { - background-color: #b80; -} -.sev-3 { - background-color: #28c; -} -.sev-4 { - background-color: #383; -} - -a { - text-decoration: none; -} - -#doc { - background-color: white; - margin: 1em 0; - padding: 1em; - padding-left: 1.2em; - position: relative; - box-shadow: 0 0 4px rgba(0, 0, 0, 0.8); -} - -#doc pre { - margin: 0; - padding: 0.07em; -} - -.violations { - position: absolute; - margin: 1.2em 0 0 3em; - padding: 0.5em 1em; - font-size: 14px; - background-color: white; - box-shadow: 0 0 4px rgba(0, 0, 0, 0.4); - display: none; -} - -.violations .count { - font-size: 70%; -} - -.violations li { - padding: 0.1em 0.3em; - list-style: none; -} - -.line-violations::before { - display: block; - content: ""; - position: absolute; - left: -1em; - width: 14px; - height: 14px; - border-radius: 50%; - background-color: red; -} - -.code:hover .violations { - display: block; -} - -tt { - white-space: pre-wrap; - font-family: Consolas, monospace; - font-size: 10pt; -} - -tt i { - color: silver; - display: inline-block; - text-align: right; - width: 3em; - box-sizing: border-box; - height: 100%; - border-right: solid #eee 1px; - padding-right: 0.2em; -} - -.le { - background-color: #ffe8e8; - cursor: pointer; -} - -.le:hover { - background-color: #fcc; -} - -.details { - clear: both; -} - -#index .details { - border-top-style: none; - margin: 1em; -} - -ul.details { - margin-left: 0; - padding-left: 0; -} - -#index .details li { - list-style: none; - border-top-style: none; - margin: 0.3em 0; - padding: 0; -} - -#srclink { - float: right; - font-size: 36px; - margin: 0; -} - -#srclink a { - color: white; -} - -#index .details a { - padding: 0; - color: inherit; -} - -.le { - background-color: #ffe8e8; - cursor: pointer; -} - -.le.sev-1 { - background-color: #f88; -} -.le.sev-2 { - background-color: #fda; -} -.le.sev-3 { - background-color: #adf; -} - -img { - height: 1.2em; - vertical-align: -0.35em; -} - -pre { line-height: 125%; } -td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } -span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } -td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } -span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } -.hll { background-color: #ffffcc } -.c { color: #3D7B7B; font-style: italic } /* Comment */ -.err { border: 1px solid #F00 } /* Error */ -.k { color: #008000; font-weight: bold } /* Keyword */ -.o { color: #666 } /* Operator */ -.ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */ -.cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */ -.cp { color: #9C6500 } /* Comment.Preproc */ -.cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */ -.c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */ -.cs { color: #3D7B7B; font-style: italic } /* Comment.Special */ -.gd { color: #A00000 } /* Generic.Deleted */ -.ge { font-style: italic } /* Generic.Emph */ -.ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ -.gr { color: #E40000 } /* Generic.Error */ -.gh { color: #000080; font-weight: bold } /* Generic.Heading */ -.gi { color: #008400 } /* Generic.Inserted */ -.go { color: #717171 } /* Generic.Output */ -.gp { color: #000080; font-weight: bold } /* Generic.Prompt */ -.gs { font-weight: bold } /* Generic.Strong */ -.gu { color: #800080; font-weight: bold } /* Generic.Subheading */ -.gt { color: #04D } /* Generic.Traceback */ -.kc { color: #008000; font-weight: bold } /* Keyword.Constant */ -.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ -.kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ -.kp { color: #008000 } /* Keyword.Pseudo */ -.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ -.kt { color: #B00040 } /* Keyword.Type */ -.m { color: #666 } /* Literal.Number */ -.s { color: #BA2121 } /* Literal.String */ -.na { color: #687822 } /* Name.Attribute */ -.nb { color: #008000 } /* Name.Builtin */ -.nc { color: #00F; font-weight: bold } /* Name.Class */ -.no { color: #800 } /* Name.Constant */ -.nd { color: #A2F } /* Name.Decorator */ -.ni { color: #717171; font-weight: bold } /* Name.Entity */ -.ne { color: #CB3F38; font-weight: bold } /* Name.Exception */ -.nf { color: #00F } /* Name.Function */ -.nl { color: #767600 } /* Name.Label */ -.nn { color: #00F; font-weight: bold } /* Name.Namespace */ -.nt { color: #008000; font-weight: bold } /* Name.Tag */ -.nv { color: #19177C } /* Name.Variable */ -.ow { color: #A2F; font-weight: bold } /* Operator.Word */ -.w { color: #BBB } /* Text.Whitespace */ -.mb { color: #666 } /* Literal.Number.Bin */ -.mf { color: #666 } /* Literal.Number.Float */ -.mh { color: #666 } /* Literal.Number.Hex */ -.mi { color: #666 } /* Literal.Number.Integer */ -.mo { color: #666 } /* Literal.Number.Oct */ -.sa { color: #BA2121 } /* Literal.String.Affix */ -.sb { color: #BA2121 } /* Literal.String.Backtick */ -.sc { color: #BA2121 } /* Literal.String.Char */ -.dl { color: #BA2121 } /* Literal.String.Delimiter */ -.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ -.s2 { color: #BA2121 } /* Literal.String.Double */ -.se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */ -.sh { color: #BA2121 } /* Literal.String.Heredoc */ -.si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */ -.sx { color: #008000 } /* Literal.String.Other */ -.sr { color: #A45A77 } /* Literal.String.Regex */ -.s1 { color: #BA2121 } /* Literal.String.Single */ -.ss { color: #19177C } /* Literal.String.Symbol */ -.bp { color: #008000 } /* Name.Builtin.Pseudo */ -.fm { color: #00F } /* Name.Function.Magic */ -.vc { color: #19177C } /* Name.Variable.Class */ -.vg { color: #19177C } /* Name.Variable.Global */ -.vi { color: #19177C } /* Name.Variable.Instance */ -.vm { color: #19177C } /* Name.Variable.Magic */ -.il { color: #666 } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/lettings/admin.py b/lettings/admin.py index 4633a55339..b31639f1b1 100644 --- a/lettings/admin.py +++ b/lettings/admin.py @@ -5,4 +5,3 @@ admin.site.register(Letting) admin.site.register(Address) - diff --git a/lettings/views.py b/lettings/views.py index fc357cad20..758a37bf64 100644 --- a/lettings/views.py +++ b/lettings/views.py @@ -3,17 +3,24 @@ 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 +# 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 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 = { diff --git a/oc_lettings_site/settings.py b/oc_lettings_site/settings.py index e4d4401198..e527926df9 100644 --- a/oc_lettings_site/settings.py +++ b/oc_lettings_site/settings.py @@ -113,4 +113,4 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATIC_URL = '/static/' -STATICFILES_DIRS = [BASE_DIR / "static",] +STATICFILES_DIRS = [BASE_DIR / "static", ] diff --git a/oc_lettings_site/views.py b/oc_lettings_site/views.py index 22eaa0dcbe..967f48ff61 100644 --- a/oc_lettings_site/views.py +++ b/oc_lettings_site/views.py @@ -1,8 +1,11 @@ from django.shortcuts import render -# 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') diff --git a/profiles/views.py b/profiles/views.py index 7d2af649c5..6853615d15 100644 --- a/profiles/views.py +++ b/profiles/views.py @@ -3,18 +3,20 @@ from profiles.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 +# 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 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} return render(request, 'profiles/profile.html', context) - From 0c5b95577847cf2237ee8c741658f93de0e95e9f Mon Sep 17 00:00:00 2001 From: NM Date: Tue, 19 May 2026 10:10:32 +0200 Subject: [PATCH 4/4] Modification : fix admin plural issue, manage/customize 404 and 500 errors with new specific templates --- lettings/models.py | 4 ++++ lettings/views.py | 24 +++++++++++++++++------- profiles/views.py | 16 +++++++++++++--- templates/error_404.html | 30 ++++++++++++++++++++++++++++++ templates/error_500.html | 26 ++++++++++++++++++++++++++ 5 files changed, 90 insertions(+), 10 deletions(-) create mode 100644 templates/error_404.html create mode 100644 templates/error_500.html diff --git a/lettings/models.py b/lettings/models.py index 8e76ef00d2..df27eead49 100644 --- a/lettings/models.py +++ b/lettings/models.py @@ -10,6 +10,10 @@ class Address(models.Model): zip_code = models.PositiveIntegerField(validators=[MaxValueValidator(99999)]) country_iso_code = models.CharField(max_length=3, validators=[MinLengthValidator(3)]) + class Meta: + verbose_name = "Address" + verbose_name_plural = "Addresses" + def __str__(self): return f'{self.number} {self.street}' diff --git a/lettings/views.py b/lettings/views.py index 758a37bf64..303a59e040 100644 --- a/lettings/views.py +++ b/lettings/views.py @@ -1,4 +1,4 @@ -from django.shortcuts import render +from django.shortcuts import render, get_object_or_404 from .models import Letting @@ -22,9 +22,19 @@ def index(request): # 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, 'lettings/letting.html', context) + try: + letting = Letting.objects.get(id=letting_id) + + context = { + 'title': letting.title, + 'address': letting.address, + } + return render(request, 'lettings/letting.html', context=context) + + except Letting.DoesNotExist: + context = {"type": "letting", "id": letting_id} + return render(request, 'error_404.html', context=context) + + except Exception as e: + context = {"error": e} + return render(request, 'error_500.html', context=context) diff --git a/profiles/views.py b/profiles/views.py index 6853615d15..13fb49857f 100644 --- a/profiles/views.py +++ b/profiles/views.py @@ -17,6 +17,16 @@ def index(request): # 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, 'profiles/profile.html', context) + try: + profile = Profile.objects.get(user__username=username) + context = {'profile': profile} + + return render(request, 'profiles/profile.html', context) + + except Profile.DoesNotExist: + context = {"type": "profile", "name": username} + return render(request, 'error_404.html', context=context) + + except Exception as e: + context = {"error": e} + return render(request, 'error_500.html', context=context) diff --git a/templates/error_404.html b/templates/error_404.html new file mode 100644 index 0000000000..bc8477aadb --- /dev/null +++ b/templates/error_404.html @@ -0,0 +1,30 @@ +{% extends "base.html" %} +{% block title %}Holiday Homes{% endblock title %} + +{% block content %} + + +
+
+
+ {% if type == "letting" %} +

404 Error : {{ type }} n° {{ id }} not found !

+ {% elif type == "profile" %} +

404 Error : {{ type }} '{{ name }}' not found !

+ {% endif %} +
+
+
+ + + +{% endblock %} \ No newline at end of file diff --git a/templates/error_500.html b/templates/error_500.html new file mode 100644 index 0000000000..f7d65b087f --- /dev/null +++ b/templates/error_500.html @@ -0,0 +1,26 @@ +{% extends "base.html" %} +{% block title %}Holiday Homes{% endblock title %} + +{% block content %} + + +
+
+
+

500 Error : something wrong with the server - {{ error }}

+
+
+
+ + + +{% endblock %} \ No newline at end of file