Access url for interventions
* adds access_token as new attribute * adds generating of access_token * adds new form * adds two new routes for sharing an intervention * adds translation * adds render_submit to BaseModalForm which triggers rendering the modal footer
This commit is contained in:
+37
-1
@@ -15,7 +15,7 @@ from django.urls import reverse
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from intervention.models import Intervention
|
||||
from konova.forms import BaseForm
|
||||
from konova.forms import BaseForm, BaseModalForm
|
||||
from konova.models import Document
|
||||
from konova.settings import DEFAULT_LAT, DEFAULT_LON, DEFAULT_ZOOM
|
||||
from organisation.models import Organisation
|
||||
@@ -220,6 +220,42 @@ class OpenInterventionForm(EditInterventionForm):
|
||||
self.disable_form_field(field)
|
||||
|
||||
|
||||
class ShareInterventionForm(BaseModalForm):
|
||||
url = forms.CharField(
|
||||
label=_("Share link"),
|
||||
label_suffix="",
|
||||
disabled=True,
|
||||
required=False,
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
"style": "width:100%",
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.form_title = _("Share")
|
||||
self.form_caption = _("Send this link to users who you want to have writing access on the data.")
|
||||
self.template = "modal/modal_form.html"
|
||||
self.render_submit = False
|
||||
|
||||
# Make sure an access_token is set
|
||||
if self.instance.access_token is None:
|
||||
self.instance.generate_access_token()
|
||||
|
||||
self.share_link = self.request.build_absolute_uri(
|
||||
reverse("intervention:share", args=(self.instance.id, self.instance.access_token,))
|
||||
)
|
||||
self.initialize_form_field(
|
||||
"url",
|
||||
self.share_link
|
||||
)
|
||||
|
||||
def save(self):
|
||||
i = 0
|
||||
|
||||
|
||||
class DummyFilterInput(forms.HiddenInput):
|
||||
""" A dummy input widget
|
||||
|
||||
|
||||
Reference in New Issue
Block a user