add event_place to fetmeeting admin and template

This commit is contained in:
2021-06-24 13:01:58 +00:00
parent 0db9aed0b7
commit 3c893bcfba
9 changed files with 45 additions and 21 deletions

View File

@@ -49,8 +49,8 @@ make_fetmeeting.short_description = "In eine Fachschaftssitzung konvertieren"
class FileUploadInline(admin.TabularInline):
model = FileUpload
extra = 0
verbose_name = "Dokument"
verbose_name_plural = "Do­ku­men­ten­samm­lung"
verbose_name = "Datei"
verbose_name_plural = "Dateien"
class PostAdmin(admin.ModelAdmin):

View File

@@ -139,11 +139,12 @@ class EventForm(PostForm):
class FetMeetingForm(PostForm):
class Meta:
model = FetMeeting
fields = ["event_start", "event_end", "tags"]
fields = ["event_start", "event_end", "event_place", "tags"]
labels = {
"event_start": _("Start der Sitzung"),
"event_end": _("Ende der Sitzung"),
"event_place": _("Ort der Sitzung"),
}
help_texts = {
@@ -165,8 +166,8 @@ class FetMeetingForm(PostForm):
class PostSearchForm(forms.Form):
year_choices = [('', _('Alle'))]
month_choices = [('', _('Alle'))] + list(MONTHS.items())
year_choices = [("", _("Alle"))]
month_choices = [("", _("Alle"))] + list(MONTHS.items())
year = forms.ChoiceField(label="Jahr", choices=year_choices, required=False)
month = forms.ChoiceField(label="Monat", choices=month_choices, required=False)
@@ -180,8 +181,8 @@ class PostSearchForm(forms.Form):
if first_post:
year_of_first_post = first_post.public_date.year
years = range(year_of_first_post, timezone.now().date().year + 1)
year_choices = [('', _('Alle'))] + [(i, i) for i in years]
self.fields['year'].choices = year_choices
year_choices = [("", _("Alle"))] + [(i, i) for i in years]
self.fields["year"].choices = year_choices
except:
pass

View File

@@ -85,7 +85,9 @@ class Post(models.Model):
is_hidden = models.BooleanField(verbose_name="UNSICHTBAR", default=False)
# addional infos for events
event_start = models.DateTimeField(verbose_name="Event Start", null=True, blank=True)
event_start = models.DateTimeField(
verbose_name="Event Start", null=True, blank=True
)
event_end = models.DateTimeField(verbose_name="Event Ende", null=True, blank=True)
event_place = models.CharField(max_length=200, null=True, blank=True)
@@ -338,7 +340,9 @@ class FetMeeting(Event):
class FileUpload(models.Model):
title = models.CharField(verbose_name="Titel", max_length=200)
file_field = models.FileField(verbose_name="Dokument", upload_to="uploads/posts/files/")
file_field = models.FileField(
verbose_name="Dokument", upload_to="uploads/posts/files/"
)
post = models.ForeignKey(Post, on_delete=models.CASCADE)
objects = models.Manager()

View File

@@ -19,7 +19,11 @@ class PostTestCase(TestCase):
post = Post.objects.get(title="Informationen zur ÖH Wahl")
slug_str = timezone.now().date().strftime("%Y-%m-%d")
date_str = timezone.now().date().strftime("%d.%m.%Y")
self.assertEqual(post.__str__(), "Post (%s-informationen-zur-oh-wahl, %s): Informationen zur ÖH Wahl" % (slug_str, date_str))
self.assertEqual(
post.__str__(),
"Post (%s-informationen-zur-oh-wahl, %s): Informationen zur ÖH Wahl"
% (slug_str, date_str),
)
def test_date_sorted(self):
post = Post()

View File

@@ -12,6 +12,12 @@ urlpatterns = [
path("", views.index, name="posts.index"),
path("fet_calendar.ics", views.calendar, name="posts.calendar"),
path("<str:id>", views.show, name="posts.show"),
re_path(r"^(?P<id>[-\w]+)/agenda.pdf$", views.show_pdf_agenda, name="show_pdf_agenda"),
re_path(r"^(?P<id>[-\w]+)/protokoll.pdf$", views.show_pdf_protocol, name="show_pdf_protocol"),
re_path(
r"^(?P<id>[-\w]+)/agenda.pdf$", views.show_pdf_agenda, name="show_pdf_agenda"
),
re_path(
r"^(?P<id>[-\w]+)/protokoll.pdf$",
views.show_pdf_protocol,
name="show_pdf_protocol",
),
]

View File

@@ -10,6 +10,6 @@ def render_to_pdf(html):
pdf = pisa.pisaDocument(src, dest)
if not pdf.err:
return HttpResponse(dest.getvalue(), content_type='application/pdf')
return HttpResponse(dest.getvalue(), content_type="application/pdf")
return None

View File

@@ -57,11 +57,12 @@ def index(request):
if not year and month:
messages.info(
request,
"Es kann nicht nur nach einem Monat gesucht werden."
request, "Es kann nicht nur nach einem Monat gesucht werden."
)
posts = deque(Post.objects.get_date_filtered_list(year, month, fet_meeting_only))
posts = deque(
Post.objects.get_date_filtered_list(year, month, fet_meeting_only)
)
else:
form = PostSearchForm()
posts = deque(Post.objects.get_date_sorted_list())
@@ -79,6 +80,7 @@ def index(request):
return render(request, "posts/index.html", context)
def calendar(request):
"Kalender Ansicht ICS zur Verknüpfung mit Outlook"
events = deque(Post.objects.get_all_posts_with_date())
@@ -129,6 +131,7 @@ def __get_post_object(id=None):
return post
def show(request, id=None):
p = __get_post_object(id)
@@ -193,7 +196,9 @@ def show(request, id=None):
def show_pdf(request, html, filename):
rendered = render_to_string(settings.BASE_DIR + "/templates/posts/pdf/template.html")
rendered = render_to_string(
settings.BASE_DIR + "/templates/posts/pdf/template.html"
)
# get body-content from pdf template
rendered = rendered.split("<html>")[1]
@@ -208,10 +213,10 @@ def show_pdf(request, html, filename):
if not pdf:
raise Http404("can't create pdf file")
response = HttpResponse(pdf, content_type='application/pdf')
response = HttpResponse(pdf, content_type="application/pdf")
content = "inline; filename=%s" % filename
response['Content-Disposition'] = content
response["Content-Disposition"] = content
return response

View File

@@ -122,6 +122,10 @@
Ende: {{ post.event_end|date:"d. F Y" }} {{ post.event_end|time:"H:i" }}<br>
{% endif %}
{% if post.event_place %}
Ort: {{ post.event_place }}
{% endif %}
{% if post.event_start %}
{% include 'posts/partials/_date_box.html' %}
{% endif %}