mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-23 01:51:08 +00:00
Editable announcement
This commit is contained in:
parent
d64e0c4aa8
commit
3d70a36d86
6 changed files with 104 additions and 72 deletions
|
@ -1,5 +1,4 @@
|
|||
{% spaceless %}
|
||||
|
||||
{% load i18n %}
|
||||
|
||||
<dl>
|
||||
|
|
|
@ -1,22 +1,59 @@
|
|||
{% extends 'settings/admin_layout.html' %}
|
||||
{% load i18n %}
|
||||
{% load i18n %}{% load humanize %}
|
||||
{% block title %}{% trans "Announcement" %} - {{ announcement.preview }}{% endblock %}
|
||||
|
||||
{% block header %}{% trans "Announcement" %}{% endblock %}
|
||||
{% block header %}
|
||||
{% trans "Announcement" %}
|
||||
<a href="{% url 'settings-announcements' %}" class="has-text-weight-normal help">{% trans "Back to list" %}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block edit-button %}
|
||||
{% trans "Edit Announcement" as button_text %}
|
||||
{% include 'snippets/toggle/open_button.html' with controls_text="create-announcement" icon_with_text="plus" text=button_text focus="create-announcement-header" %}
|
||||
{% include 'snippets/toggle/open_button.html' with controls_text="edit-announcement" icon_with_text="plus" text=button_text focus="edit-announcement-header" %}
|
||||
</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block panel %}
|
||||
|
||||
<div class="block">
|
||||
{% include 'settings/announcement_form.html' with controls_text="create-announcement" %}
|
||||
</div>
|
||||
<form name="edit-announcement" method="post" action="{% url 'settings-announcements' announcement.id %}" class="block">
|
||||
{% include 'settings/announcement_form.html' with controls_text="edit-announcement" %}
|
||||
</form>
|
||||
|
||||
<div class="block content">
|
||||
<dl>
|
||||
<div class="is-flex notification pt-1 pb-1 mb-0 {% if announcement in active_announcements %}is-success{% else %}is-danger{% endif %}">
|
||||
<dt class="mr-1 has-text-weight-bold">{% trans "Visible:" %}</dt>
|
||||
<dd>
|
||||
{% if announcement in active_announcements %}
|
||||
{% trans "True" %}
|
||||
{% else %}
|
||||
{% trans "False" %}
|
||||
{% endif %}
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
{% if announcement.start_date %}
|
||||
<div class="is-flex notificationi pt-1 pb-1 mb-0 has-background-white">
|
||||
<dt class="mr-1 has-text-weight-bold">{% trans "Start date:" %}</dt>
|
||||
<dd>{{ announcement.start_date|naturalday }}</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if announcement.end_date %}
|
||||
<div class="is-flex notification pt-1 pb-1 mb-0 has-background-white">
|
||||
<dt class="mr-1 has-text-weight-bold">{% trans "End date:" %}</dt>
|
||||
<dd>{{ announcement.end_date|naturalday }}</dd>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="is-flex notification pt-1 pb-1 has-background-white">
|
||||
<dt class="mr-1 has-text-weight-bold">{% trans "Active:" %}</dt>
|
||||
<dd>{{ announcement.active }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<hr aria-hidden="true">
|
||||
|
||||
{% include 'snippets/announcement.html' with announcement=announcement pressed=True %}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -6,67 +6,63 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block form %}
|
||||
<form name="create-announcement" method="post" action="{% url 'settings-announcements' %}">
|
||||
<form name="create-announcement" method="post" action="/settings/announcements">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||
<p>
|
||||
<label class="label" for="id_preview">Preview:</label>
|
||||
{{ form.preview }}
|
||||
{% for error in form.preview.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<p>
|
||||
<label class="label" for="id_content">Content:</label>
|
||||
{{ form.content }}
|
||||
{% for error in form.content.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<p>
|
||||
<label class="label" for="id_event_date">Event date:</label>
|
||||
<input type="date" name="event_date" value="{{ form.event_date.value }}" class="input" id="id_event_date">
|
||||
{% for error in form.event_date.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<hr aria-hidden="true">
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<p>
|
||||
<label class="label" for="id_start_date">Start date:</label>
|
||||
<input type="date" name="start_date" class="input" id="id_start_date">
|
||||
{% for error in form.start_date.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<p>
|
||||
<label class="label" for="id_end_date">End date:</label>
|
||||
<input type="date" name="end_date" class="input" id="id_end_date">
|
||||
{% for error in form.end_date.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
<div class="column is-narrow">
|
||||
<p>
|
||||
<label class="label" for="id_active">Active:</label>
|
||||
{{ form.active }}
|
||||
{% for error in form.active.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ request.user.id }}">
|
||||
<p>
|
||||
<label class="label" for="id_preview">Preview:</label>
|
||||
{{ form.preview }}
|
||||
{% for error in form.preview.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<p>
|
||||
<label class="label" for="id_content">Content:</label>
|
||||
{{ form.content }}
|
||||
{% for error in form.content.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<p>
|
||||
<label class="label" for="id_event_date">Event date:</label>
|
||||
<input type="date" name="event_date" value="{{ form.event_date.value }}" class="input" id="id_event_date">
|
||||
{% for error in form.event_date.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
</p>
|
||||
<hr aria-hidden="true">
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<p>
|
||||
<label class="label" for="id_start_date">Start date:</label>
|
||||
<input type="date" name="start_date" class="input" id="id_start_date">
|
||||
{% for error in form.start_date.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
<div class="column">
|
||||
<p>
|
||||
<label class="label" for="id_end_date">End date:</label>
|
||||
<input type="date" name="end_date" class="input" id="id_end_date">
|
||||
{% for error in form.end_date.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
<div class="column is-narrow">
|
||||
<p>
|
||||
<label class="label" for="id_active">Active:</label>
|
||||
{{ form.active }}
|
||||
{% for error in form.active.errors %}
|
||||
<p class="help is-danger">{{ error | escape }}</p>
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
<button type="submit" class="button is-primary">{% trans "Save" %}</button>
|
||||
</div>
|
||||
<div class="field has-addons">
|
||||
<div class="control">
|
||||
<button type="submit" class="button is-primary">{% trans "Save" %}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block panel %}
|
||||
<div class="block">
|
||||
<form name="create-announcement" method="post" action="{% url 'settings-announcements' %}" class="block">
|
||||
{% include 'settings/announcement_form.html' with controls_text="create-announcement" %}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<table class="table is-striped">
|
||||
<tr>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
{% if server.status == "blocked" %}<span class="icon icon-x has-text-danger is-size-5" title="{% trans 'Blocked' %}"><span class="is-sr-only">{% trans "Blocked" %}</span></span>
|
||||
{% endif %}
|
||||
|
||||
<a href="{% url 'settings-federation' %}" class="has-text-weight-normal help">{% trans "Back to server list" %}</a>
|
||||
<a href="{% url 'settings-federation' %}" class="has-text-weight-normal help">{% trans "Back to list" %}</a>
|
||||
{% endblock %}
|
||||
|
||||
{% block panel %}
|
||||
|
|
|
@ -61,9 +61,9 @@ class Announcement(View):
|
|||
announcement = get_object_or_404(models.Announcement, id=announcement_id)
|
||||
form = forms.AnnouncementForm(request.POST, instance=announcement)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
announcement = form.save()
|
||||
data = {
|
||||
"announcements": models.Announcement.objects.all(),
|
||||
"announcement": announcement,
|
||||
"form": form,
|
||||
}
|
||||
return TemplateResponse(request, "settings/announcement.html", data)
|
||||
|
|
Loading…
Reference in a new issue