Templates + Routes
* adds control button for Intervention, Compensation, Ema and EcoAccount for setting a resubmission on an entry
This commit is contained in:
parent
117a4437fe
commit
4f02e8ee1b
@ -12,6 +12,9 @@
|
|||||||
</button>
|
</button>
|
||||||
</a>
|
</a>
|
||||||
{% if has_access %}
|
{% if has_access %}
|
||||||
|
<button class="btn btn-default btn-modal mr-2" title="{% trans 'Resubmission' %}" data-form-url="{% url 'compensation:resubmission-create' obj.id %}">
|
||||||
|
{% fa5_icon 'bell' %}
|
||||||
|
</button>
|
||||||
{% if is_default_member %}
|
{% if is_default_member %}
|
||||||
<a href="{% url 'compensation:edit' obj.id %}" class="mr-2">
|
<a href="{% url 'compensation:edit' obj.id %}" class="mr-2">
|
||||||
<button class="btn btn-default" title="{% trans 'Edit' %}">
|
<button class="btn btn-default" title="{% trans 'Edit' %}">
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
</button>
|
</button>
|
||||||
</a>
|
</a>
|
||||||
{% if has_access %}
|
{% if has_access %}
|
||||||
|
<button class="btn btn-default btn-modal mr-2" title="{% trans 'Resubmission' %}" data-form-url="{% url 'compensation:acc:resubmission-create' obj.id %}">
|
||||||
|
{% fa5_icon 'bell' %}
|
||||||
|
</button>
|
||||||
<button class="btn btn-default btn-modal mr-2" title="{% trans 'Share' %}" data-form-url="{% url 'compensation:acc:share-create' obj.id %}">
|
<button class="btn btn-default btn-modal mr-2" title="{% trans 'Share' %}" data-form-url="{% url 'compensation:acc:share-create' obj.id %}">
|
||||||
{% fa5_icon 'share-alt' %}
|
{% fa5_icon 'share-alt' %}
|
||||||
</button>
|
</button>
|
||||||
|
@ -31,6 +31,7 @@ urlpatterns = [
|
|||||||
path('<id>/deadline/<deadline_id>/edit', deadline_edit_view, name='deadline-edit'),
|
path('<id>/deadline/<deadline_id>/edit', deadline_edit_view, name='deadline-edit'),
|
||||||
path('<id>/deadline/<deadline_id>/remove', deadline_remove_view, name='deadline-remove'),
|
path('<id>/deadline/<deadline_id>/remove', deadline_remove_view, name='deadline-remove'),
|
||||||
path('<id>/report', report_view, name='report'),
|
path('<id>/report', report_view, name='report'),
|
||||||
|
path('<id>/resub', create_resubmission_view, name='resubmission-create'),
|
||||||
|
|
||||||
# Documents
|
# Documents
|
||||||
path('<id>/document/new/', new_document_view, name='new-doc'),
|
path('<id>/document/new/', new_document_view, name='new-doc'),
|
||||||
|
@ -19,6 +19,7 @@ urlpatterns = [
|
|||||||
path('<id>/report', report_view, name='report'),
|
path('<id>/report', report_view, name='report'),
|
||||||
path('<id>/edit', edit_view, name='edit'),
|
path('<id>/edit', edit_view, name='edit'),
|
||||||
path('<id>/remove', remove_view, name='remove'),
|
path('<id>/remove', remove_view, name='remove'),
|
||||||
|
path('<id>/resub', create_resubmission_view, name='resubmission-create'),
|
||||||
|
|
||||||
path('<id>/state/new', state_new_view, name='new-state'),
|
path('<id>/state/new', state_new_view, name='new-state'),
|
||||||
path('<id>/state/<state_id>/edit', state_edit_view, name='state-edit'),
|
path('<id>/state/<state_id>/edit', state_edit_view, name='state-edit'),
|
||||||
|
@ -14,7 +14,8 @@ from compensation.tables import CompensationTable
|
|||||||
from intervention.models import Intervention
|
from intervention.models import Intervention
|
||||||
from konova.contexts import BaseContext
|
from konova.contexts import BaseContext
|
||||||
from konova.decorators import *
|
from konova.decorators import *
|
||||||
from konova.forms import RemoveModalForm, SimpleGeomForm, RemoveDeadlineModalForm, EditDocumentModalForm
|
from konova.forms import RemoveModalForm, SimpleGeomForm, RemoveDeadlineModalForm, EditDocumentModalForm, \
|
||||||
|
ResubmissionModalForm
|
||||||
from konova.models import Deadline
|
from konova.models import Deadline
|
||||||
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
||||||
from konova.utils.documents import get_document, remove_document
|
from konova.utils.documents import get_document, remove_document
|
||||||
@ -656,3 +657,26 @@ def report_view(request: HttpRequest, id: str):
|
|||||||
}
|
}
|
||||||
context = BaseContext(request, context).context
|
context = BaseContext(request, context).context
|
||||||
return render(request, template, context)
|
return render(request, template, context)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@default_group_required
|
||||||
|
@shared_access_required(Compensation, "id")
|
||||||
|
def create_resubmission_view(request: HttpRequest, id: str):
|
||||||
|
""" Renders resubmission form for a compensation
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request (HttpRequest): The incoming request
|
||||||
|
id (str): Compensation's id
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
com = get_object_or_404(Compensation, id=id)
|
||||||
|
form = ResubmissionModalForm(request.POST or None, instance=com, request=request)
|
||||||
|
form.action_url = reverse("compensation:resubmission-create", args=(id,))
|
||||||
|
return form.process_request(
|
||||||
|
request,
|
||||||
|
msg_success=_("Resubmission set"),
|
||||||
|
redirect_url=reverse("compensation:detail", args=(id,))
|
||||||
|
)
|
||||||
|
@ -26,7 +26,7 @@ from konova.contexts import BaseContext
|
|||||||
from konova.decorators import any_group_check, default_group_required, conservation_office_group_required, \
|
from konova.decorators import any_group_check, default_group_required, conservation_office_group_required, \
|
||||||
shared_access_required
|
shared_access_required
|
||||||
from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentModalForm, RecordModalForm, \
|
from konova.forms import RemoveModalForm, SimpleGeomForm, NewDocumentModalForm, RecordModalForm, \
|
||||||
RemoveDeadlineModalForm, EditDocumentModalForm
|
RemoveDeadlineModalForm, EditDocumentModalForm, ResubmissionModalForm
|
||||||
from konova.models import Deadline
|
from konova.models import Deadline
|
||||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||||
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
||||||
@ -839,3 +839,26 @@ def create_share_view(request: HttpRequest, id: str):
|
|||||||
request,
|
request,
|
||||||
msg_success=_("Share settings updated")
|
msg_success=_("Share settings updated")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@default_group_required
|
||||||
|
@shared_access_required(EcoAccount, "id")
|
||||||
|
def create_resubmission_view(request: HttpRequest, id: str):
|
||||||
|
""" Renders resubmission form for an eco account
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request (HttpRequest): The incoming request
|
||||||
|
id (str): EcoAccount's id
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
acc = get_object_or_404(EcoAccount, id=id)
|
||||||
|
form = ResubmissionModalForm(request.POST or None, instance=acc, request=request)
|
||||||
|
form.action_url = reverse("compensation:acc:resubmission-create", args=(id,))
|
||||||
|
return form.process_request(
|
||||||
|
request,
|
||||||
|
msg_success=_("Resubmission set"),
|
||||||
|
redirect_url=reverse("compensation:acc:detail", args=(id,))
|
||||||
|
)
|
@ -12,6 +12,9 @@
|
|||||||
</button>
|
</button>
|
||||||
</a>
|
</a>
|
||||||
{% if has_access %}
|
{% if has_access %}
|
||||||
|
<button class="btn btn-default btn-modal mr-2" title="{% trans 'Resubmission' %}" data-form-url="{% url 'ema:resubmission-create' obj.id %}">
|
||||||
|
{% fa5_icon 'bell' %}
|
||||||
|
</button>
|
||||||
<button class="btn btn-default btn-modal mr-2" title="{% trans 'Share' %}" data-form-url="{% url 'ema:share-create' obj.id %}">
|
<button class="btn btn-default btn-modal mr-2" title="{% trans 'Share' %}" data-form-url="{% url 'ema:share-create' obj.id %}">
|
||||||
{% fa5_icon 'share-alt' %}
|
{% fa5_icon 'share-alt' %}
|
||||||
</button>
|
</button>
|
||||||
|
@ -19,6 +19,7 @@ urlpatterns = [
|
|||||||
path('<id>/remove', remove_view, name='remove'),
|
path('<id>/remove', remove_view, name='remove'),
|
||||||
path('<id>/record', record_view, name='record'),
|
path('<id>/record', record_view, name='record'),
|
||||||
path('<id>/report', report_view, name='report'),
|
path('<id>/report', report_view, name='report'),
|
||||||
|
path('<id>/resub', create_resubmission_view, name='resubmission-create'),
|
||||||
|
|
||||||
path('<id>/state/new', state_new_view, name='new-state'),
|
path('<id>/state/new', state_new_view, name='new-state'),
|
||||||
path('<id>/state/<state_id>/remove', state_remove_view, name='state-remove'),
|
path('<id>/state/<state_id>/remove', state_remove_view, name='state-remove'),
|
||||||
|
25
ema/views.py
25
ema/views.py
@ -17,7 +17,7 @@ from konova.contexts import BaseContext
|
|||||||
from konova.decorators import conservation_office_group_required, shared_access_required
|
from konova.decorators import conservation_office_group_required, shared_access_required
|
||||||
from ema.models import Ema, EmaDocument
|
from ema.models import Ema, EmaDocument
|
||||||
from konova.forms import RemoveModalForm, SimpleGeomForm, RecordModalForm, RemoveDeadlineModalForm, \
|
from konova.forms import RemoveModalForm, SimpleGeomForm, RecordModalForm, RemoveDeadlineModalForm, \
|
||||||
EditDocumentModalForm
|
EditDocumentModalForm, ResubmissionModalForm
|
||||||
from konova.models import Deadline
|
from konova.models import Deadline
|
||||||
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
from konova.settings import DEFAULT_GROUP, ZB_GROUP, ETS_GROUP
|
||||||
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
||||||
@ -711,3 +711,26 @@ def deadline_remove_view(request: HttpRequest, id: str, deadline_id: str):
|
|||||||
msg_success=DEADLINE_REMOVED,
|
msg_success=DEADLINE_REMOVED,
|
||||||
redirect_url=reverse("ema:detail", args=(id,)) + "#related_data"
|
redirect_url=reverse("ema:detail", args=(id,)) + "#related_data"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@conservation_office_group_required
|
||||||
|
@shared_access_required(Ema, "id")
|
||||||
|
def create_resubmission_view(request: HttpRequest, id: str):
|
||||||
|
""" Renders resubmission form for an EMA
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request (HttpRequest): The incoming request
|
||||||
|
id (str): EMA's id
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
ema = get_object_or_404(Ema, id=id)
|
||||||
|
form = ResubmissionModalForm(request.POST or None, instance=ema, request=request)
|
||||||
|
form.action_url = reverse("ema:resubmission-create", args=(id,))
|
||||||
|
return form.process_request(
|
||||||
|
request,
|
||||||
|
msg_success=_("Resubmission set"),
|
||||||
|
redirect_url=reverse("ema:detail", args=(id,))
|
||||||
|
)
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
</button>
|
</button>
|
||||||
</a>
|
</a>
|
||||||
{% if has_access %}
|
{% if has_access %}
|
||||||
|
<button class="btn btn-default btn-modal mr-2" title="{% trans 'Resubmission' %}" data-form-url="{% url 'intervention:resubmission-create' obj.id %}">
|
||||||
|
{% fa5_icon 'bell' %}
|
||||||
|
</button>
|
||||||
<button class="btn btn-default btn-modal mr-2" title="{% trans 'Share' %}" data-form-url="{% url 'intervention:share-create' obj.id %}">
|
<button class="btn btn-default btn-modal mr-2" title="{% trans 'Share' %}" data-form-url="{% url 'intervention:share-create' obj.id %}">
|
||||||
{% fa5_icon 'share-alt' %}
|
{% fa5_icon 'share-alt' %}
|
||||||
</button>
|
</button>
|
||||||
|
@ -10,7 +10,8 @@ from django.urls import path
|
|||||||
from intervention.views import index_view, new_view, detail_view, edit_view, remove_view, new_document_view, share_view, \
|
from intervention.views import index_view, new_view, detail_view, edit_view, remove_view, new_document_view, share_view, \
|
||||||
create_share_view, remove_revocation_view, new_revocation_view, check_view, log_view, new_deduction_view, \
|
create_share_view, remove_revocation_view, new_revocation_view, check_view, log_view, new_deduction_view, \
|
||||||
record_view, remove_document_view, get_document_view, get_revocation_view, new_id_view, report_view, \
|
record_view, remove_document_view, get_document_view, get_revocation_view, new_id_view, report_view, \
|
||||||
remove_deduction_view, remove_compensation_view, edit_deduction_view, edit_revocation_view, edit_document_view
|
remove_deduction_view, remove_compensation_view, edit_deduction_view, edit_revocation_view, edit_document_view, \
|
||||||
|
create_resubmission_view
|
||||||
|
|
||||||
app_name = "intervention"
|
app_name = "intervention"
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
@ -26,6 +27,7 @@ urlpatterns = [
|
|||||||
path('<id>/check', check_view, name='check'),
|
path('<id>/check', check_view, name='check'),
|
||||||
path('<id>/record', record_view, name='record'),
|
path('<id>/record', record_view, name='record'),
|
||||||
path('<id>/report', report_view, name='report'),
|
path('<id>/report', report_view, name='report'),
|
||||||
|
path('<id>/resub', create_resubmission_view, name='resubmission-create'),
|
||||||
|
|
||||||
# Compensations
|
# Compensations
|
||||||
path('<id>/compensation/<comp_id>/remove', remove_compensation_view, name='remove-compensation'),
|
path('<id>/compensation/<comp_id>/remove', remove_compensation_view, name='remove-compensation'),
|
||||||
|
@ -12,7 +12,7 @@ from intervention.models import Intervention, Revocation, InterventionDocument,
|
|||||||
from intervention.tables import InterventionTable
|
from intervention.tables import InterventionTable
|
||||||
from konova.contexts import BaseContext
|
from konova.contexts import BaseContext
|
||||||
from konova.decorators import *
|
from konova.decorators import *
|
||||||
from konova.forms import SimpleGeomForm, RemoveModalForm, RecordModalForm, EditDocumentModalForm
|
from konova.forms import SimpleGeomForm, RemoveModalForm, RecordModalForm, EditDocumentModalForm, ResubmissionModalForm
|
||||||
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
||||||
from konova.utils.documents import remove_document, get_document
|
from konova.utils.documents import remove_document, get_document
|
||||||
from konova.utils.generators import generate_qr_code
|
from konova.utils.generators import generate_qr_code
|
||||||
@ -475,6 +475,29 @@ def create_share_view(request: HttpRequest, id: str):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
@default_group_required
|
||||||
|
@shared_access_required(Intervention, "id")
|
||||||
|
def create_resubmission_view(request: HttpRequest, id: str):
|
||||||
|
""" Renders resubmission form for an intervention
|
||||||
|
|
||||||
|
Args:
|
||||||
|
request (HttpRequest): The incoming request
|
||||||
|
id (str): Intervention's id
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
|
||||||
|
"""
|
||||||
|
intervention = get_object_or_404(Intervention, id=id)
|
||||||
|
form = ResubmissionModalForm(request.POST or None, instance=intervention, request=request)
|
||||||
|
form.action_url = reverse("intervention:resubmission-create", args=(id,))
|
||||||
|
return form.process_request(
|
||||||
|
request,
|
||||||
|
msg_success=_("Resubmission set"),
|
||||||
|
redirect_url=reverse("intervention:detail", args=(id,))
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@registration_office_group_required
|
@registration_office_group_required
|
||||||
@shared_access_required(Intervention, "id")
|
@shared_access_required(Intervention, "id")
|
||||||
|
@ -7,7 +7,7 @@ Created on: 22.07.21
|
|||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from konova.models import Geometry, Deadline, GeometryConflict, Parcel, District, Municipal, ParcelGroup
|
from konova.models import Geometry, Deadline, GeometryConflict, Parcel, District, Municipal, ParcelGroup, Resubmission
|
||||||
from konova.sub_settings.lanis_settings import DEFAULT_SRID_RLP
|
from konova.sub_settings.lanis_settings import DEFAULT_SRID_RLP
|
||||||
from konova.utils.message_templates import COMPENSATION_REMOVED_TEMPLATE
|
from konova.utils.message_templates import COMPENSATION_REMOVED_TEMPLATE
|
||||||
from user.models import UserAction
|
from user.models import UserAction
|
||||||
@ -139,6 +139,15 @@ class BaseObjectAdmin(BaseResourceAdmin, DeletableObjectMixinAdmin):
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class ResubmissionAdmin(BaseResourceAdmin):
|
||||||
|
list_display = [
|
||||||
|
"resubmit_on"
|
||||||
|
]
|
||||||
|
fields = [
|
||||||
|
"comment",
|
||||||
|
"resubmit_on"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
# Outcommented for a cleaner admin backend on production
|
# Outcommented for a cleaner admin backend on production
|
||||||
#admin.site.register(Geometry, GeometryAdmin)
|
#admin.site.register(Geometry, GeometryAdmin)
|
||||||
@ -148,3 +157,4 @@ class BaseObjectAdmin(BaseResourceAdmin, DeletableObjectMixinAdmin):
|
|||||||
#admin.site.register(ParcelGroup, ParcelGroupAdmin)
|
#admin.site.register(ParcelGroup, ParcelGroupAdmin)
|
||||||
#admin.site.register(GeometryConflict, GeometryConflictAdmin)
|
#admin.site.register(GeometryConflict, GeometryConflictAdmin)
|
||||||
#admin.site.register(Deadline, DeadlineAdmin)
|
#admin.site.register(Deadline, DeadlineAdmin)
|
||||||
|
#admin.site.register(Resubmission, ResubmissionAdmin)
|
||||||
|
@ -13,7 +13,9 @@ from bootstrap_modal_forms.utils import is_ajax
|
|||||||
from django import forms
|
from django import forms
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.gis import gdal
|
from django.contrib.gis import gdal
|
||||||
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.db.models.fields.files import FieldFile
|
from django.db.models.fields.files import FieldFile
|
||||||
|
from django.utils.timezone import now
|
||||||
|
|
||||||
from compensation.models import EcoAccount
|
from compensation.models import EcoAccount
|
||||||
from konova.sub_settings.lanis_settings import DEFAULT_SRID_RLP
|
from konova.sub_settings.lanis_settings import DEFAULT_SRID_RLP
|
||||||
@ -26,7 +28,7 @@ from django.shortcuts import render
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from konova.contexts import BaseContext
|
from konova.contexts import BaseContext
|
||||||
from konova.models import BaseObject, Geometry, RecordableObjectMixin, AbstractDocument
|
from konova.models import BaseObject, Geometry, RecordableObjectMixin, AbstractDocument, Resubmission
|
||||||
from konova.settings import DEFAULT_SRID
|
from konova.settings import DEFAULT_SRID
|
||||||
from konova.tasks import celery_update_parcels
|
from konova.tasks import celery_update_parcels
|
||||||
from konova.utils.message_templates import FORM_INVALID, FILE_TYPE_UNSUPPORTED, FILE_SIZE_TOO_LARGE, DOCUMENT_EDITED
|
from konova.utils.message_templates import FORM_INVALID, FILE_TYPE_UNSUPPORTED, FILE_SIZE_TOO_LARGE, DOCUMENT_EDITED
|
||||||
@ -161,6 +163,7 @@ class BaseForm(forms.Form):
|
|||||||
self,
|
self,
|
||||||
(
|
(
|
||||||
NewDeductionModalForm,
|
NewDeductionModalForm,
|
||||||
|
ResubmissionModalForm,
|
||||||
EditEcoAccountDeductionModalForm,
|
EditEcoAccountDeductionModalForm,
|
||||||
RemoveEcoAccountDeductionModalForm,
|
RemoveEcoAccountDeductionModalForm,
|
||||||
)
|
)
|
||||||
@ -686,3 +689,72 @@ class RecordModalForm(BaseModalForm):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class ResubmissionModalForm(BaseModalForm):
|
||||||
|
date = forms.DateField(
|
||||||
|
label_suffix=_(""),
|
||||||
|
label=_("Date"),
|
||||||
|
help_text=_("When do you want to be reminded?"),
|
||||||
|
widget=forms.DateInput(
|
||||||
|
attrs={
|
||||||
|
"type": "date",
|
||||||
|
"data-provide": "datepicker",
|
||||||
|
"class": "form-control",
|
||||||
|
},
|
||||||
|
format="%d.%m.%Y"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
comment = forms.CharField(
|
||||||
|
required=False,
|
||||||
|
label=_("Comment"),
|
||||||
|
label_suffix=_(""),
|
||||||
|
help_text=_("Additional comment"),
|
||||||
|
widget=forms.Textarea(
|
||||||
|
attrs={
|
||||||
|
"cols": 30,
|
||||||
|
"rows": 5,
|
||||||
|
"class": "form-control",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
self.form_title = _("Resubmission")
|
||||||
|
self.form_caption = _("Set your resubmission for this entry.")
|
||||||
|
self.action_url = None
|
||||||
|
|
||||||
|
try:
|
||||||
|
self.resubmission = self.instance.resubmissions.get(
|
||||||
|
user=self.user
|
||||||
|
)
|
||||||
|
self.initialize_form_field("date", str(self.resubmission.resubmit_on))
|
||||||
|
self.initialize_form_field("comment", self.resubmission.comment)
|
||||||
|
except ObjectDoesNotExist:
|
||||||
|
self.resubmission = Resubmission()
|
||||||
|
|
||||||
|
def is_valid(self):
|
||||||
|
super_valid = super().is_valid()
|
||||||
|
self_valid = True
|
||||||
|
|
||||||
|
date = self.cleaned_data.get("date")
|
||||||
|
today = now().today().date()
|
||||||
|
if date <= today:
|
||||||
|
self.add_error(
|
||||||
|
"date",
|
||||||
|
_("The date should be in the future")
|
||||||
|
)
|
||||||
|
self_valid = False
|
||||||
|
|
||||||
|
return super_valid and self_valid
|
||||||
|
|
||||||
|
def save(self):
|
||||||
|
with transaction.atomic():
|
||||||
|
self.resubmission.user = self.user
|
||||||
|
self.resubmission.resubmit_on = self.cleaned_data.get("date")
|
||||||
|
self.resubmission.comment = self.cleaned_data.get("comment")
|
||||||
|
self.resubmission.save()
|
||||||
|
self.instance.resubmissions.add(self.resubmission)
|
||||||
|
return self.resubmission
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user