diff --git a/fet2020/intern/forms.py b/fet2020/intern/forms.py index d952f5e1..4bbb4dfe 100644 --- a/fet2020/intern/forms.py +++ b/fet2020/intern/forms.py @@ -153,6 +153,11 @@ class TopicCreateForm(forms.ModelForm): "topic_group": HiddenInput, } + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) # to get the self.fields set + + self.fields["title"].autofocus = True + class TopicUpdateForm(forms.ModelForm): class Meta: @@ -173,11 +178,15 @@ class TopicUpdateForm(forms.ModelForm): "topic_group": HiddenInput, } + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) # to get the self.fields set + + self.fields["title"].autofocus = True + class AttachmentCreateForm(forms.ModelForm): class Meta: model = Attachment - fields = [ "title", "description", @@ -194,11 +203,15 @@ class AttachmentCreateForm(forms.ModelForm): "topic": HiddenInput, } + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) # to get the self.fields set + + self.fields["title"].autofocus = True + class AttachmentUpdateForm(forms.ModelForm): class Meta: model = Attachment - fields = [ "title", "description", @@ -215,11 +228,15 @@ class AttachmentUpdateForm(forms.ModelForm): "topic": HiddenInput, } + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) # to get the self.fields set -class EtherpadForm(forms.ModelForm): + self.fields["title"].autofocus = True + + +class EtherpadCreateForm(forms.ModelForm): class Meta: model = Etherpad - fields = [ "title", "date", @@ -236,8 +253,13 @@ class EtherpadForm(forms.ModelForm): "attachment": HiddenInput, } + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) # to get the self.fields set -class FileUploadForm(forms.ModelForm): + self.fields["title"].autofocus = True + + +class FileUploadCreateForm(forms.ModelForm): class Meta: model = FileUpload fields = [ @@ -246,6 +268,16 @@ class FileUploadForm(forms.ModelForm): "attachment", ] + labels = { + "title": "Titel", + "date": "Datum", + } + widgets = { "attachment": HiddenInput, } + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) # to get the self.fields set + + self.fields["file_field"].autofocus = True diff --git a/fet2020/intern/views.py b/fet2020/intern/views.py index d4ce2d0e..67c161c9 100644 --- a/fet2020/intern/views.py +++ b/fet2020/intern/views.py @@ -14,8 +14,8 @@ from fet2020.utils import add_log_action from .forms import ( AttachmentCreateForm, AttachmentUpdateForm, - EtherpadForm, - FileUploadForm, + EtherpadCreateForm, + FileUploadCreateForm, TopicCreateForm, TopicUpdateForm, ) @@ -45,7 +45,7 @@ class TopicCreateView(LoginRequiredMixin, CreateView): form_class = TopicCreateForm model = Topic success_url = reverse_lazy("intern:index") - template_name = "intern/topic/topic_create.html" + template_name = "intern/topic/create.html" def form_valid(self, form): form.instance.created_by = self.request.user @@ -61,7 +61,7 @@ class TopicCreateView(LoginRequiredMixin, CreateView): class TopicDetailView(LoginRequiredMixin, DetailView): model = Topic - template_name = "intern/topic/topic_detail.html" + template_name = "intern/topic/detail.html" def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) @@ -80,7 +80,7 @@ class TopicDetailView(LoginRequiredMixin, DetailView): class TopicUpdateView(LoginRequiredMixin, UpdateView): form_class = TopicUpdateForm model = Topic - template_name = "intern/topic/topic_update.html" + template_name = "intern/topic/update.html" def form_valid(self, form): form.instance.created_by = self.request.user @@ -95,7 +95,7 @@ class TopicUpdateView(LoginRequiredMixin, UpdateView): class AttachmentCreateView(LoginRequiredMixin, CreateView): form_class = AttachmentCreateForm model = Attachment - template_name = "intern/attachment/attachment_create.html" + template_name = "intern/attachment/create.html" def form_valid(self, form): form.instance.created_by = self.request.user @@ -117,7 +117,7 @@ class AttachmentCreateView(LoginRequiredMixin, CreateView): class AttachmentDetailView(LoginRequiredMixin, DetailView): model = Attachment - template_name = "intern/attachment/attachment_detail.html" + template_name = "intern/attachment/detail.html" def get(self, request, *args, **kwargs): response = super().get(request, *args, **kwargs) @@ -150,7 +150,7 @@ class AttachmentDetailView(LoginRequiredMixin, DetailView): class AttachmentUpdateView(LoginRequiredMixin, UpdateView): form_class = AttachmentUpdateForm model = Attachment - template_name = "intern/attachment/attachment_update.html" + template_name = "intern/attachment/update.html" def form_valid(self, form): form.instance.created_by = self.request.user @@ -171,9 +171,9 @@ class AttachmentUpdateView(LoginRequiredMixin, UpdateView): class EtherpadCreateView(LoginRequiredMixin, CreateView): - form_class = EtherpadForm + form_class = EtherpadCreateForm model = Etherpad - template_name = "intern/etherpad_create.html" + template_name = "intern/etherpad/create.html" def form_valid(self, form): form.instance.created_by = self.request.user @@ -198,9 +198,9 @@ class EtherpadCreateView(LoginRequiredMixin, CreateView): class FileUploadCreateView(LoginRequiredMixin, CreateView): - form_class = FileUploadForm + form_class = FileUploadCreateForm model = FileUpload - template_name = "intern/file_create.html" + template_name = "intern/fileupload/create.html" def form_valid(self, form): form.instance.created_by = self.request.user diff --git a/fet2020/templates/baseform/file.html b/fet2020/templates/baseform/file.html index 5a072905..63656be1 100644 --- a/fet2020/templates/baseform/file.html +++ b/fet2020/templates/baseform/file.html @@ -8,6 +8,9 @@ diff --git a/fet2020/templates/intern/attachment/attachment_create.html b/fet2020/templates/intern/attachment/attachment_create.html deleted file mode 100644 index 608e7c68..00000000 --- a/fet2020/templates/intern/attachment/attachment_create.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends 'base.html' %} - -{% block title %}Anhang Ordner hinzufügen{% endblock %} - -{% block content %} - -
-

Anhang Ordner hinzufügen

-
-
- {% csrf_token %} - - {% if form.non_field_errors %} -
- -

Fehler:

-
{{ form.non_field_errors }}
-
- {% endif %} - - - - - - - - -
-
-
-{% endblock %} diff --git a/fet2020/templates/intern/attachment/attachment_update.html b/fet2020/templates/intern/attachment/attachment_update.html deleted file mode 100644 index 1092b272..00000000 --- a/fet2020/templates/intern/attachment/attachment_update.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends 'base.html' %} - -{% block title %}{{ attachment.title }} bearbeiten{% endblock %} - -{% block content %} - -
-

Anhang Ordner '{{ attachment.title }}' bearbeiten

-
-
- {% csrf_token %} - - {% if form.non_field_errors %} -
- -

Fehler:

-
{{ form.non_field_errors }}
-
- {% endif %} - - - - - - - - -
-
-
-{% endblock %} diff --git a/fet2020/templates/intern/attachment/create.html b/fet2020/templates/intern/attachment/create.html new file mode 100644 index 00000000..ea8e86f0 --- /dev/null +++ b/fet2020/templates/intern/attachment/create.html @@ -0,0 +1,23 @@ +{% extends 'base.html' %} + +{% block title %}Anhang Ordner hinzufügen{% endblock %} + +{% block content %} + +
+

Anhang Ordner hinzufügen

+
+
+ {% csrf_token %} + {% include "baseform/non_field_errors.html" %} + + {% include "baseform/text.html" with field=form.title %} + {% include "baseform/body.html" with field=form.description media=form.media %} + + + + +
+
+
+{% endblock %} diff --git a/fet2020/templates/intern/attachment/attachment_detail.html b/fet2020/templates/intern/attachment/detail.html similarity index 100% rename from fet2020/templates/intern/attachment/attachment_detail.html rename to fet2020/templates/intern/attachment/detail.html diff --git a/fet2020/templates/intern/attachment/update.html b/fet2020/templates/intern/attachment/update.html new file mode 100644 index 00000000..68cf4a36 --- /dev/null +++ b/fet2020/templates/intern/attachment/update.html @@ -0,0 +1,23 @@ +{% extends 'base.html' %} + +{% block title %}{{ attachment.title }} bearbeiten{% endblock %} + +{% block content %} + +
+

Anhang Ordner '{{ attachment.title }}' bearbeiten

+
+
+ {% csrf_token %} + {% include "baseform/non_field_errors.html" %} + + {% include "baseform/text.html" with field=form.title %} + {% include "baseform/body.html" with field=form.description media=form.media %} + + + + +
+
+
+{% endblock %} diff --git a/fet2020/templates/intern/etherpad/create.html b/fet2020/templates/intern/etherpad/create.html new file mode 100644 index 00000000..abca8eaa --- /dev/null +++ b/fet2020/templates/intern/etherpad/create.html @@ -0,0 +1,23 @@ +{% extends 'base.html' %} + +{% block title %}Etherpad hinzufügen{% endblock %} + +{% block content %} + +
+

Etherpad hinzufügen

+
+
+ {% csrf_token %} + {% include "baseform/non_field_errors.html" %} + + {% include "baseform/text.html" with field=form.title %} + {% include "baseform/date.html" with field=form.date %} + + + + +
+
+
+{% endblock %} diff --git a/fet2020/templates/intern/etherpad_create.html b/fet2020/templates/intern/etherpad_create.html deleted file mode 100644 index c4df6403..00000000 --- a/fet2020/templates/intern/etherpad_create.html +++ /dev/null @@ -1,42 +0,0 @@ -{% extends 'base.html' %} - -{% block title %}Etherpad hinzufügen{% endblock %} - -{% block content %} - -
-

Etherpad hinzufügen

-
-
- {% csrf_token %} - - {% if form.non_field_errors %} -
- -

Fehler:

-
{{ form.non_field_errors }}
-
- {% endif %} - - - - - - - - -
-
-
-{% endblock %} diff --git a/fet2020/templates/intern/file_create.html b/fet2020/templates/intern/file_create.html deleted file mode 100644 index 72ddd99f..00000000 --- a/fet2020/templates/intern/file_create.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends 'base.html' %} - -{% block title %}Datei hinzufügen{% endblock %} - -{% block content %} - -
-

Datei hinzufügen

-
-
- {% csrf_token %} - - {% if form.non_field_errors %} -
- -

Fehler:

-
{{ form.non_field_errors }}
-
- {% endif %} - - - - - - - - - -
-
-
-{% endblock %} diff --git a/fet2020/templates/intern/fileupload/create.html b/fet2020/templates/intern/fileupload/create.html new file mode 100644 index 00000000..09c4a6f0 --- /dev/null +++ b/fet2020/templates/intern/fileupload/create.html @@ -0,0 +1,23 @@ +{% extends 'base.html' %} + +{% block title %}Datei hinzufügen{% endblock %} + +{% block content %} + +
+

Datei hinzufügen

+
+
+ {% csrf_token %} + {% include "baseform/non_field_errors.html" %} + + {% include "baseform/file.html" with field=form.file_field %} + {% include "baseform/text.html" with field=form.title %} + + + + +
+
+
+{% endblock %} diff --git a/fet2020/templates/intern/topic/create.html b/fet2020/templates/intern/topic/create.html new file mode 100644 index 00000000..ad18b9d8 --- /dev/null +++ b/fet2020/templates/intern/topic/create.html @@ -0,0 +1,23 @@ +{% extends 'base.html' %} + +{% block title %}Neues Thema hinzufügen{% endblock %} + +{% block content %} + +
+

neues Thema hinzufügen

+
+
+ {% csrf_token %} + {% include "baseform/non_field_errors.html" %} + + {% include "baseform/text.html" with field=form.title %} + {% include "baseform/body.html" with field=form.description media=form.media %} + + + + +
+
+
+{% endblock %} diff --git a/fet2020/templates/intern/topic/topic_detail.html b/fet2020/templates/intern/topic/detail.html similarity index 100% rename from fet2020/templates/intern/topic/topic_detail.html rename to fet2020/templates/intern/topic/detail.html diff --git a/fet2020/templates/intern/topic/topic_create.html b/fet2020/templates/intern/topic/topic_create.html deleted file mode 100644 index 306f6975..00000000 --- a/fet2020/templates/intern/topic/topic_create.html +++ /dev/null @@ -1,48 +0,0 @@ -{% extends 'base.html' %} - -{% block title %}Neues Thema hinzufügen{% endblock %} - -{% block content %} - -
-

neues Thema hinzufügen

-
-
- {% csrf_token %} - - {% if form.non_field_errors %} -
- -

Fehler:

-
{{ form.non_field_errors }}
-
- {% endif %} - - - - - - - - -
-
-
-{% endblock %} diff --git a/fet2020/templates/intern/topic/topic_update.html b/fet2020/templates/intern/topic/topic_update.html deleted file mode 100644 index 88a225f7..00000000 --- a/fet2020/templates/intern/topic/topic_update.html +++ /dev/null @@ -1,51 +0,0 @@ -{% extends 'base.html' %} - -{% block title %}{{ topic.title }} bearbeiten{% endblock %} - -{% block content %} - -
-

Thema '{{ topic.title }}' bearbeiten

-
-
- {% csrf_token %} - - {% if form.non_field_errors %} -
- -

Fehler:

-
{{ form.non_field_errors }}
-
- {% endif %} - - - - - - - - -
-
-
-{% endblock %} diff --git a/fet2020/templates/intern/topic/update.html b/fet2020/templates/intern/topic/update.html new file mode 100644 index 00000000..72516f93 --- /dev/null +++ b/fet2020/templates/intern/topic/update.html @@ -0,0 +1,27 @@ +{% extends 'base.html' %} + +{% block title %}{{ topic.title }} bearbeiten{% endblock %} + +{% block content %} + +
+

Thema '{{ topic.title }}' bearbeiten

+
+
+ {% csrf_token %} + + {% include "baseform/non_field_errors.html" %} + + {% include "baseform/text.html" with field=form.title %} + {% include "baseform/body.html" with field=form.description media=form.media %} + + + + +
+
+
+{% endblock %}