change slug to slugify of title or uuid + title
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.db.models import F
|
from django.db.models import F
|
||||||
|
|
||||||
from .models import TopicGroup, Topic, Attachment, Etherpad, FileUpload
|
|
||||||
from .forms import (
|
from .forms import (
|
||||||
TopicGroupAdminForm,
|
TopicGroupAdminForm,
|
||||||
TopicAdminForm,
|
TopicAdminForm,
|
||||||
@@ -13,38 +12,38 @@ from .forms import (
|
|||||||
EtherpadInlineForm,
|
EtherpadInlineForm,
|
||||||
FileUploadInlineForm,
|
FileUploadInlineForm,
|
||||||
)
|
)
|
||||||
|
from .models import TopicGroup, Topic, Attachment, Etherpad, FileUpload
|
||||||
|
|
||||||
|
|
||||||
class TopicInline(admin.TabularInline):
|
class TopicInline(admin.TabularInline):
|
||||||
model = Topic
|
|
||||||
form = TopicInlineForm
|
form = TopicInlineForm
|
||||||
|
model = Topic
|
||||||
extra = 0
|
extra = 0
|
||||||
|
show_change_link = True
|
||||||
verbose_name = "Thema"
|
verbose_name = "Thema"
|
||||||
verbose_name_plural = "Themen"
|
verbose_name_plural = "Themen"
|
||||||
show_change_link = True
|
|
||||||
readonly_fields = ("slug",)
|
|
||||||
|
|
||||||
|
|
||||||
class AttachmentInline(admin.TabularInline):
|
class AttachmentInline(admin.TabularInline):
|
||||||
model = Attachment
|
|
||||||
form = AttachmentInlineForm
|
form = AttachmentInlineForm
|
||||||
|
model = Attachment
|
||||||
extra = 0
|
extra = 0
|
||||||
|
show_change_link = True
|
||||||
verbose_name = "Anhang Ordner"
|
verbose_name = "Anhang Ordner"
|
||||||
verbose_name_plural = "Anhang Ordner"
|
verbose_name_plural = "Anhang Ordner"
|
||||||
readonly_fields = ("slug",)
|
|
||||||
|
|
||||||
|
|
||||||
class EtherpadInline(admin.TabularInline):
|
class EtherpadInline(admin.TabularInline):
|
||||||
model = Etherpad
|
|
||||||
form = EtherpadInlineForm
|
form = EtherpadInlineForm
|
||||||
|
model = Etherpad
|
||||||
extra = 0
|
extra = 0
|
||||||
verbose_name = "Etherpad"
|
verbose_name = "Etherpad"
|
||||||
verbose_name_plural = "Etherpads"
|
verbose_name_plural = "Etherpads"
|
||||||
|
|
||||||
|
|
||||||
class FileUploadInline(admin.TabularInline):
|
class FileUploadInline(admin.TabularInline):
|
||||||
model = FileUpload
|
|
||||||
form = FileUploadInlineForm
|
form = FileUploadInlineForm
|
||||||
|
model = FileUpload
|
||||||
extra = 0
|
extra = 0
|
||||||
verbose_name = "Datei"
|
verbose_name = "Datei"
|
||||||
verbose_name_plural = "Dateien"
|
verbose_name_plural = "Dateien"
|
||||||
@@ -53,9 +52,11 @@ class FileUploadInline(admin.TabularInline):
|
|||||||
class TopicGroupAdmin(admin.ModelAdmin):
|
class TopicGroupAdmin(admin.ModelAdmin):
|
||||||
form = TopicGroupAdminForm
|
form = TopicGroupAdminForm
|
||||||
model = TopicGroup
|
model = TopicGroup
|
||||||
search_fields = ("title",)
|
|
||||||
|
|
||||||
readonly_fields = ("slug",)
|
list_display = ["title", "order"]
|
||||||
|
search_fields = ("title",)
|
||||||
|
ordering = [F("order").asc(nulls_last=True)]
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(
|
(
|
||||||
None,
|
None,
|
||||||
@@ -70,11 +71,8 @@ class TopicGroupAdmin(admin.ModelAdmin):
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
inlines = (TopicInline,)
|
inlines = (TopicInline,)
|
||||||
|
readonly_fields = ("slug",)
|
||||||
list_display = ["title", "order"]
|
|
||||||
ordering = [F("order").asc(nulls_last=True)]
|
|
||||||
|
|
||||||
def add_view(self, request, form_url="", extra_context=None):
|
def add_view(self, request, form_url="", extra_context=None):
|
||||||
extra_context = extra_context or {}
|
extra_context = extra_context or {}
|
||||||
@@ -103,17 +101,18 @@ class TopicGroupAdmin(admin.ModelAdmin):
|
|||||||
class TopicAdmin(admin.ModelAdmin):
|
class TopicAdmin(admin.ModelAdmin):
|
||||||
form = TopicAdminForm
|
form = TopicAdminForm
|
||||||
model = Topic
|
model = Topic
|
||||||
search_fields = ("title",)
|
|
||||||
|
|
||||||
readonly_fields = ("slug",)
|
list_display = ["title", "topic_group", "archive"]
|
||||||
|
list_filter = ["topic_group", "archive"]
|
||||||
|
search_fields = ("title",)
|
||||||
|
ordering = ["archive"]
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(
|
(
|
||||||
None,
|
None,
|
||||||
{
|
{
|
||||||
"fields": (
|
"fields": (
|
||||||
"title",
|
"title",
|
||||||
"shortterm",
|
|
||||||
"slug",
|
|
||||||
"topic_group",
|
"topic_group",
|
||||||
"task_list",
|
"task_list",
|
||||||
"archive",
|
"archive",
|
||||||
@@ -124,10 +123,6 @@ class TopicAdmin(admin.ModelAdmin):
|
|||||||
)
|
)
|
||||||
inlines = (AttachmentInline,)
|
inlines = (AttachmentInline,)
|
||||||
|
|
||||||
list_filter = ["topic_group", "archive"]
|
|
||||||
list_display = ["title", "topic_group", "archive"]
|
|
||||||
ordering = ["archive"]
|
|
||||||
|
|
||||||
def add_view(self, request, form_url="", extra_context=None):
|
def add_view(self, request, form_url="", extra_context=None):
|
||||||
extra_context = extra_context or {}
|
extra_context = extra_context or {}
|
||||||
extra_context["help_text"] = "Fette Schriften sind Pflichtfelder."
|
extra_context["help_text"] = "Fette Schriften sind Pflichtfelder."
|
||||||
@@ -156,32 +151,25 @@ class AttachmentAdmin(admin.ModelAdmin):
|
|||||||
form = AttachmentAdminForm
|
form = AttachmentAdminForm
|
||||||
model = Attachment
|
model = Attachment
|
||||||
|
|
||||||
readonly_fields = ("slug",)
|
list_display = ["title", "topic"]
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(
|
(
|
||||||
None,
|
None,
|
||||||
{
|
{
|
||||||
"fields": (
|
"fields": (
|
||||||
"title",
|
"title",
|
||||||
"shortterm",
|
|
||||||
"slug",
|
|
||||||
"topic",
|
"topic",
|
||||||
"description",
|
"description",
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
inlines = (
|
inlines = (
|
||||||
EtherpadInline,
|
EtherpadInline,
|
||||||
FileUploadInline,
|
FileUploadInline,
|
||||||
)
|
)
|
||||||
|
|
||||||
list_display = [
|
|
||||||
"title",
|
|
||||||
"topic",
|
|
||||||
]
|
|
||||||
|
|
||||||
def add_view(self, request, form_url="", extra_context=None):
|
def add_view(self, request, form_url="", extra_context=None):
|
||||||
extra_context = extra_context or {}
|
extra_context = extra_context or {}
|
||||||
extra_context["help_text"] = "Fette Schriften sind Pflichtfelder."
|
extra_context["help_text"] = "Fette Schriften sind Pflichtfelder."
|
||||||
@@ -210,14 +198,8 @@ class EtherpadAdmin(admin.ModelAdmin):
|
|||||||
form = EtherpadAdminForm
|
form = EtherpadAdminForm
|
||||||
model = Etherpad
|
model = Etherpad
|
||||||
|
|
||||||
list_filter = [
|
list_display = ["title", "date", "attachment"]
|
||||||
"attachment",
|
list_filter = ["attachment"]
|
||||||
]
|
|
||||||
list_display = [
|
|
||||||
"title",
|
|
||||||
"date",
|
|
||||||
"attachment",
|
|
||||||
]
|
|
||||||
ordering = ["-date"]
|
ordering = ["-date"]
|
||||||
|
|
||||||
def add_view(self, request, form_url="", extra_context=None):
|
def add_view(self, request, form_url="", extra_context=None):
|
||||||
@@ -248,13 +230,8 @@ class FileUploadAdmin(admin.ModelAdmin):
|
|||||||
form = FileUploadAdminForm
|
form = FileUploadAdminForm
|
||||||
model = FileUpload
|
model = FileUpload
|
||||||
|
|
||||||
list_filter = [
|
list_display = ["title", "attachment"]
|
||||||
"attachment",
|
list_filter = ["attachment"]
|
||||||
]
|
|
||||||
list_display = [
|
|
||||||
"title",
|
|
||||||
"attachment",
|
|
||||||
]
|
|
||||||
|
|
||||||
def add_view(self, request, form_url="", extra_context=None):
|
def add_view(self, request, form_url="", extra_context=None):
|
||||||
extra_context = extra_context or {}
|
extra_context = extra_context or {}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
|
from ckeditor.widgets import CKEditorWidget
|
||||||
from ckeditor_uploader.widgets import CKEditorUploadingWidget
|
from ckeditor_uploader.widgets import CKEditorUploadingWidget
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.forms.widgets import HiddenInput
|
from django.forms.widgets import HiddenInput
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
@@ -23,10 +25,6 @@ class TopicGroupAdminForm(forms.ModelForm):
|
|||||||
"short_description": _("Kurzbeschreibung"),
|
"short_description": _("Kurzbeschreibung"),
|
||||||
}
|
}
|
||||||
|
|
||||||
help_texts = {
|
|
||||||
"shortterm": _("max. 10 Zeichen erlaubt."),
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class TopicAdminForm(forms.ModelForm):
|
class TopicAdminForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -35,16 +33,11 @@ class TopicAdminForm(forms.ModelForm):
|
|||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
"shortterm": _("Kürzel für Link"),
|
|
||||||
"slug": _("Permalink"),
|
"slug": _("Permalink"),
|
||||||
"task_list": _("Aufgabenbereich"),
|
"task_list": _("Aufgabenbereich"),
|
||||||
"description": _("Beschreibung"),
|
"description": _("Beschreibung"),
|
||||||
}
|
}
|
||||||
|
|
||||||
help_texts = {
|
|
||||||
"shortterm": _("max. 10 Zeichen erlaubt."),
|
|
||||||
}
|
|
||||||
|
|
||||||
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
|
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
|
||||||
|
|
||||||
|
|
||||||
@@ -55,15 +48,11 @@ class AttachmentAdminForm(forms.ModelForm):
|
|||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
"shortterm": _("Kürzel für Link"),
|
|
||||||
"slug": _("Permalink"),
|
"slug": _("Permalink"),
|
||||||
|
"topic": _("Thema"),
|
||||||
"description": _("Beschreibung"),
|
"description": _("Beschreibung"),
|
||||||
}
|
}
|
||||||
|
|
||||||
help_texts = {
|
|
||||||
"shortterm": _("max. 10 Zeichen erlaubt."),
|
|
||||||
}
|
|
||||||
|
|
||||||
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
|
widgets = {"description": CKEditorUploadingWidget(config_name="default")}
|
||||||
|
|
||||||
|
|
||||||
@@ -76,6 +65,11 @@ class EtherpadAdminForm(forms.ModelForm):
|
|||||||
"attachment",
|
"attachment",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
labels = {
|
||||||
|
"title": _("Titel"),
|
||||||
|
"attachment": _("Anhang Ordner"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class FileUploadAdminForm(forms.ModelForm):
|
class FileUploadAdminForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -86,20 +80,21 @@ class FileUploadAdminForm(forms.ModelForm):
|
|||||||
"attachment",
|
"attachment",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
labels = {
|
||||||
|
"title": _("Titel"),
|
||||||
|
"attachment": _("Anhang Ordner"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class TopicInlineForm(forms.ModelForm):
|
class TopicInlineForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Topic
|
model = Topic
|
||||||
fields = [
|
fields = [
|
||||||
"title",
|
"title",
|
||||||
"shortterm",
|
|
||||||
"slug",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
"shortterm": _("Kürzel für Link"),
|
|
||||||
"slug": _("Permalink"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -108,14 +103,10 @@ class AttachmentInlineForm(forms.ModelForm):
|
|||||||
model = Attachment
|
model = Attachment
|
||||||
fields = [
|
fields = [
|
||||||
"title",
|
"title",
|
||||||
"shortterm",
|
|
||||||
"slug",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
"shortterm": _("Kürzel für Link"),
|
|
||||||
"slug": _("Permalink"),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -152,18 +143,17 @@ class TopicCreateForm(forms.ModelForm):
|
|||||||
model = Topic
|
model = Topic
|
||||||
fields = [
|
fields = [
|
||||||
"title",
|
"title",
|
||||||
"shortterm",
|
|
||||||
"description",
|
"description",
|
||||||
"topic_group",
|
"topic_group",
|
||||||
]
|
]
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
"shortterm": _("Kürzel für den Link"),
|
|
||||||
"description": _("Beschreibung"),
|
"description": _("Beschreibung"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"description": CKEditorWidget(config_name="intern"),
|
||||||
"topic_group": HiddenInput,
|
"topic_group": HiddenInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,18 +163,17 @@ class TopicUpdateForm(forms.ModelForm):
|
|||||||
model = Topic
|
model = Topic
|
||||||
fields = [
|
fields = [
|
||||||
"title",
|
"title",
|
||||||
"shortterm",
|
|
||||||
"description",
|
"description",
|
||||||
"topic_group",
|
"topic_group",
|
||||||
]
|
]
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
"shortterm": _("Kürzel für den Link"),
|
|
||||||
"description": _("Beschreibung"),
|
"description": _("Beschreibung"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"description": CKEditorWidget(config_name="intern"),
|
||||||
"topic_group": HiddenInput,
|
"topic_group": HiddenInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,18 +184,17 @@ class AttachmentCreateForm(forms.ModelForm):
|
|||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
"title",
|
"title",
|
||||||
"shortterm",
|
|
||||||
"description",
|
"description",
|
||||||
"topic",
|
"topic",
|
||||||
]
|
]
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
"shortterm": _("Kürzel für den Link"),
|
|
||||||
"description": _("Beschreibung"),
|
"description": _("Beschreibung"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"description": CKEditorWidget(config_name="intern"),
|
||||||
"topic": HiddenInput,
|
"topic": HiddenInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,18 +205,17 @@ class AttachmentUpdateForm(forms.ModelForm):
|
|||||||
|
|
||||||
fields = [
|
fields = [
|
||||||
"title",
|
"title",
|
||||||
"shortterm",
|
|
||||||
"description",
|
"description",
|
||||||
"topic",
|
"topic",
|
||||||
]
|
]
|
||||||
|
|
||||||
labels = {
|
labels = {
|
||||||
"title": _("Titel"),
|
"title": _("Titel"),
|
||||||
"shortterm": _("Kürzel für den Link"),
|
|
||||||
"description": _("Beschreibung"),
|
"description": _("Beschreibung"),
|
||||||
}
|
}
|
||||||
|
|
||||||
widgets = {
|
widgets = {
|
||||||
|
"description": CKEditorWidget(config_name="intern"),
|
||||||
"topic": HiddenInput,
|
"topic": HiddenInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
# Generated by Django 4.0.3 on 2022-04-20 20:55
|
# Generated by Django 4.0.6 on 2022-07-30 16:33
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
import fet2020.utils
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@@ -10,7 +11,7 @@ class Migration(migrations.Migration):
|
|||||||
initial = True
|
initial = True
|
||||||
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
('tasks', '0002_slug'),
|
('tasks', '0002_alter_task_options_task_slug_task_slug_id_and_more'),
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
@@ -19,8 +20,7 @@ class Migration(migrations.Migration):
|
|||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('title', models.CharField(max_length=128, verbose_name='Titel')),
|
('title', models.CharField(max_length=128, verbose_name='Titel')),
|
||||||
('shortterm', models.CharField(max_length=10)),
|
('slug', models.SlugField()),
|
||||||
('slug', models.SlugField(max_length=10)),
|
|
||||||
('description', models.TextField(blank=True, null=True)),
|
('description', models.TextField(blank=True, null=True)),
|
||||||
],
|
],
|
||||||
options={
|
options={
|
||||||
@@ -33,8 +33,8 @@ class Migration(migrations.Migration):
|
|||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('title', models.CharField(max_length=128, verbose_name='Titel')),
|
('title', models.CharField(max_length=128, verbose_name='Titel')),
|
||||||
('shortterm', models.CharField(max_length=10, unique=True)),
|
('shortterm', models.CharField(blank=True, max_length=128, unique=True)),
|
||||||
('slug', models.SlugField(max_length=10, unique=True)),
|
('slug', models.SlugField(unique=True)),
|
||||||
('short_description', models.TextField(blank=True, null=True)),
|
('short_description', models.TextField(blank=True, null=True)),
|
||||||
('order', models.PositiveSmallIntegerField(blank=True, null=True, unique=True, verbose_name='Reihenfolge')),
|
('order', models.PositiveSmallIntegerField(blank=True, null=True, unique=True, verbose_name='Reihenfolge')),
|
||||||
],
|
],
|
||||||
@@ -48,8 +48,7 @@ class Migration(migrations.Migration):
|
|||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('title', models.CharField(max_length=128, verbose_name='Titel')),
|
('title', models.CharField(max_length=128, verbose_name='Titel')),
|
||||||
('shortterm', models.CharField(max_length=10, unique=True)),
|
('slug', models.SlugField()),
|
||||||
('slug', models.SlugField(max_length=10, unique=True)),
|
|
||||||
('archive', models.BooleanField(default=False, verbose_name='Archiv')),
|
('archive', models.BooleanField(default=False, verbose_name='Archiv')),
|
||||||
('description', models.TextField(blank=True, null=True)),
|
('description', models.TextField(blank=True, null=True)),
|
||||||
('task_list', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='tasks.tasklist')),
|
('task_list', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='tasks.tasklist')),
|
||||||
@@ -79,7 +78,7 @@ class Migration(migrations.Migration):
|
|||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('title', models.CharField(max_length=128, verbose_name='Titel')),
|
('title', models.CharField(max_length=128, verbose_name='Titel')),
|
||||||
('slug', models.SlugField(blank=True, null=True)),
|
('slug_id', models.CharField(default=fet2020.utils.create_random_id, editable=False, max_length=8, unique=True)),
|
||||||
('etherpad_key', models.CharField(blank=True, max_length=50)),
|
('etherpad_key', models.CharField(blank=True, max_length=50)),
|
||||||
('date', models.DateField(default=datetime.date.today, verbose_name='Datum')),
|
('date', models.DateField(default=datetime.date.today, verbose_name='Datum')),
|
||||||
('attachment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='intern.attachment')),
|
('attachment', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='intern.attachment')),
|
||||||
@@ -94,6 +93,14 @@ class Migration(migrations.Migration):
|
|||||||
name='topic',
|
name='topic',
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='intern.topic'),
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='intern.topic'),
|
||||||
),
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name='topic',
|
||||||
|
constraint=models.UniqueConstraint(fields=('slug', 'topic_group'), name='unique_intern_slug_topic_group'),
|
||||||
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name='topic',
|
||||||
|
constraint=models.UniqueConstraint(fields=('title', 'topic_group'), name='unique_intern_title_topic_group'),
|
||||||
|
),
|
||||||
migrations.AddConstraint(
|
migrations.AddConstraint(
|
||||||
model_name='etherpad',
|
model_name='etherpad',
|
||||||
constraint=models.UniqueConstraint(fields=('title', 'date', 'attachment'), name='unique_intern_etherpad'),
|
constraint=models.UniqueConstraint(fields=('title', 'date', 'attachment'), name='unique_intern_etherpad'),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ from django.utils.translation import gettext_lazy as _
|
|||||||
|
|
||||||
from documents import create_pad, get_pad_html
|
from documents import create_pad, get_pad_html
|
||||||
from documents.api import get_pad_link
|
from documents.api import get_pad_link
|
||||||
|
from fet2020.utils import create_random_id
|
||||||
from tasks.models import TaskList
|
from tasks.models import TaskList
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -20,8 +21,8 @@ logger = logging.getLogger(__name__)
|
|||||||
class TopicGroup(models.Model):
|
class TopicGroup(models.Model):
|
||||||
title = models.CharField(verbose_name="Titel", max_length=128)
|
title = models.CharField(verbose_name="Titel", max_length=128)
|
||||||
|
|
||||||
shortterm = models.CharField(max_length=10, unique=True)
|
shortterm = models.CharField(max_length=128, unique=True, blank=True)
|
||||||
slug = models.SlugField(max_length=10, unique=True)
|
slug = models.SlugField(unique=True)
|
||||||
|
|
||||||
short_description = models.TextField(null=True, blank=True)
|
short_description = models.TextField(null=True, blank=True)
|
||||||
|
|
||||||
@@ -42,24 +43,24 @@ class TopicGroup(models.Model):
|
|||||||
return reverse("intern:index") + "#" + self.slug
|
return reverse("intern:index") + "#" + self.slug
|
||||||
|
|
||||||
def clean(self, *args, **kwargs):
|
def clean(self, *args, **kwargs):
|
||||||
|
if not self.shortterm:
|
||||||
|
self.shortterm = self.title
|
||||||
self.slug = slugify(self.shortterm)
|
self.slug = slugify(self.shortterm)
|
||||||
|
|
||||||
|
|
||||||
class Topic(models.Model):
|
class Topic(models.Model):
|
||||||
title = models.CharField(verbose_name="Titel", max_length=128)
|
title = models.CharField(max_length=128, verbose_name="Titel")
|
||||||
|
slug = models.SlugField()
|
||||||
|
|
||||||
shortterm = models.CharField(max_length=10, unique=True)
|
archive = models.BooleanField(default=False, verbose_name="Archiv")
|
||||||
slug = models.SlugField(max_length=10, unique=True)
|
|
||||||
|
|
||||||
archive = models.BooleanField(verbose_name="Archiv", default=False)
|
description = models.TextField(blank=True, null=True)
|
||||||
|
|
||||||
description = models.TextField(null=True, blank=True)
|
|
||||||
|
|
||||||
topic_group = models.ForeignKey(
|
topic_group = models.ForeignKey(
|
||||||
TopicGroup, on_delete=models.CASCADE, verbose_name="Themenbereich"
|
TopicGroup, on_delete=models.CASCADE, verbose_name="Themenbereich"
|
||||||
)
|
)
|
||||||
task_list = models.ForeignKey(
|
task_list = models.ForeignKey(
|
||||||
TaskList, on_delete=models.CASCADE, null=True, blank=True
|
TaskList, blank=True, on_delete=models.CASCADE, null=True
|
||||||
)
|
)
|
||||||
|
|
||||||
objects = models.Manager()
|
objects = models.Manager()
|
||||||
@@ -68,6 +69,15 @@ class Topic(models.Model):
|
|||||||
verbose_name = "Thema"
|
verbose_name = "Thema"
|
||||||
verbose_name_plural = "Themen"
|
verbose_name_plural = "Themen"
|
||||||
|
|
||||||
|
constraints = [
|
||||||
|
UniqueConstraint(
|
||||||
|
fields=["slug", "topic_group"], name="unique_intern_slug_topic_group"
|
||||||
|
),
|
||||||
|
UniqueConstraint(
|
||||||
|
fields=["title", "topic_group"], name="unique_intern_title_topic_group"
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
@@ -75,18 +85,17 @@ class Topic(models.Model):
|
|||||||
return reverse("intern:topic", kwargs={"slug": self.slug})
|
return reverse("intern:topic", kwargs={"slug": self.slug})
|
||||||
|
|
||||||
def clean(self, *args, **kwargs):
|
def clean(self, *args, **kwargs):
|
||||||
self.slug = slugify(self.shortterm)
|
self.slug = slugify(self.title)
|
||||||
|
|
||||||
|
|
||||||
class Attachment(models.Model):
|
class Attachment(models.Model):
|
||||||
title = models.CharField(verbose_name="Titel", max_length=128)
|
title = models.CharField(max_length=128, verbose_name="Titel")
|
||||||
|
|
||||||
shortterm = models.CharField(max_length=10)
|
slug = models.SlugField()
|
||||||
slug = models.SlugField(max_length=10)
|
|
||||||
|
|
||||||
description = models.TextField(null=True, blank=True)
|
description = models.TextField(blank=True, null=True)
|
||||||
|
|
||||||
topic = models.ForeignKey(Topic, on_delete=models.CASCADE)
|
topic = models.ForeignKey(Topic, on_delete=models.CASCADE, verbose_name="Thema")
|
||||||
|
|
||||||
objects = models.Manager()
|
objects = models.Manager()
|
||||||
|
|
||||||
@@ -113,17 +122,21 @@ class Attachment(models.Model):
|
|||||||
return reverse("intern:attachment", kwargs=kwargs)
|
return reverse("intern:attachment", kwargs=kwargs)
|
||||||
|
|
||||||
def clean(self, *args, **kwargs):
|
def clean(self, *args, **kwargs):
|
||||||
self.slug = slugify(self.shortterm)
|
self.slug = slugify(self.title)
|
||||||
|
|
||||||
|
|
||||||
class Etherpad(models.Model):
|
class Etherpad(models.Model):
|
||||||
title = models.CharField(verbose_name="Titel", max_length=128)
|
title = models.CharField(max_length=128, verbose_name="Titel")
|
||||||
slug = models.SlugField(null=True, blank=True)
|
|
||||||
|
|
||||||
etherpad_key = models.CharField(max_length=50, blank=True)
|
slug_id = models.CharField(
|
||||||
date = models.DateField(verbose_name="Datum", default=date.today)
|
default=create_random_id, editable=False, max_length=8, unique=True
|
||||||
|
)
|
||||||
|
etherpad_key = models.CharField(blank=True, max_length=50)
|
||||||
|
date = models.DateField(default=date.today, verbose_name="Datum")
|
||||||
|
|
||||||
attachment = models.ForeignKey(Attachment, on_delete=models.CASCADE)
|
attachment = models.ForeignKey(
|
||||||
|
Attachment, on_delete=models.CASCADE, verbose_name="Anhang Ordner"
|
||||||
|
)
|
||||||
|
|
||||||
objects = models.Manager()
|
objects = models.Manager()
|
||||||
|
|
||||||
@@ -141,57 +154,43 @@ class Etherpad(models.Model):
|
|||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return get_pad_link(self.__get_pad_name())
|
return get_pad_link(self.etherpad_key)
|
||||||
|
|
||||||
def __get_pad_name(self):
|
|
||||||
return (
|
|
||||||
slugify(self.date)
|
|
||||||
+ "-"
|
|
||||||
+ self.attachment.topic.slug
|
|
||||||
+ "-"
|
|
||||||
+ self.attachment.slug
|
|
||||||
+ "-"
|
|
||||||
+ self.slug
|
|
||||||
)
|
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
self.slug = slugify(self.title)
|
pad_name = slugify(str(self.slug_id) + "-" + self.title[:40])
|
||||||
|
if len(pad_name) > 50:
|
||||||
|
raise ValidationError(
|
||||||
|
_(
|
||||||
|
"Name zum Erstellen des Etherpads ist zu lange - max. 50 Zeichen. "
|
||||||
|
"(Länge: %(length)s, Name: %(pad_name)s)"
|
||||||
|
),
|
||||||
|
params={"length": len(pad_name), "pad_name": pad_name},
|
||||||
|
)
|
||||||
|
|
||||||
|
self.etherpad_key = create_pad(pad_name)
|
||||||
if not self.etherpad_key:
|
if not self.etherpad_key:
|
||||||
pad_name = self.__get_pad_name()
|
raise ValidationError(
|
||||||
if len(pad_name) > 50:
|
_(f"Etherpad '{pad_name}' konnte nicht erstellt werden."),
|
||||||
raise ValidationError(
|
)
|
||||||
_(
|
|
||||||
"Name zum Erstellen des Etherpads ist zu lange - max. 50 Zeichen. (Länge: %(length)s, Name: %(pad_name)s)"
|
|
||||||
),
|
|
||||||
params={"length": len(pad_name), "pad_name": pad_name},
|
|
||||||
)
|
|
||||||
|
|
||||||
self.etherpad_key = create_pad(pad_name)
|
|
||||||
if not self.etherpad_key:
|
|
||||||
raise ValidationError(
|
|
||||||
_(f"Etherpad '{pad_name}' konnte nicht erstellt werden."),
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def etherpad_html(self):
|
def etherpad_html(self):
|
||||||
if not self.__get_pad_name():
|
return get_pad_html(self.etherpad_key)
|
||||||
return None
|
|
||||||
|
|
||||||
return get_pad_html(self.__get_pad_name())
|
|
||||||
|
|
||||||
def get_model_name(self):
|
def get_model_name(self):
|
||||||
return self._meta.model_name
|
return self._meta.model_name
|
||||||
|
|
||||||
|
|
||||||
class FileUpload(models.Model):
|
class FileUpload(models.Model):
|
||||||
title = models.CharField(verbose_name="Titel", max_length=128, blank=True)
|
title = models.CharField(blank=True, max_length=128, verbose_name="Titel")
|
||||||
file_field = models.FileField(
|
file_field = models.FileField(
|
||||||
verbose_name="Dokument", upload_to="uploads/intern/files/"
|
upload_to="uploads/intern/files/", verbose_name="Dokument"
|
||||||
)
|
)
|
||||||
date = models.DateField(verbose_name="Datum", default=date.today)
|
date = models.DateField(default=date.today, verbose_name="Datum")
|
||||||
|
|
||||||
attachment = models.ForeignKey(Attachment, on_delete=models.CASCADE)
|
attachment = models.ForeignKey(
|
||||||
|
Attachment, on_delete=models.CASCADE, verbose_name="Anhang Ordner"
|
||||||
|
)
|
||||||
|
|
||||||
objects = models.Manager()
|
objects = models.Manager()
|
||||||
|
|
||||||
|
|||||||
@@ -29,13 +29,14 @@
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label class="block">
|
<label class="block">
|
||||||
<span class="text-gray-700 dark:text-gray-200">{{ form.shortterm.label }}</span>
|
<span class="text-gray-700 dark:text-gray-200">{{ form.description.label }}</span>
|
||||||
{% if form.shortterm.errors %}
|
{% if form.description.errors %}
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<div class="alert-body">{{ form.shortterm.errors }}</div>
|
<div class="alert-body">{{ form.description.errors }}</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<input type="text" id="id_shortterm" name="shortterm" class="mt-1 block w-full rounded-md border-gray-300 dark:border-none shadow-sm focus:border-none focus:ring focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50" required>
|
{{ form.media }}
|
||||||
|
{{ form.description }}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<input type="hidden" name="topic" value="{{ topic.id }}" id="id_topic">
|
<input type="hidden" name="topic" value="{{ topic.id }}" id="id_topic">
|
||||||
|
|||||||
@@ -29,13 +29,14 @@
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label class="block">
|
<label class="block">
|
||||||
<span class="text-gray-700 dark:text-gray-200">{{ form.shortterm.label }}</span>
|
<span class="text-gray-700 dark:text-gray-200">{{ form.description.label }}</span>
|
||||||
{% if form.shortterm.errors %}
|
{% if form.description.errors %}
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<div class="alert-body">{{ form.shortterm.errors }}</div>
|
<div class="alert-body">{{ form.description.errors }}</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<input type="text" id="id_shortterm" name="shortterm" value="{{ attachment.shortterm }}" class="mt-1 block w-full rounded-md border-gray-300 dark:border-none shadow-sm focus:border-none focus:ring focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50" required>
|
{{ form.media }}
|
||||||
|
{{ form.description }}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<input type="hidden" name="topic" value="{{ topic.id }}" id="id_topic">
|
<input type="hidden" name="topic" value="{{ topic.id }}" id="id_topic">
|
||||||
|
|||||||
@@ -28,16 +28,6 @@
|
|||||||
<input type="text" id="id_title" name="title" class="mt-1 block w-full rounded-md border-gray-300 dark:border-none shadow-sm focus:border-none focus:ring focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50" required>
|
<input type="text" id="id_title" name="title" class="mt-1 block w-full rounded-md border-gray-300 dark:border-none shadow-sm focus:border-none focus:ring focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50" required>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label class="block">
|
|
||||||
<span class="text-gray-700 dark:text-gray-200">{{ form.shortterm.label }}</span>
|
|
||||||
{% if form.shortterm.errors %}
|
|
||||||
<div class="alert alert-danger">
|
|
||||||
<div class="alert-body">{{ form.shortterm.errors }}</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
<input type="text" id="id_shortterm" name="shortterm" class="mt-1 block w-full rounded-md border-gray-300 dark:border-none shadow-sm focus:border-none focus:ring focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50" required>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
<span class="text-gray-700 dark:text-gray-200">{{ form.due_date.label }}</span>
|
<span class="text-gray-700 dark:text-gray-200">{{ form.due_date.label }}</span>
|
||||||
<input type="date" id="id_due_date" name="due_date" class="block w-full mt-1 rounded-md border-gray-300 dark:border-none shadow-sm focus:border-none focus:ring focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50">
|
<input type="date" id="id_due_date" name="due_date" class="block w-full mt-1 rounded-md border-gray-300 dark:border-none shadow-sm focus:border-none focus:ring focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50">
|
||||||
|
|||||||
@@ -29,13 +29,14 @@
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label class="block">
|
<label class="block">
|
||||||
<span class="text-gray-700 dark:text-gray-200">{{ form.shortterm.label }}</span>
|
<span class="text-gray-700 dark:text-gray-200">{{ form.description.label }}</span>
|
||||||
{% if form.shortterm.errors %}
|
{% if form.description.errors %}
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<div class="alert-body">{{ form.shortterm.errors }}</div>
|
<div class="alert-body">{{ form.description.errors }}</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<input type="text" id="id_shortterm" name="shortterm" class="mt-1 block w-full rounded-md border-gray-300 dark:border-none shadow-sm focus:border-none focus:ring focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50" required>
|
{{ form.media }}
|
||||||
|
{{ form.description }}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<input type="hidden" name="topic_group" value="{{ topic_group.id }}" id="id_topic_group">
|
<input type="hidden" name="topic_group" value="{{ topic_group.id }}" id="id_topic_group">
|
||||||
|
|||||||
@@ -29,13 +29,14 @@
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
<label class="block">
|
<label class="block">
|
||||||
<span class="text-gray-700 dark:text-gray-200">{{ form.shortterm.label }}</span>
|
<span class="text-gray-700 dark:text-gray-200">{{ form.description.label }}</span>
|
||||||
{% if form.shortterm.errors %}
|
{% if form.description.errors %}
|
||||||
<div class="alert alert-danger">
|
<div class="alert alert-danger">
|
||||||
<div class="alert-body">{{ form.shortterm.errors }}</div>
|
<div class="alert-body">{{ form.description.errors }}</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<input type="text" id="id_shortterm" name="shortterm" value="{{ topic.shortterm }}" class="mt-1 block w-full rounded-md border-gray-300 dark:border-none shadow-sm focus:border-none focus:ring focus:ring-blue-200 dark:focus:ring-sky-700 focus:ring-opacity-50" required>
|
{{ form.media }}
|
||||||
|
{{ form.description }}
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<input type="hidden" name="topic_group" value="{{ topic.topic_group.id }}" id="id_topic_group">
|
<input type="hidden" name="topic_group" value="{{ topic.topic_group.id }}" id="id_topic_group">
|
||||||
|
|||||||
Reference in New Issue
Block a user