Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
13f302e
Update for session 8 content
wsot Aug 11, 2022
db72024
Content for session 9. Tidy up URLs and Views.
wsot Aug 18, 2022
813a809
Session 10 - add search
wsot Aug 18, 2022
509bb13
Session 10 - multi-field search
wsot Aug 18, 2022
80a5ffb
Session 10 - Add search to generic view
wsot Aug 18, 2022
91af556
Session 10 - text in search box
wsot Aug 18, 2022
a3cb85e
Session 10 - you searched for text
wsot Aug 18, 2022
4a80446
Session 10 - you searched for text in CBV
wsot Aug 18, 2022
67997f4
Session 10 - Django form
wsot Aug 18, 2022
81a9b9d
Show message if no results
wsot Aug 22, 2022
a6e9a78
Handle search from any page
wsot Aug 22, 2022
3e0dd80
Add get_object_or_404
wsot Aug 22, 2022
528f096
Add basic form
wsot Aug 22, 2022
c77a180
Add list of choices with country code and country name
wsot Aug 25, 2022
fd2cbcd
Add list of choices with just country name
wsot Aug 25, 2022
8f29b25
Use 'TextChoices' for countries
wsot Aug 25, 2022
9fdd85c
Change form to use UL
wsot Aug 25, 2022
a0d9e2a
Add ChoicesField
wsot Aug 25, 2022
f0363b9
Switch to using ModelForm
wsot Aug 25, 2022
cc42faf
Use instance feature of ModelForm
wsot Aug 25, 2022
541e9da
Add PersonUpdateView
wsot Aug 29, 2022
9baad9d
Add basic check_my_auth view
wsot Aug 29, 2022
893fbf4
Login
wsot Aug 29, 2022
793cdb5
Add permission check
wsot Aug 31, 2022
9790b0b
Edit only own profile
wsot Aug 31, 2022
427150e
Handle multiple users for profile
wsot Aug 31, 2022
37a1e42
Initial advanced search
wsot Sep 5, 2022
c1d173f
Template list include
wsot Sep 5, 2022
fdd9d6a
Template include custom text
wsot Sep 5, 2022
8103367
Template include custom text 2
wsot Sep 5, 2022
1df30a5
Choices but no blank option
wsot Sep 5, 2022
a768e06
Choices with blank option
wsot Sep 5, 2022
e84a1f4
Add sorting
wsot Sep 5, 2022
fc31b67
Only show results when search performed
wsot Sep 5, 2022
8b3aa56
add migration
wsot Sep 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/community_db/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
from django.contrib import admin

# Register your models here.
from .models import Person


class PersonAdmin(admin.ModelAdmin):
list_display = (
"first_name",
"last_name",
)


admin.site.register(Person, PersonAdmin)
29 changes: 29 additions & 0 deletions src/community_db/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django import forms

from .models import Person


class QuickSearchForm(forms.Form):
search = forms.CharField(max_length=100, required=False)


class PersonForm(forms.ModelForm):
class Meta:
model = Person
fields = ["first_name", "last_name", "country", "mobile_number"]


class PersonSearchForm(forms.Form):
COUNTRIES = [("", "")] + list(Person.Countries.choices)
SORT_BY_OPTIONS = [
("last_name", "Last Name"),
("first_name", "First Name"),
("country", "Country"),
("mobile_number", "Mobile Number"),
]

first_name = forms.CharField(max_length=100, required=False)
last_name = forms.CharField(max_length=100, required=False)
country = forms.ChoiceField(required=False, choices=COUNTRIES)
mobile_number = forms.CharField(max_length=20, required=False)
sort_by = forms.ChoiceField(choices=SORT_BY_OPTIONS, required=False)
Original file line number Diff line number Diff line change
@@ -0,0 +1,337 @@
# Generated by Django 4.1 on 2022-08-25 02:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("community_db", "0001_initial"),
]

operations = [
migrations.AlterField(
model_name="person",
name="country",
field=models.CharField(
blank=True,
choices=[
("Afghanistan", "Afghanistan"),
("Albania", "Albania"),
("Algeria", "Algeria"),
("American Samoa", "American Samoa"),
("Andorra", "Andorra"),
("Angola", "Angola"),
("Anguilla", "Anguilla"),
("Antarctica", "Antarctica"),
("Antigua and Barbuda", "Antigua and Barbuda"),
("Argentina", "Argentina"),
("Armenia", "Armenia"),
("Aruba", "Aruba"),
("Australia", "Australia"),
("Austria", "Austria"),
("Azerbaijan", "Azerbaijan"),
("Bahamas (the)", "Bahamas (the)"),
("Bahrain", "Bahrain"),
("Bangladesh", "Bangladesh"),
("Barbados", "Barbados"),
("Belarus", "Belarus"),
("Belgium", "Belgium"),
("Belize", "Belize"),
("Benin", "Benin"),
("Bermuda", "Bermuda"),
("Bhutan", "Bhutan"),
(
"Bolivia (Plurinational State of)",
"Bolivia (Plurinational State of)",
),
(
"Bonaire, Sint Eustatius and Saba",
"Bonaire, Sint Eustatius and Saba",
),
("Bosnia and Herzegovina", "Bosnia and Herzegovina"),
("Botswana", "Botswana"),
("Bouvet Island", "Bouvet Island"),
("Brazil", "Brazil"),
(
"British Indian Ocean Territory (the)",
"British Indian Ocean Territory (the)",
),
("Brunei Darussalam", "Brunei Darussalam"),
("Bulgaria", "Bulgaria"),
("Burkina Faso", "Burkina Faso"),
("Burundi", "Burundi"),
("Cabo Verde", "Cabo Verde"),
("Cambodia", "Cambodia"),
("Cameroon", "Cameroon"),
("Canada", "Canada"),
("Cayman Islands (the)", "Cayman Islands (the)"),
(
"Central African Republic (the)",
"Central African Republic (the)",
),
("Chad", "Chad"),
("Chile", "Chile"),
("China", "China"),
("Christmas Island", "Christmas Island"),
("Cocos (Keeling) Islands (the)", "Cocos (Keeling) Islands (the)"),
("Colombia", "Colombia"),
("Comoros (the)", "Comoros (the)"),
(
"Congo (the Democratic Republic of the)",
"Congo (the Democratic Republic of the)",
),
("Congo (the)", "Congo (the)"),
("Cook Islands (the)", "Cook Islands (the)"),
("Costa Rica", "Costa Rica"),
("Croatia", "Croatia"),
("Cuba", "Cuba"),
("Curaçao", "Curaçao"),
("Cyprus", "Cyprus"),
("Czechia", "Czechia"),
("Côte d'Ivoire", "Côte d'Ivoire"),
("Denmark", "Denmark"),
("Djibouti", "Djibouti"),
("Dominica", "Dominica"),
("Dominican Republic (the)", "Dominican Republic (the)"),
("Ecuador", "Ecuador"),
("Egypt", "Egypt"),
("El Salvador", "El Salvador"),
("Equatorial Guinea", "Equatorial Guinea"),
("Eritrea", "Eritrea"),
("Estonia", "Estonia"),
("Eswatini", "Eswatini"),
("Ethiopia", "Ethiopia"),
(
"Falkland Islands (the) [Malvinas]",
"Falkland Islands (the) [Malvinas]",
),
("Faroe Islands (the)", "Faroe Islands (the)"),
("Fiji", "Fiji"),
("Finland", "Finland"),
("France", "France"),
("French Guiana", "French Guiana"),
("French Polynesia", "French Polynesia"),
(
"French Southern Territories (the)",
"French Southern Territories (the)",
),
("Gabon", "Gabon"),
("Gambia (the)", "Gambia (the)"),
("Georgia", "Georgia"),
("Germany", "Germany"),
("Ghana", "Ghana"),
("Gibraltar", "Gibraltar"),
("Greece", "Greece"),
("Greenland", "Greenland"),
("Grenada", "Grenada"),
("Guadeloupe", "Guadeloupe"),
("Guam", "Guam"),
("Guatemala", "Guatemala"),
("Guernsey", "Guernsey"),
("Guinea", "Guinea"),
("Guinea-Bissau", "Guinea-Bissau"),
("Guyana", "Guyana"),
("Haiti", "Haiti"),
(
"Heard Island and McDonald Islands",
"Heard Island and McDonald Islands",
),
("Holy See (the)", "Holy See (the)"),
("Honduras", "Honduras"),
("Hong Kong", "Hong Kong"),
("Hungary", "Hungary"),
("Iceland", "Iceland"),
("India", "India"),
("Indonesia", "Indonesia"),
("Iran (Islamic Republic of)", "Iran (Islamic Republic of)"),
("Iraq", "Iraq"),
("Ireland", "Ireland"),
("Isle of Man", "Isle of Man"),
("Israel", "Israel"),
("Italy", "Italy"),
("Jamaica", "Jamaica"),
("Japan", "Japan"),
("Jersey", "Jersey"),
("Jordan", "Jordan"),
("Kazakhstan", "Kazakhstan"),
("Kenya", "Kenya"),
("Kiribati", "Kiribati"),
(
"Korea (the Democratic People's Republic of)",
"Korea (the Democratic People's Republic of)",
),
("Korea (the Republic of)", "Korea (the Republic of)"),
("Kuwait", "Kuwait"),
("Kyrgyzstan", "Kyrgyzstan"),
(
"Lao People's Democratic Republic (the)",
"Lao People's Democratic Republic (the)",
),
("Latvia", "Latvia"),
("Lebanon", "Lebanon"),
("Lesotho", "Lesotho"),
("Liberia", "Liberia"),
("Libya", "Libya"),
("Liechtenstein", "Liechtenstein"),
("Lithuania", "Lithuania"),
("Luxembourg", "Luxembourg"),
("Macao", "Macao"),
("Madagascar", "Madagascar"),
("Malawi", "Malawi"),
("Malaysia", "Malaysia"),
("Maldives", "Maldives"),
("Mali", "Mali"),
("Malta", "Malta"),
("Marshall Islands (the)", "Marshall Islands (the)"),
("Martinique", "Martinique"),
("Mauritania", "Mauritania"),
("Mauritius", "Mauritius"),
("Mayotte", "Mayotte"),
("Mexico", "Mexico"),
(
"Micronesia (Federated States of)",
"Micronesia (Federated States of)",
),
("Moldova (the Republic of)", "Moldova (the Republic of)"),
("Monaco", "Monaco"),
("Mongolia", "Mongolia"),
("Montenegro", "Montenegro"),
("Montserrat", "Montserrat"),
("Morocco", "Morocco"),
("Mozambique", "Mozambique"),
("Myanmar", "Myanmar"),
("Namibia", "Namibia"),
("Nauru", "Nauru"),
("Nepal", "Nepal"),
("Netherlands (the)", "Netherlands (the)"),
("New Caledonia", "New Caledonia"),
("New Zealand", "New Zealand"),
("Nicaragua", "Nicaragua"),
("Niger (the)", "Niger (the)"),
("Nigeria", "Nigeria"),
("Niue", "Niue"),
("Norfolk Island", "Norfolk Island"),
(
"Northern Mariana Islands (the)",
"Northern Mariana Islands (the)",
),
("Norway", "Norway"),
("Oman", "Oman"),
("Pakistan", "Pakistan"),
("Palau", "Palau"),
("Palestine, State of", "Palestine, State of"),
("Panama", "Panama"),
("Papua New Guinea", "Papua New Guinea"),
("Paraguay", "Paraguay"),
("Peru", "Peru"),
("Philippines (the)", "Philippines (the)"),
("Pitcairn", "Pitcairn"),
("Poland", "Poland"),
("Portugal", "Portugal"),
("Puerto Rico", "Puerto Rico"),
("Qatar", "Qatar"),
("Republic of North Macedonia", "Republic of North Macedonia"),
("Romania", "Romania"),
("Russian Federation (the)", "Russian Federation (the)"),
("Rwanda", "Rwanda"),
("Réunion", "Réunion"),
("Saint Barthélemy", "Saint Barthélemy"),
(
"Saint Helena, Ascension and Tristan da Cunha",
"Saint Helena, Ascension and Tristan da Cunha",
),
("Saint Kitts and Nevis", "Saint Kitts and Nevis"),
("Saint Lucia", "Saint Lucia"),
("Saint Martin (French part)", "Saint Martin (French part)"),
("Saint Pierre and Miquelon", "Saint Pierre and Miquelon"),
(
"Saint Vincent and the Grenadines",
"Saint Vincent and the Grenadines",
),
("Samoa", "Samoa"),
("San Marino", "San Marino"),
("Sao Tome and Principe", "Sao Tome and Principe"),
("Saudi Arabia", "Saudi Arabia"),
("Senegal", "Senegal"),
("Serbia", "Serbia"),
("Seychelles", "Seychelles"),
("Sierra Leone", "Sierra Leone"),
("Singapore", "Singapore"),
("Sint Maarten (Dutch part)", "Sint Maarten (Dutch part)"),
("Slovakia", "Slovakia"),
("Slovenia", "Slovenia"),
("Solomon Islands", "Solomon Islands"),
("Somalia", "Somalia"),
("South Africa", "South Africa"),
(
"South Georgia and the South Sandwich Islands",
"South Georgia and the South Sandwich Islands",
),
("South Sudan", "South Sudan"),
("Spain", "Spain"),
("Sri Lanka", "Sri Lanka"),
("Sudan (the)", "Sudan (the)"),
("Suriname", "Suriname"),
("Svalbard and Jan Mayen", "Svalbard and Jan Mayen"),
("Sweden", "Sweden"),
("Switzerland", "Switzerland"),
("Syrian Arab Republic", "Syrian Arab Republic"),
("Taiwan (Province of China)", "Taiwan (Province of China)"),
("Tajikistan", "Tajikistan"),
("Tanzania, United Republic of", "Tanzania, United Republic of"),
("Thailand", "Thailand"),
("Timor-Leste", "Timor-Leste"),
("Togo", "Togo"),
("Tokelau", "Tokelau"),
("Tonga", "Tonga"),
("Trinidad and Tobago", "Trinidad and Tobago"),
("Tunisia", "Tunisia"),
("Turkey", "Turkey"),
("Turkmenistan", "Turkmenistan"),
(
"Turks and Caicos Islands (the)",
"Turks and Caicos Islands (the)",
),
("Tuvalu", "Tuvalu"),
("Uganda", "Uganda"),
("Ukraine", "Ukraine"),
("United Arab Emirates (the)", "United Arab Emirates (the)"),
(
"United Kingdom of Great Britain and Northern Ireland (the)",
"United Kingdom of Great Britain and Northern Ireland (the)",
),
(
"United States Minor Outlying Islands (the)",
"United States Minor Outlying Islands (the)",
),
(
"United States of America (the)",
"United States of America (the)",
),
("Uruguay", "Uruguay"),
("Uzbekistan", "Uzbekistan"),
("Vanuatu", "Vanuatu"),
(
"Venezuela (Bolivarian Republic of)",
"Venezuela (Bolivarian Republic of)",
),
("Viet Nam", "Viet Nam"),
("Virgin Islands (British)", "Virgin Islands (British)"),
("Virgin Islands (U.S.)", "Virgin Islands (U.S.)"),
("Wallis and Futuna", "Wallis and Futuna"),
("Western Sahara", "Western Sahara"),
("Yemen", "Yemen"),
("Zambia", "Zambia"),
("Zimbabwe", "Zimbabwe"),
("Åland Islands", "Åland Islands"),
],
max_length=100,
),
),
migrations.AlterField(
model_name="person",
name="last_name",
field=models.CharField(max_length=100),
),
]
Loading