Browse Source

Add read-only serials views

main
squeaky otter 5 months ago
parent
commit
f1aa929701
Signed by: dashie GPG Key ID: C2D57B325840B755
  1. 2
      config/settings/common.py
  2. 0
      controllers/serial/__init__.py
  3. 110
      controllers/serial/admin.py
  4. 5
      controllers/serial/apps.py
  5. 0
      controllers/serial/migrations/__init__.py
  6. 3
      controllers/serial/models.py
  7. 3
      controllers/serial/tests.py
  8. 3
      controllers/serial/views.py

2
config/settings/common.py

@ -87,7 +87,7 @@ DJANGO_APPS = [
THIRD_PARTY_APPS = ["mptt", "imagekit", "django_admin_listfilter_dropdown", "django_extensions"]
LOCAL_APPS = ["controllers.users", "controllers.gear", "controllers.files"] # custom users app
LOCAL_APPS = ["controllers.users", "controllers.gear", "controllers.files", "controllers.serial"] # custom users app
# See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps

0
controllers/serial/__init__.py

110
controllers/serial/admin.py

@ -0,0 +1,110 @@
from django.contrib import admin
from config.admin import CommonAdmin
from controllers.gear.models import Camera, Lens, Accessory
class CameraSerialsAdmin(CommonAdmin):
"""
Create a pseudo-readonly view for Camera Serials
"""
list_display = ("camera_model", "state", "serial")
search_fields = ("name", "state_notes", "model_notes", "description")
def camera_model(self, obj):
return obj.__str__()
list_filter = ("manufacturer", "mount", "film_type", "can_be_sold")
def get_actions(self, request):
actions = super().get_actions(request)
if "delete_selected" in actions:
del actions["delete_selected"]
return actions
def has_add_permission(self, request):
return False
def has_delete_permission(self, request, obj=None):
return False
def has_change_permission(self, request, obj=None):
return False
class LensSerialsAdmin(CommonAdmin):
"""
Create a pseudo-readonly view for Lens Serials
"""
list_display = ("camera_model", "state", "serial")
search_fields = ("name", "state_notes", "model_notes", "description")
def camera_model(self, obj):
return obj.__str__()
list_filter = ("manufacturer", "mount", "can_be_sold")
def get_actions(self, request):
actions = super().get_actions(request)
if "delete_selected" in actions:
del actions["delete_selected"]
return actions
def has_add_permission(self, request):
return False
def has_delete_permission(self, request, obj=None):
return False
def has_change_permission(self, request, obj=None):
return False
class AccessorySerialsAdmin(CommonAdmin):
"""
Create a pseudo-readonly view for Accessory Serials
"""
list_display = ("camera_model", "state", "serial")
search_fields = ("name", "state_notes", "model_notes", "description")
def camera_model(self, obj):
return obj.__str__()
list_filter = ("manufacturer", "mount", "can_be_sold")
def get_actions(self, request):
actions = super().get_actions(request)
if "delete_selected" in actions:
del actions["delete_selected"]
return actions
def has_add_permission(self, request):
return False
def has_delete_permission(self, request, obj=None):
return False
def has_change_permission(self, request, obj=None):
return False
class CameraSerial(Camera):
class Meta:
proxy = True
class LensSerial(Lens):
class Meta:
proxy = True
class AccessorySerial(Accessory):
class Meta:
proxy = True
admin.site.register(CameraSerial, CameraSerialsAdmin)
admin.site.register(LensSerial, LensSerialsAdmin)
admin.site.register(AccessorySerial, AccessorySerialsAdmin)

5
controllers/serial/apps.py

@ -0,0 +1,5 @@
from django.apps import AppConfig
class SerialConfig(AppConfig):
name = "serial"

0
controllers/serial/migrations/__init__.py

3
controllers/serial/models.py

@ -0,0 +1,3 @@
# from django.db import models
# Create your models here.

3
controllers/serial/tests.py

@ -0,0 +1,3 @@
# from django.test import TestCase
# Create your tests here.

3
controllers/serial/views.py

@ -0,0 +1,3 @@
# from django.shortcuts import render
# Create your views here.
Loading…
Cancel
Save