* adds Ema model (basically Compensation inherited)
* adds index view for EMAs
* fixes drop-down link bug for menu 'More' in navbar
* refactors some more forms to use process_request()
* adds modified attribute to BaseResource for easy last_modified check
* adds setting of modified attribute in all places where UserAction.EDITED is added to log
* adds EMA_ACCOUNT_IDENTIFIER_LENGTH and EMA_ACCOUNT_IDENTIFIER_TEMPLATE to ema/settings.py
* adds EmaAdmin to ema/admin.py
* fixes wrong title in intervention detail view html for revocations
* adds support for subtitle variable to BaseTable and generic_index.html
* drops next_version attribute from models
* adds/updates translations
* adds default ordering for UserActionLogEntry
   * removes extra ordering in log modal rendering
This commit is contained in:
mipel
2021-08-19 13:02:31 +02:00
parent b2f3094214
commit 510d77422a
34 changed files with 675 additions and 315 deletions

View File

@@ -45,7 +45,6 @@ class BaseForm(forms.Form):
def __init__(self, *args, **kwargs):
self.instance = kwargs.pop("instance", None)
self.user = kwargs.pop("user", None)
self.request = kwargs.pop("request", None)
super().__init__(*args, **kwargs)
# Check for required fields
@@ -341,6 +340,8 @@ class NewDocumentForm(BaseModalForm):
comment=_("Added document"),
)
self.instance.log.add(edited_action)
self.instance.modified = edited_action
self.instance.save()
return doc

View File

@@ -16,6 +16,7 @@ from django.db import models, transaction
from compensation.settings import COMPENSATION_IDENTIFIER_TEMPLATE, COMPENSATION_IDENTIFIER_LENGTH, \
ECO_ACCOUNT_IDENTIFIER_TEMPLATE, ECO_ACCOUNT_IDENTIFIER_LENGTH
from ema.settings import EMA_ACCOUNT_IDENTIFIER_LENGTH, EMA_ACCOUNT_IDENTIFIER_TEMPLATE
from intervention.settings import INTERVENTION_IDENTIFIER_LENGTH, INTERVENTION_IDENTIFIER_TEMPLATE
from konova.utils.generators import generate_random_string
from user.models import UserActionLogEntry, UserAction
@@ -39,7 +40,21 @@ class BaseResource(UuidModel):
"""
A basic resource model, which defines attributes for every derived model
"""
created = models.ForeignKey(UserActionLogEntry, on_delete=models.SET_NULL, null=True, blank=True, related_name='+')
created = models.ForeignKey(
UserActionLogEntry,
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name='+'
)
modified = models.ForeignKey(
UserActionLogEntry,
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name='+',
help_text="Last modified"
)
class Meta:
abstract = True
@@ -131,6 +146,8 @@ class BaseObject(BaseResource):
"""
from compensation.models import Compensation, EcoAccount
from intervention.models import Intervention
from ema.models import Ema
definitions = {
Intervention: {
"length": INTERVENTION_IDENTIFIER_LENGTH,
@@ -144,6 +161,10 @@ class BaseObject(BaseResource):
"length": ECO_ACCOUNT_IDENTIFIER_LENGTH,
"template": ECO_ACCOUNT_IDENTIFIER_TEMPLATE,
},
Ema: {
"length": EMA_ACCOUNT_IDENTIFIER_LENGTH,
"template": EMA_ACCOUNT_IDENTIFIER_TEMPLATE,
},
}
if self.__class__ not in definitions:

View File

@@ -68,6 +68,7 @@ INSTALLED_APPS = [
'organisation',
'news',
'user',
'ema',
]
if DEBUG:
INSTALLED_APPS += [

View File

@@ -31,7 +31,7 @@ urlpatterns = [
path('', home_view, name="home"),
path('intervention/', include("intervention.urls")),
path('compensation/', include("compensation.urls")),
path('ema/', include("intervention.urls")), #ToDo
path('ema/', include("ema.urls")),
path('organisation/', include("organisation.urls")),
path('user/', include("user.urls")),
path('news/', include("news.urls")),

View File

@@ -24,6 +24,7 @@ class BaseTable(tables.tables.Table):
add_new_entries = True
add_new_url = None
title = None
subtitle = ""
class Meta:
attrs = {

View File

@@ -64,7 +64,6 @@ def home_view(request: HttpRequest):
# First fetch all valid objects (undeleted, only newest versions)
interventions = Intervention.objects.filter(
deleted=None,
next_version=None,
)
# Then fetch only user related ones
user_interventions = interventions.filter(
@@ -74,14 +73,12 @@ def home_view(request: HttpRequest):
# Repeat for other objects
comps = Compensation.objects.filter(
deleted=None,
next_version=None,
)
user_comps = comps.filter(
intervention__users__in=[user]
)
eco_accs = EcoAccount.objects.filter(
deleted=None,
next_version=None,
)
user_ecco_accs = eco_accs.filter(
users__in=[user]