Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/7 location admin #17

Merged
merged 4 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/open_producten/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"open_producten.utils",
"open_producten.producttypes",
"open_producten.products",
"open_producten.locations",
]

#
Expand Down
Empty file.
11 changes: 11 additions & 0 deletions src/open_producten/locations/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from .contact import ContactAdmin
from .location import LocationAdmin
from .organisation import NeighbourhoodAmin, OrganisationAdmin, OrganisationTypeAdmin

__all__ = [
"ContactAdmin",
"LocationAdmin",
"OrganisationAdmin",
"OrganisationTypeAdmin",
"NeighbourhoodAmin",
]
13 changes: 13 additions & 0 deletions src/open_producten/locations/admin/contact.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.contrib import admin

from ..models import Contact


@admin.register(Contact)
Floris272 marked this conversation as resolved.
Show resolved Hide resolved
class ContactAdmin(admin.ModelAdmin):
list_display = ("organisation", "last_name", "first_name")
list_filter = ("organisation",)
search_fields = ("first_name", "last_name")

def get_queryset(self, request):
return super().get_queryset(request).select_related("organisation")
10 changes: 10 additions & 0 deletions src/open_producten/locations/admin/location.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.contrib import admin

from ..models import Location


@admin.register(Location)
class LocationAdmin(admin.ModelAdmin):
list_display = ("name", "city", "postcode", "street", "house_number")
list_filter = ("city",)
search_fields = ("name", "city")
37 changes: 37 additions & 0 deletions src/open_producten/locations/admin/organisation.py
Floris272 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
from django.contrib import admin
from django.utils.translation import gettext_lazy as _

from ..models import Neighbourhood, Organisation, OrganisationType


@admin.register(Organisation)
class OrganisationAdmin(admin.ModelAdmin):
list_display = ("name", "type")
list_filter = ("type__name", "city")
search_fields = ("name",)
ordering = ("name",)

fieldsets = (
(
None,
{"fields": ("name", "type", "logo", "neighbourhood")},
),
(_("Contact"), {"fields": ("email", "phone_number")}),
(
_("Address"),
{"fields": ("street", "house_number", "postcode", "city")},
),
)

def get_queryset(self, request):
return super().get_queryset(request).select_related("neighbourhood", "type")


@admin.register(OrganisationType)
class OrganisationTypeAdmin(admin.ModelAdmin):
list_display = ("name",)


@admin.register(Neighbourhood)
class NeighbourhoodAmin(admin.ModelAdmin):
list_display = ("name",)
6 changes: 6 additions & 0 deletions src/open_producten/locations/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class LocationsConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "open_producten.locations"
Loading
Loading