Compare commits
No commits in common. "de3f96d4a81733e40afd975eb32de04f3ef3a4b7" and "c4c36d27a2fdf1c1a893d6c24ccd1733eb20e517" have entirely different histories.
de3f96d4a8
...
c4c36d27a2
@ -12,9 +12,5 @@ class APITokenAdmin(admin.ModelAdmin):
|
|||||||
readonly_fields = [
|
readonly_fields = [
|
||||||
"token"
|
"token"
|
||||||
]
|
]
|
||||||
search_fields = [
|
|
||||||
"token"
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(APIUserToken, APITokenAdmin)
|
admin.site.register(APIUserToken, APITokenAdmin)
|
||||||
|
@ -35,13 +35,6 @@ class KonovaCodeAdmin(admin.ModelAdmin):
|
|||||||
"parent",
|
"parent",
|
||||||
]
|
]
|
||||||
|
|
||||||
search_fields = [
|
|
||||||
"id",
|
|
||||||
"atom_id",
|
|
||||||
"long_name",
|
|
||||||
"short_name",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
#admin.site.register(KonovaCodeList, KonovaCodeListAdmin)
|
#admin.site.register(KonovaCodeList, KonovaCodeListAdmin)
|
||||||
admin.site.register(KonovaCode, KonovaCodeAdmin)
|
admin.site.register(KonovaCode, KonovaCodeAdmin)
|
||||||
|
@ -2,100 +2,7 @@ from django.contrib import admin
|
|||||||
|
|
||||||
from compensation.models import Compensation, CompensationAction, CompensationState, Payment, \
|
from compensation.models import Compensation, CompensationAction, CompensationState, Payment, \
|
||||||
EcoAccountDeduction, EcoAccount
|
EcoAccountDeduction, EcoAccount
|
||||||
from konova.admin import BaseObjectAdmin, BaseResourceAdmin
|
from konova.admin import BaseObjectAdmin
|
||||||
|
|
||||||
|
|
||||||
class AbstractCompensationAdmin(BaseObjectAdmin):
|
|
||||||
list_display = [
|
|
||||||
"id",
|
|
||||||
"identifier",
|
|
||||||
"title",
|
|
||||||
"created",
|
|
||||||
"deleted",
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_fields(self, request, obj=None):
|
|
||||||
return super().get_fields(request, obj) + [
|
|
||||||
"identifier",
|
|
||||||
"title",
|
|
||||||
"comment",
|
|
||||||
"after_states",
|
|
||||||
"before_states",
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_readonly_fields(self, request, obj=None):
|
|
||||||
return super().get_readonly_fields(request, obj) + [
|
|
||||||
"after_states",
|
|
||||||
"before_states",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class CompensationAdmin(AbstractCompensationAdmin):
|
|
||||||
autocomplete_fields = [
|
|
||||||
"intervention",
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_fields(self, request, obj=None):
|
|
||||||
return super().get_fields(request, obj) + [
|
|
||||||
"is_cef",
|
|
||||||
"is_coherence_keeping",
|
|
||||||
"intervention",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class EcoAccountAdmin(AbstractCompensationAdmin):
|
|
||||||
list_display = [
|
|
||||||
"id",
|
|
||||||
"identifier",
|
|
||||||
"title",
|
|
||||||
"created",
|
|
||||||
"deleted",
|
|
||||||
]
|
|
||||||
|
|
||||||
filter_horizontal = [
|
|
||||||
"users"
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_fields(self, request, obj=None):
|
|
||||||
return super().get_fields(request, obj) + [
|
|
||||||
"deductable_surface",
|
|
||||||
"users"
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class PaymentAdmin(admin.ModelAdmin):
|
|
||||||
list_display = [
|
|
||||||
"id",
|
|
||||||
"amount",
|
|
||||||
"due_on",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class EcoAccountDeductionAdmin(BaseResourceAdmin):
|
|
||||||
list_display = [
|
|
||||||
"id",
|
|
||||||
"account",
|
|
||||||
"intervention",
|
|
||||||
"surface",
|
|
||||||
]
|
|
||||||
search_fields = [
|
|
||||||
"account__identifier",
|
|
||||||
"account__title",
|
|
||||||
"intervention__identifier",
|
|
||||||
"intervention__title",
|
|
||||||
"surface",
|
|
||||||
]
|
|
||||||
autocomplete_fields = [
|
|
||||||
"account",
|
|
||||||
"intervention",
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_fields(self, request, obj=None):
|
|
||||||
return super().get_fields(request, obj) + [
|
|
||||||
"account",
|
|
||||||
"intervention",
|
|
||||||
"surface",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class CompensationStateAdmin(admin.ModelAdmin):
|
class CompensationStateAdmin(admin.ModelAdmin):
|
||||||
@ -116,11 +23,44 @@ class CompensationActionAdmin(admin.ModelAdmin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class CompensationAdmin(BaseObjectAdmin):
|
||||||
|
list_display = [
|
||||||
|
"id",
|
||||||
|
"identifier",
|
||||||
|
"title",
|
||||||
|
"created",
|
||||||
|
"deleted",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class EcoAccountAdmin(admin.ModelAdmin):
|
||||||
|
list_display = [
|
||||||
|
"id",
|
||||||
|
"identifier",
|
||||||
|
"title",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class PaymentAdmin(admin.ModelAdmin):
|
||||||
|
list_display = [
|
||||||
|
"id",
|
||||||
|
"amount",
|
||||||
|
"due_on",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class EcoAccountDeductionAdmin(admin.ModelAdmin):
|
||||||
|
list_display = [
|
||||||
|
"id",
|
||||||
|
"account",
|
||||||
|
"intervention",
|
||||||
|
"surface",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Compensation, CompensationAdmin)
|
admin.site.register(Compensation, CompensationAdmin)
|
||||||
|
admin.site.register(Payment, PaymentAdmin)
|
||||||
|
admin.site.register(CompensationAction, CompensationActionAdmin)
|
||||||
|
admin.site.register(CompensationState, CompensationStateAdmin)
|
||||||
admin.site.register(EcoAccount, EcoAccountAdmin)
|
admin.site.register(EcoAccount, EcoAccountAdmin)
|
||||||
admin.site.register(EcoAccountDeduction, EcoAccountDeductionAdmin)
|
admin.site.register(EcoAccountDeduction, EcoAccountDeductionAdmin)
|
||||||
|
|
||||||
# For a more cleaner admin interface these rarely used admin views are not important for deployment
|
|
||||||
#admin.site.register(Payment, PaymentAdmin)
|
|
||||||
#admin.site.register(CompensationAction, CompensationActionAdmin)
|
|
||||||
#admin.site.register(CompensationState, CompensationStateAdmin)
|
|
@ -59,7 +59,7 @@ class CompensationAction(BaseResource):
|
|||||||
objects = CompensationActionManager()
|
objects = CompensationActionManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.action_type} | {self.amount} {self.unit}"
|
return "{} | {} {}".format(self.action_type, self.amount, self.unit)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_humanize(self):
|
def unit_humanize(self):
|
||||||
|
@ -46,7 +46,7 @@ class EcoAccount(AbstractCompensation, ShareableObjectMixin, RecordableObjectMix
|
|||||||
objects = EcoAccountManager()
|
objects = EcoAccountManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.identifier} ({self.title})"
|
return "{}".format(self.identifier)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
# Deductable surface can not be larger than added states after surface
|
# Deductable surface can not be larger than added states after surface
|
||||||
|
@ -44,4 +44,4 @@ class CompensationState(UuidModel):
|
|||||||
objects = CompensationStateManager()
|
objects = CompensationStateManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.biotope_type} | {self.surface} m²"
|
return "{} | {} m²".format(self.biotope_type, self.surface)
|
||||||
|
13
ema/admin.py
13
ema/admin.py
@ -1,17 +1,10 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from compensation.admin import AbstractCompensationAdmin
|
from compensation.admin import CompensationAdmin
|
||||||
from ema.models import Ema
|
from ema.models import Ema
|
||||||
|
|
||||||
|
|
||||||
class EmaAdmin(AbstractCompensationAdmin):
|
class EmaAdmin(CompensationAdmin):
|
||||||
filter_horizontal = [
|
pass
|
||||||
"users"
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_fields(self, request, obj=None):
|
|
||||||
return super().get_fields(request, obj) + [
|
|
||||||
"users"
|
|
||||||
]
|
|
||||||
|
|
||||||
admin.site.register(Ema, EmaAdmin)
|
admin.site.register(Ema, EmaAdmin)
|
||||||
|
@ -13,26 +13,6 @@ class InterventionAdmin(BaseObjectAdmin):
|
|||||||
"deleted",
|
"deleted",
|
||||||
]
|
]
|
||||||
|
|
||||||
filter_horizontal = [
|
|
||||||
"users"
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_fields(self, request, obj=None):
|
|
||||||
return super().get_fields(request, obj) + [
|
|
||||||
"identifier",
|
|
||||||
"title",
|
|
||||||
"comment",
|
|
||||||
"checked",
|
|
||||||
"recorded",
|
|
||||||
"users",
|
|
||||||
]
|
|
||||||
|
|
||||||
def get_readonly_fields(self, request, obj=None):
|
|
||||||
return super().get_readonly_fields(request, obj) + [
|
|
||||||
"checked",
|
|
||||||
"recorded",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class InterventionDocumentAdmin(AbstractDocumentAdmin):
|
class InterventionDocumentAdmin(AbstractDocumentAdmin):
|
||||||
pass
|
pass
|
||||||
@ -68,9 +48,7 @@ class RevocationAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
|
|
||||||
admin.site.register(Intervention, InterventionAdmin)
|
admin.site.register(Intervention, InterventionAdmin)
|
||||||
|
admin.site.register(Responsibility, ResponsibilityAdmin)
|
||||||
# Outcommented for a cleaner admin backend on production
|
admin.site.register(Legal, LegalAdmin)
|
||||||
#admin.site.register(Responsibility, ResponsibilityAdmin)
|
admin.site.register(Revocation, RevocationAdmin)
|
||||||
#admin.site.register(Legal, LegalAdmin)
|
admin.site.register(InterventionDocument, InterventionDocumentAdmin)
|
||||||
#admin.site.register(Revocation, RevocationAdmin)
|
|
||||||
#admin.site.register(InterventionDocument, InterventionDocumentAdmin)
|
|
||||||
|
@ -51,7 +51,7 @@ class Intervention(BaseObject, ShareableObjectMixin, RecordableObjectMixin, Chec
|
|||||||
objects = InterventionManager()
|
objects = InterventionManager()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.identifier} ({self.title})"
|
return "{} ({})".format(self.identifier, self.title)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
""" Custom save functionality
|
""" Custom save functionality
|
||||||
|
@ -62,35 +62,16 @@ class DeadlineAdmin(admin.ModelAdmin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class BaseResourceAdmin(admin.ModelAdmin):
|
class BaseObjectAdmin(admin.ModelAdmin):
|
||||||
fields = [
|
|
||||||
"created",
|
|
||||||
"modified",
|
|
||||||
]
|
|
||||||
readonly_fields = [
|
readonly_fields = [
|
||||||
"modified",
|
"modified",
|
||||||
|
"deleted",
|
||||||
"created",
|
"created",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class BaseObjectAdmin(BaseResourceAdmin):
|
admin.site.register(Geometry, GeometryAdmin)
|
||||||
search_fields = [
|
admin.site.register(Parcel, ParcelAdmin)
|
||||||
"identifier",
|
admin.site.register(District, DistrictAdmin)
|
||||||
"title",
|
admin.site.register(GeometryConflict, GeometryConflictAdmin)
|
||||||
]
|
admin.site.register(Deadline, DeadlineAdmin)
|
||||||
|
|
||||||
def get_fields(self, request, obj=None):
|
|
||||||
return super().get_fields(request, obj) + ["deleted"]
|
|
||||||
|
|
||||||
def get_readonly_fields(self, request, obj=None):
|
|
||||||
return super().get_readonly_fields(request, obj) + [
|
|
||||||
"deleted",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# Outcommented for a cleaner admin backend on production
|
|
||||||
#admin.site.register(Geometry, GeometryAdmin)
|
|
||||||
#admin.site.register(Parcel, ParcelAdmin)
|
|
||||||
#admin.site.register(District, DistrictAdmin)
|
|
||||||
#admin.site.register(GeometryConflict, GeometryConflictAdmin)
|
|
||||||
#admin.site.register(Deadline, DeadlineAdmin)
|
|
||||||
|
@ -4,23 +4,11 @@ from news.models import ServerMessage
|
|||||||
|
|
||||||
|
|
||||||
class ServerMessageAdmin(admin.ModelAdmin):
|
class ServerMessageAdmin(admin.ModelAdmin):
|
||||||
readonly_fields = [
|
|
||||||
"modified",
|
|
||||||
"created",
|
|
||||||
]
|
|
||||||
list_display = [
|
list_display = [
|
||||||
"id",
|
"id",
|
||||||
"subject",
|
"subject",
|
||||||
"publish_on",
|
"publish_on",
|
||||||
"is_active",
|
"is_active",
|
||||||
]
|
]
|
||||||
search_fields = [
|
|
||||||
"subject"
|
|
||||||
]
|
|
||||||
|
|
||||||
def save_model(self, request, obj, form, change):
|
|
||||||
obj.save(user=request.user)
|
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(ServerMessage, ServerMessageAdmin)
|
admin.site.register(ServerMessage, ServerMessageAdmin)
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ from django.db import models
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from konova.models import BaseResource
|
from konova.models import BaseResource
|
||||||
from user.models import UserActionLogEntry
|
|
||||||
|
|
||||||
|
|
||||||
class ServerMessageImportance(models.TextChoices):
|
class ServerMessageImportance(models.TextChoices):
|
||||||
@ -24,13 +23,3 @@ class ServerMessage(BaseResource):
|
|||||||
publish_on = models.DateTimeField()
|
publish_on = models.DateTimeField()
|
||||||
unpublish_on = models.DateTimeField()
|
unpublish_on = models.DateTimeField()
|
||||||
importance = models.CharField(max_length=100, choices=ServerMessageImportance.choices)
|
importance = models.CharField(max_length=100, choices=ServerMessageImportance.choices)
|
||||||
|
|
||||||
def save(self, user=None, *args, **kwargs):
|
|
||||||
user = kwargs.pop("user", None)
|
|
||||||
if user is not None:
|
|
||||||
if self.created is None:
|
|
||||||
self.created = UserActionLogEntry.get_created_action(user)
|
|
||||||
else:
|
|
||||||
self.modified = UserActionLogEntry.get_edited_action(user)
|
|
||||||
|
|
||||||
super().save(*args, **kwargs)
|
|
||||||
|
@ -19,40 +19,6 @@ class UserAdmin(admin.ModelAdmin):
|
|||||||
"last_name",
|
"last_name",
|
||||||
"email",
|
"email",
|
||||||
]
|
]
|
||||||
fields = [
|
|
||||||
"username",
|
|
||||||
"first_name",
|
|
||||||
"last_name",
|
|
||||||
"email",
|
|
||||||
"is_active",
|
|
||||||
"is_staff",
|
|
||||||
"is_superuser",
|
|
||||||
"api_token",
|
|
||||||
"groups",
|
|
||||||
"notifications",
|
|
||||||
"date_joined",
|
|
||||||
"last_login",
|
|
||||||
]
|
|
||||||
search_fields = [
|
|
||||||
"username",
|
|
||||||
"first_name",
|
|
||||||
"last_name",
|
|
||||||
"email",
|
|
||||||
]
|
|
||||||
filter_horizontal = [
|
|
||||||
"groups",
|
|
||||||
"notifications",
|
|
||||||
]
|
|
||||||
readonly_fields = [
|
|
||||||
"date_joined",
|
|
||||||
"last_login",
|
|
||||||
]
|
|
||||||
autocomplete_fields = [
|
|
||||||
"api_token",
|
|
||||||
]
|
|
||||||
exclude = [
|
|
||||||
"user_permissions",
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
class UserActionLogEntryAdmin(admin.ModelAdmin):
|
class UserActionLogEntryAdmin(admin.ModelAdmin):
|
||||||
@ -64,8 +30,6 @@ class UserActionLogEntryAdmin(admin.ModelAdmin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(UserNotification, UserNotificationAdmin)
|
||||||
|
admin.site.register(UserActionLogEntry, UserActionLogEntryAdmin)
|
||||||
admin.site.register(User, UserAdmin)
|
admin.site.register(User, UserAdmin)
|
||||||
|
|
||||||
# Outcommented for a cleaner admin backend on production
|
|
||||||
#admin.site.register(UserNotification, UserNotificationAdmin)
|
|
||||||
#admin.site.register(UserActionLogEntry, UserActionLogEntryAdmin)
|
|
||||||
|
@ -10,8 +10,6 @@ import uuid
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from konova.sub_settings.django_settings import DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT
|
|
||||||
|
|
||||||
|
|
||||||
class UserAction(models.TextChoices):
|
class UserAction(models.TextChoices):
|
||||||
"""
|
"""
|
||||||
@ -51,9 +49,6 @@ class UserActionLogEntry(models.Model):
|
|||||||
"-timestamp",
|
"-timestamp",
|
||||||
)
|
)
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return f"{self.timestamp.strftime(DEFAULT_DATE_TIME_FORMAT)} | {self.action} | {self.user}"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def action_humanize(self):
|
def action_humanize(self):
|
||||||
""" Returns humanized version of enum
|
""" Returns humanized version of enum
|
||||||
|
Loading…
Reference in New Issue
Block a user