# Refactoring revocation views
* refactors views for adding, editing and removing revocations * refactors view for getting the document of a revocation * updates tests
This commit is contained in:
@@ -7,9 +7,10 @@ Created on: 18.08.22
|
||||
"""
|
||||
from django import forms
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from intervention.models import RevocationDocument
|
||||
from intervention.models import RevocationDocument, Revocation
|
||||
from konova.forms.modals import BaseModalForm, RemoveModalForm
|
||||
from konova.utils import validators
|
||||
from konova.utils.message_templates import REVOCATION_ADDED, REVOCATION_EDITED
|
||||
@@ -75,7 +76,8 @@ class EditRevocationModalForm(NewRevocationModalForm):
|
||||
revocation = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.revocation = kwargs.pop("revocation", None)
|
||||
revocation_id = kwargs.pop("revocation_id", None)
|
||||
self.revocation = get_object_or_404(Revocation, id=revocation_id)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.form_title = _("Edit revocation")
|
||||
try:
|
||||
@@ -104,8 +106,8 @@ class RemoveRevocationModalForm(RemoveModalForm):
|
||||
revocation = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
revocation = kwargs.pop("revocation", None)
|
||||
self.revocation = revocation
|
||||
revocation_id = kwargs.pop("revocation_id", None)
|
||||
self.revocation = get_object_or_404(Revocation, id=revocation_id)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def save(self):
|
||||
|
||||
Reference in New Issue
Block a user