rename to attachment

This commit is contained in:
2022-03-17 16:40:19 +00:00
parent c818e91050
commit 206a71fb6f
12 changed files with 105 additions and 105 deletions

View File

@@ -15,14 +15,14 @@ from documents.etherpadlib import add_ep_cookie
from tasks.forms import InternTaskCreateForm
from tasks.models import Task
from .forms import (
DocumentationCreateForm,
DocumentationUpdateForm,
AttachmentCreateForm,
AttachmentUpdateForm,
EtherpadForm,
FileUploadForm,
TopicCreateForm,
TopicUpdateForm,
)
from .models import TopicGroup, Topic, Documentation, Etherpad, FileUpload
from .models import TopicGroup, Topic, Attachment, Etherpad, FileUpload
logger = logging.getLogger(__name__)
@@ -50,7 +50,7 @@ def show_topic(request, slug=None):
if not active_topic:
raise Http404("wrong topic")
docu = Documentation.objects.filter(topic__slug=slug).order_by("title")
attachments = Attachment.objects.filter(topic__slug=slug).order_by("title")
tasks = None
if active_topic.task_list:
@@ -65,7 +65,7 @@ def show_topic(request, slug=None):
context = {
"active_topic": active_topic,
"docus": docu,
"attachments": attachments,
"tasks": tasks,
}
@@ -73,12 +73,12 @@ def show_topic(request, slug=None):
@authenticated_user
def show_docu(request, topic_slug=None, slug=None):
active_docu = Documentation.objects.filter(
def show_attachment(request, topic_slug=None, slug=None):
attachment = Attachment.objects.filter(
Q(topic__slug=topic_slug) & Q(slug=slug)
).first()
if not active_docu:
raise Http404("wrong docu")
if not attachment:
raise Http404("wrong attachment")
active_topic = Topic.objects.filter(slug=topic_slug).first()
@@ -106,20 +106,20 @@ def show_docu(request, topic_slug=None, slug=None):
messages.info(request, "; ".join(elem))
initial = {
"documentation": active_docu,
"attachment": attachment,
}
form_add_etherpad = EtherpadForm(initial=initial)
form_add_file = FileUploadForm(initial=initial)
files = FileUpload.objects.filter(documentation=active_docu)
files = FileUpload.objects.filter(attachment=attachment)
docus = Etherpad.objects.filter(documentation=active_docu).order_by("-date")
etherpads = deque([])
etherpads = Etherpad.objects.filter(attachment=attachment).order_by("-date")
etherpad_list = deque([])
# list of etherpad url-link of any etherpads
for elem in docus:
etherpads.append(
for elem in etherpads:
etherpad_list.append(
{
"title": elem.title,
"date": elem.date,
@@ -131,12 +131,12 @@ def show_docu(request, topic_slug=None, slug=None):
"form_add_etherpad": form_add_etherpad,
"form_add_file": form_add_file,
"active_topic": active_topic,
"active_docu": active_docu,
"documents": etherpads,
"attachment": attachment,
"etherpads": etherpad_list,
"files": files,
}
response = render(request, "intern/docu.html", context)
response = render(request, "intern/attachment.html", context)
try:
response = add_ep_cookie(request, response)
@@ -200,10 +200,10 @@ class TopicUpdateView(LoginRequiredMixin, UpdateView):
return reverse("intern:topic", kwargs=context)
class DocumentationCreateView(LoginRequiredMixin, CreateView):
model = Documentation
template_name = "intern/docu/docu_create.html"
form_class = DocumentationCreateForm
class AttachmentCreateView(LoginRequiredMixin, CreateView):
model = Attachment
template_name = "intern/attachment/attachment_create.html"
form_class = AttachmentCreateForm
slug = None
@@ -230,10 +230,10 @@ class DocumentationCreateView(LoginRequiredMixin, CreateView):
return reverse("intern:topic", kwargs=context)
class DocumentationUpdateView(LoginRequiredMixin, UpdateView):
model = Documentation
template_name = "intern/docu/docu_update.html"
form_class = DocumentationUpdateForm
class AttachmentUpdateView(LoginRequiredMixin, UpdateView):
model = Attachment
template_name = "intern/attachment/attachment_update.html"
form_class = AttachmentUpdateForm
topic_slug = None
slug = None
@@ -248,9 +248,9 @@ class DocumentationUpdateView(LoginRequiredMixin, UpdateView):
self.topic_slug = self.kwargs.get("topic_slug")
self.slug = self.kwargs.get("slug")
active_docu = Documentation.objects.filter(slug=self.slug).first()
attachment = Attachment.objects.filter(slug=self.slug).first()
context = {
"documentation": active_docu,
"attachment": attachment,
}
return context
@@ -261,7 +261,7 @@ class DocumentationUpdateView(LoginRequiredMixin, UpdateView):
"slug": self.slug,
}
return reverse("intern:docu", kwargs=context)
return reverse("intern:attachment", kwargs=context)
class EtherpadCreateView(LoginRequiredMixin, CreateView):
@@ -282,9 +282,9 @@ class EtherpadCreateView(LoginRequiredMixin, CreateView):
self.topic_slug = self.kwargs.get("topic_slug")
self.slug = self.kwargs.get("slug")
active_docu = Documentation.objects.filter(slug=self.slug).first()
attachment = Attachment.objects.filter(slug=self.slug).first()
context = {
"documentation": active_docu,
"attachment": attachment,
}
return context
@@ -295,7 +295,7 @@ class EtherpadCreateView(LoginRequiredMixin, CreateView):
"slug": self.slug,
}
return reverse("intern:docu", kwargs=context)
return reverse("intern:attachment", kwargs=context)
class FileUploadCreateView(LoginRequiredMixin, CreateView):
@@ -317,9 +317,9 @@ class FileUploadCreateView(LoginRequiredMixin, CreateView):
self.topic_slug = self.kwargs.get("topic_slug")
self.slug = self.kwargs.get("slug")
active_docu = Documentation.objects.filter(slug=self.kwargs.get("slug")).first()
attachment = Attachment.objects.filter(slug=self.kwargs.get("slug")).first()
context = {
"documentation": active_docu,
"attachment": attachment,
}
return context
@@ -330,7 +330,7 @@ class FileUploadCreateView(LoginRequiredMixin, CreateView):
"slug": self.slug,
}
return reverse("intern:docu", kwargs=context)
return reverse("intern:attachment", kwargs=context)
class TaskCreateView(LoginRequiredMixin, CreateView):