Hide the cancel button and add title/subtitle to notification page
This commit is contained in:
parent
7ee698f457
commit
246674b03e
|
@ -1,5 +1,10 @@
|
||||||
{% include 'partials/notify.html' %}
|
{% include 'partials/notify.html' %}
|
||||||
|
{% if page_title is not None %}
|
||||||
|
<h1 class="title is-4">{{ page_title }}</h1>
|
||||||
|
{% endif %}
|
||||||
|
{% if page_subtitle is not None %}
|
||||||
|
<h1 class="subtitle">{{ page_subtitle }}</h1>
|
||||||
|
{% endif %}
|
||||||
{% load crispy_forms_tags %}
|
{% load crispy_forms_tags %}
|
||||||
|
|
||||||
{% load crispy_forms_bulma_field %}
|
{% load crispy_forms_bulma_field %}
|
||||||
|
@ -10,11 +15,13 @@
|
||||||
hx-swap="innerHTML">
|
hx-swap="innerHTML">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form|crispy }}
|
{{ form|crispy }}
|
||||||
<button
|
{% if hide_cancel is not True %}
|
||||||
type="button"
|
<button
|
||||||
class="button is-light modal-close-button">
|
type="button"
|
||||||
Cancel
|
class="button is-light modal-close-button">
|
||||||
</button>
|
Cancel
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
<button type="submit" class="button modal-close-button">Submit</button>
|
<button type="submit" class="button modal-close-button">Submit</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -341,6 +341,9 @@ class ObjectUpdate(RestrictedViewMixin, ObjectNameMixin, UpdateView):
|
||||||
window_content = "window-content/object-form.html"
|
window_content = "window-content/object-form.html"
|
||||||
parser_classes = [FormParser]
|
parser_classes = [FormParser]
|
||||||
|
|
||||||
|
page_title = None
|
||||||
|
page_subtitle = None
|
||||||
|
|
||||||
model = None
|
model = None
|
||||||
submit_url_name = None
|
submit_url_name = None
|
||||||
submit_url_args = ["type", "pk"]
|
submit_url_args = ["type", "pk"]
|
||||||
|
@ -350,6 +353,9 @@ class ObjectUpdate(RestrictedViewMixin, ObjectNameMixin, UpdateView):
|
||||||
# Whether pk is required in the get request
|
# Whether pk is required in the get request
|
||||||
pk_required = True
|
pk_required = True
|
||||||
|
|
||||||
|
# Whether to hide the cancel button in the form
|
||||||
|
hide_cancel = False
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.title = "Update " + self.context_object_name_singular
|
self.title = "Update " + self.context_object_name_singular
|
||||||
|
@ -411,6 +417,11 @@ class ObjectUpdate(RestrictedViewMixin, ObjectNameMixin, UpdateView):
|
||||||
context["context_object_name_singular"] = self.context_object_name_singular
|
context["context_object_name_singular"] = self.context_object_name_singular
|
||||||
context["submit_url"] = submit_url
|
context["submit_url"] = submit_url
|
||||||
context["type"] = type
|
context["type"] = type
|
||||||
|
context["hide_cancel"] = self.hide_cancel
|
||||||
|
if self.page_title:
|
||||||
|
context["page_title"] = self.page_title
|
||||||
|
if self.page_subtitle:
|
||||||
|
context["page_subtitle"] = self.page_subtitle
|
||||||
response = self.render_to_response(context)
|
response = self.render_to_response(context)
|
||||||
# response["HX-Trigger"] = f"{self.context_object_name_singular}Event"
|
# response["HX-Trigger"] = f"{self.context_object_name_singular}Event"
|
||||||
return response
|
return response
|
||||||
|
|
|
@ -11,6 +11,11 @@ class NotificationsUpdate(LoginRequiredMixin, ObjectUpdate):
|
||||||
model = NotificationSettings
|
model = NotificationSettings
|
||||||
form_class = NotificationSettingsForm
|
form_class = NotificationSettingsForm
|
||||||
|
|
||||||
|
page_title = "Update your notification settings."
|
||||||
|
page_subtitle = (
|
||||||
|
"At least the topic must be set if you want to receive notifications."
|
||||||
|
)
|
||||||
|
|
||||||
# list_url_name = "notifications"
|
# list_url_name = "notifications"
|
||||||
# list_url_args = ["type"]
|
# list_url_args = ["type"]
|
||||||
|
|
||||||
|
@ -19,6 +24,8 @@ class NotificationsUpdate(LoginRequiredMixin, ObjectUpdate):
|
||||||
|
|
||||||
pk_required = False
|
pk_required = False
|
||||||
|
|
||||||
|
hide_cancel = True
|
||||||
|
|
||||||
def get_object(self, **kwargs):
|
def get_object(self, **kwargs):
|
||||||
notification_settings, _ = NotificationSettings.objects.get_or_create(
|
notification_settings, _ = NotificationSettings.objects.get_or_create(
|
||||||
user=self.request.user
|
user=self.request.user
|
||||||
|
|
Loading…
Reference in New Issue