diff --git a/project/main/cat_breeds.py b/project/main/cat_breeds.py new file mode 100644 index 0000000..ddedc53 --- /dev/null +++ b/project/main/cat_breeds.py @@ -0,0 +1,686 @@ +from dataclasses import dataclass + + +@dataclass +class CatBreed: + name: str + country: str + origin: str + coat: str + pattern: str + + +cat_breeds = [ + CatBreed( + name="Abyssinian", + country="Ethiopia", + origin="Natural/Standard", + coat="Short", + pattern="Ticked", + ), + CatBreed( + name="Aegean", + country="Greece", + origin="Natural/Standard", + coat="Semi-long", + pattern="Bi- or tri-colored", + ), + CatBreed( + name="American Curl", + country="United States", + origin="Mutation", + coat="Short/Long", + pattern="All", + ), + CatBreed( + name="American Bobtail", + country="United States", + origin="Mutation", + coat="Short/Long", + pattern="All", + ), + CatBreed( + name="American Shorthair", + country="United States", + origin="Natural", + coat="Short", + pattern="All but colorpoint", + ), + CatBreed( + name="American Wirehair", + country="United States", + origin="Mutation", + coat="Rex", + pattern="All but colorpoint", + ), + CatBreed( + name="Arabian Mau", + country="Arabian Peninsula", + origin="Natural", + coat="Short", + pattern="", + ), + CatBreed( + name="Australian Mist", + country="Australia", + origin="Crossbreed", + coat="Short", + pattern="Spotted and Classic tabby", + ), + CatBreed( + name="Asian", + country="United Kingdom", + origin="", + coat="Short", + pattern="Evenly solid", + ), + CatBreed( + name="Asian Semi-longhair", + country="United Kingdom", + origin="Crossbreed", + coat="Semi-long", + pattern="Solid", + ), + CatBreed( + name="Balinese", + country="United States", + origin="Crossbreed", + coat="Long", + pattern="Colorpoint", + ), + CatBreed( + name="Bambino", + country="United States", + origin="Crossbreed", + coat="Hairless/Furry down", + pattern="", + ), + CatBreed( + name="Bengal", + country="United States", + origin="Hybrid", + coat="Short", + pattern="Spotted/Marbled", + ), + CatBreed( + name="Birman", + country="France", + origin="Natural", + coat="Semi Long", + pattern="Colorpoint", + ), + CatBreed( + name="Bombay", + country="United States", + origin="Crossbred", + coat="Short", + pattern="Solid", + ), + CatBreed( + name="Brazilian Shorthair", + country="Brazil", + origin="Natural", + coat="Short", + pattern="All", + ), + CatBreed( + name="British Semi-longhair", + country="United Kingdom", + origin="", + coat="Medium", + pattern="All", + ), + CatBreed( + name="British Shorthair", + country="United Kingdom", + origin="Natural", + coat="Short", + pattern="All", + ), + CatBreed( + name="British Longhair", + country="United Kingdom", + origin="", + coat="Long", + pattern="", + ), + CatBreed( + name="Burmese", + country="Burma and Thailand", + origin="Natural", + coat="Short", + pattern="Solid", + ), + CatBreed( + name="Burmilla", + country="United Kingdom", + origin="Crossbreed", + coat="Short/Long", + pattern="", + ), + CatBreed( + name="California Spangled", + country="United States", + origin="Crossbreed", + coat="Short", + pattern="Spotted", + ), + CatBreed( + name="Chantilly-Tiffany", + country="United States", + origin="", + coat="", + pattern="", + ), + CatBreed( + name="Chartreux", + country="France", + origin="Natural", + coat="Short", + pattern="Solid", + ), + CatBreed( + name="Chausie", + country="France", + origin="Hybrid", + coat="Short", + pattern="Ticked", + ), + CatBreed( + name="Cheetoh", + country="United States", + origin="Hybrid Crossbreed", + coat="Short", + pattern="Spotted", + ), + CatBreed( + name="Cornish Rex", + country="United Kingdom", + origin="Mutation", + coat="Rex", + pattern="All", + ), + CatBreed( + name="Cymric or Manx Longhair", + country="United Kingdom", + origin="Natural/Mutation", + coat="Long", + pattern="", + ), + CatBreed( + name="Cyprus", + country="Cyprus", + origin="Natural", + coat="All", + pattern="All", + ), + CatBreed( + name="Devon Rex", + country="United Kingdom", + origin="Mutation", + coat="Rex", + pattern="All", + ), + CatBreed( + name="Donskoy, or Don Sphynx", + country="Russia", + origin="", + coat="Hairless", + pattern="", + ), + CatBreed( + name="Dragon Li", + country="China", + origin="Natural", + coat="Short", + pattern="Striped tabby", + ), + CatBreed( + name="Dwarf cat, or Dwelf", + country="", + origin="Crossbreed", + coat="", + pattern="Hairless", + ), + CatBreed( + name="Egyptian Mau", + country="Egypt", + origin="Natural", + coat="Short", + pattern="Spotted", + ), + CatBreed( + name="European Shorthair", + country="Finland and Sweden", + origin="Natural", + coat="Short", + pattern="", + ), + CatBreed( + name="Exotic Shorthair", + country="United States", + origin="Crossbreed", + coat="Short", + pattern="All", + ), + CatBreed( + name="Foldex[4]", + country="Canada", + origin="Crossbreed", + coat="Short", + pattern="All", + ), + CatBreed( + name="German Rex", + country="East Germany", + origin="Mutation", + coat="Rex", + pattern="", + ), + CatBreed( + name="Havana Brown", + country="United Kingdom", + origin="", + coat="Short", + pattern="Solid", + ), + CatBreed( + name="Highlander", + country="United States", + origin="Crossbreed", + coat="Short/Long", + pattern="All", + ), + CatBreed( + name="Himalayan, or Colorpoint Persian", + country="United States/United Kingdom", + origin="Crossbreed", + coat="Long", + pattern="Colorpoint", + ), + CatBreed( + name="Japanese Bobtail", + country="Japan", + origin="Natural", + coat="Short/Long", + pattern="All but colorpoint and ticked", + ), + CatBreed( + name="Javanese", + country="United States", + origin="Crossbreed", + coat="Long/Short", + pattern="Colorpoint", + ), + CatBreed( + name="Karelian Bobtail", + country="Western Russia", + origin="Natural", + coat="", + pattern="", + ), + CatBreed( + name="Khao Manee", + country="Thailand", + origin="Natural", + coat="Short", + pattern="Solid", + ), + CatBreed( + name="Korat", + country="Thailand", + origin="Natural", + coat="Short", + pattern="Solid", + ), + CatBreed( + name="Korean Bobtail", + country="Korea", + origin="Natural", + coat="Short/Long", + pattern="Colorprint", + ), + CatBreed( + name="Korn Ja", + country="Thailand", + origin="Natural", + coat="Short/Hairless", + pattern="Solid", + ), + CatBreed( + name="Kurilian Bobtail, or Kuril Islands Bobtail", + country="Eastern Russia,Japan", + origin="Natural", + coat="Short/Long", + pattern="", + ), + CatBreed( + name="LaPerm", + country="United States", + origin="Mutation", + coat="Rex", + pattern="All", + ), + CatBreed( + name="Lykoi", + country="United States", + origin="Natural/Mutation", + coat="Partly Hairless", + pattern="Ticked", + ), + CatBreed( + name="Maine Coon", + country="United States", + origin="Natural", + coat="Long", + pattern="All but colorpoint and ticked", + ), + CatBreed( + name="Manx", + country="United Kingdom", + origin="Mutation", + coat="Short/Long", + pattern="All but colorpoint", + ), + CatBreed( + name="Mekong Bobtail", + country="Russia", + origin="Natural/Mutation", + coat="Short", + pattern="Colorpoint", + ), + CatBreed( + name="Minskin", + country="United States", + origin="Crossbreed", + coat="Short/Hairless", + pattern="All", + ), + CatBreed( + name="Munchkin", + country="United States", + origin="Mutation", + coat="", + pattern="", + ), + CatBreed( + name="Nebelung", + country="United States", + origin="", + coat="Semi-long", + pattern="Solid", + ), + CatBreed( + name="Napoleon", + country="", + origin="", + coat="Long/short", + pattern="Varied", + ), + CatBreed( + name="Norwegian Forest cat", + country="Norway", + origin="Natural", + coat="Long", + pattern="All but colorpoint", + ), + CatBreed( + name="Ocicat", + country="United States", + origin="Crossbreed", + coat="Short", + pattern="Spotted", + ), + CatBreed( + name="Ojos Azules", + country="United States", + origin="", + coat="", + pattern="", + ), + CatBreed( + name="Oregon Rex", + country="United States", + origin="Mutation", + coat="Rex", + pattern="", + ), + CatBreed( + name="Oriental Bicolor", + country="", + origin="", + coat="", + pattern="Bicolor", + ), + CatBreed( + name="Oriental Shorthair", + country="", + origin="", + coat="Short", + pattern="All but colorpoint", + ), + CatBreed( + name="Oriental Longhair", + country="", + origin="", + coat="Semi-long", + pattern="", + ), + CatBreed( + name="PerFoldæ(Experimental Breed - WCF),", + country="Europe", + origin="Crossbreed", + coat="Long", + pattern="All", + ), + CatBreed( + name="Persian (Modern Persian Cat),", + country="Iran (Persia),", + origin="Crossbreed", + coat="Long", + pattern="All", + ), + CatBreed( + name="Persian (Traditional Persian Cat),", + country="Greater Iran", + origin="Natural", + coat="Long", + pattern="All", + ), + CatBreed( + name="Peterbald", + country="Russia", + origin="Crossbreed", + coat="Hairless", + pattern="All", + ), + CatBreed( + name="Pixie-bob", + country="United States", + origin="Natural", + coat="Short", + pattern="Spotted", + ), + CatBreed( + name="Raas", + country="Indonesia", + origin="Natural", + coat="Short", + pattern="", + ), + CatBreed( + name="Ragamuffin", + country="United States", + origin="Crossbreed", + coat="Long", + pattern="All", + ), + CatBreed( + name="Ragdoll", + country="United States", + origin="Crossbreed", + coat="Long", + pattern="Colorpoint/Mitted/Bicolor", + ), + CatBreed( + name="Russian Blue", + country="Russia", + origin="Natural", + coat="Short", + pattern="Solid", + ), + CatBreed( + name="Russian White, Black and Tabby", + country="Australia", + origin="Crossbreed", + coat="Short", + pattern="", + ), + CatBreed( + name="Sam Sawet", + country="Thailand", + origin="Natural", + coat="Short", + pattern="Solid", + ), + CatBreed( + name="Savannah", + country="United States", + origin="Hybrid", + coat="Short", + pattern="Spotted", + ), + CatBreed( + name="Scottish Fold", + country="United Kingdom", + origin="Natural/Mutation", + coat="Short/Long", + pattern="All", + ), + CatBreed( + name="Selkirk Rex", + country="United States", + origin="Mutation/Cross", + coat="Rex (Short/Long),", + pattern="All", + ), + CatBreed( + name="Serengeti", + country="United States", + origin="Hybrid Crossbreed", + coat="Short", + pattern="Spotted", + ), + CatBreed( + name="Serrade petit", + country="France", + origin="Natural", + coat="Short", + pattern="", + ), + CatBreed( + name="Siamese", + country="Thailand", + origin="Natural", + coat="Short", + pattern="Colorpoint", + ), + CatBreed( + name="Siberian", + country="Russia", + origin="Natural", + coat="Semi-long", + pattern="All", + ), + CatBreed( + name="Singapura", + country="Singapore", + origin="Natural", + coat="Short", + pattern="Ticked", + ), + CatBreed( + name="Snowshoe", + country="United States", + origin="Crossbreed", + coat="Short", + pattern="Colorpoint", + ), + CatBreed( + name="Sokoke", + country="Kenya", + origin="Natural", + coat="Short", + pattern="Classic tabby with ticking", + ), + CatBreed( + name="Somali", + country="Somalia", + origin="Mutation", + coat="Long", + pattern="Ticked", + ), + CatBreed( + name="Sphynx", + country="Canada", + origin="Mutation", + coat="Hairless", + pattern="All", + ), + CatBreed( + name="Suphalak", + country="Thailand", + origin="Natural", + coat="Short", + pattern="Solid", + ), + CatBreed( + name="Thai", + country="Thailand", + origin="Natural", + coat="Short", + pattern="Colorpoint", + ), + CatBreed( + name="Thai Lilac", + country="Thailand", + origin="Natural", + coat="Short", + pattern="Solid", + ), + CatBreed( + name="Tonkinese", + country="Canada", + origin="Crossbreed", + coat="Short", + pattern="Colorpoint/Mink/Solid", + ), + CatBreed( + name="Toyger", + country="United States", + origin="Crossbreed", + coat="Short", + pattern="Mackerel", + ), + CatBreed( + name="Turkish Angora", + country="Turkey", + origin="Natural", + coat="Semi-long", + pattern="All but colorpoint", + ), + CatBreed( + name="Ukrainian Levkoy", + country="Ukraine", + origin="", + coat="Hairless", + pattern="", + ), + CatBreed( + name="York Chocolate", + country="United States", + origin="Natural", + coat="Long", + pattern="Solid", + ), +] diff --git a/project/main/templates/main/filter_list.html b/project/main/templates/main/filter_list.html index 5eccfae..3ee9bcb 100644 --- a/project/main/templates/main/filter_list.html +++ b/project/main/templates/main/filter_list.html @@ -3,5 +3,52 @@ {% block content %} - {{ js_alert_work_in_progress() }} + +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ + + {% include "main/filter_list_content.html" %} {% endblock %} diff --git a/project/main/templates/main/filter_list_content.html b/project/main/templates/main/filter_list_content.html new file mode 100644 index 0000000..702625c --- /dev/null +++ b/project/main/templates/main/filter_list_content.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + {% for breed in cat_breeds %} + + + + + + + + {% endfor %} + +
BreedCountryOriginCoatPattern
{{ breed.name }}{{ breed.country }}{{ breed.origin }}{{ breed.coat }}{{ breed.pattern }}
diff --git a/project/main/views/__init__.py b/project/main/views/__init__.py index ba8d607..a75755b 100644 --- a/project/main/views/__init__.py +++ b/project/main/views/__init__.py @@ -4,7 +4,7 @@ from .complex_form.views import ( RouteModuleHandleView, WarehouseManagementHandleView, ) -from .filter_list import FilterListView +from .filter_list import FilterListFilterView, FilterListView from .form_validation import FormValidationView from .home import HomeView from .swap import SwapView diff --git a/project/main/views/filter_list.py b/project/main/views/filter_list.py index 831c811..765e17e 100644 --- a/project/main/views/filter_list.py +++ b/project/main/views/filter_list.py @@ -1,7 +1,61 @@ +from typing import Any, Optional + +from project.main.cat_breeds import CatBreed, cat_breeds from project.main.views.demo_view_base import DemoViewBase +def get_countries() -> list[str]: + return sorted(set([c.country for c in cat_breeds if len(c.country)])) + + +def filter_cat_breeds( + breed_filter: Optional[str] = None, country_filter: Optional[str] = None +) -> list[CatBreed]: + if not breed_filter and not country_filter: + return cat_breeds + + result = [] + for breed in cat_breeds: + # if (not breed_filter or breed_filter.lower() in breed.name.lower()) or ( + # not country_filter or country_filter == breed.country + # ): + if not breed_filter or breed_filter.lower() in breed.name.lower(): + result.append(breed) + return result + + class FilterListView(DemoViewBase): template_name = "main/filter_list.html" active_section = "filter-list" title = "Filter List" + + def get_context_data(self, **kwargs) -> dict[str, Any]: + context_data = super().get_context_data(**kwargs) + + context_data.update( + { + "cat_breeds": filter_cat_breeds(), + "countries": get_countries(), + } + ) + return context_data + + +class FilterListFilterView(DemoViewBase): + template_name = "main/filter_list_content.html" + + def get_context_data(self, **kwargs) -> dict[str, Any]: + context_data = super().get_context_data(**kwargs) + + cat_breeds = filter_cat_breeds( + breed_filter=self.request.GET.get("breed"), + country_filter=self.request.GET.get("country"), + ) + + context_data.update( + { + "cat_breeds": cat_breeds, + "countries": get_countries(), + } + ) + return context_data diff --git a/project/urls.py b/project/urls.py index 1d65a46..10f49bc 100644 --- a/project/urls.py +++ b/project/urls.py @@ -6,6 +6,7 @@ urlpatterns = [ path("", views.HomeView.as_view(), name="home"), path("swap", views.SwapView.as_view(), name="swap"), path("filter-list", views.FilterListView.as_view(), name="filter-list"), + path("filter-list-filter", views.FilterListFilterView.as_view(), name="filter-list-filter"), path("form-validation", views.FormValidationView.as_view(), name="form-validation"), path("complex-form", views.ComplexFormView.as_view(), name="complex-form"), path("complex-form/handle/route-module", views.RouteModuleHandleView.as_view(), name="complex-form-handle-route-module"),