fix unique between attachment and topic
This commit is contained in:
@@ -156,7 +156,7 @@ class TopicCreateView(LoginRequiredMixin, CreateView):
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
|
||||
topic_group = TopicGroup.objects.filter(slug=self.slug).first()
|
||||
context["topic_group"] = topic_group
|
||||
|
||||
@@ -165,6 +165,7 @@ class TopicCreateView(LoginRequiredMixin, CreateView):
|
||||
def get_initial(self):
|
||||
self.slug = self.kwargs.get("topic_group")
|
||||
|
||||
|
||||
class TopicUpdateView(LoginRequiredMixin, UpdateView):
|
||||
model = Topic
|
||||
template_name = "intern/topic/topic_update.html"
|
||||
@@ -175,7 +176,7 @@ class TopicUpdateView(LoginRequiredMixin, UpdateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["slug"] = self.slug
|
||||
|
||||
|
||||
topic = Topic.objects.filter(slug=self.slug).first()
|
||||
context["topic"] = topic
|
||||
|
||||
@@ -202,9 +203,9 @@ class AttachmentCreateView(LoginRequiredMixin, CreateView):
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context["slug"] = self.slug
|
||||
|
||||
|
||||
topic = Topic.objects.filter(slug=self.slug).first()
|
||||
context["topic"]= topic
|
||||
context["topic"] = topic
|
||||
|
||||
return context
|
||||
|
||||
@@ -232,7 +233,9 @@ class AttachmentUpdateView(LoginRequiredMixin, UpdateView):
|
||||
context["topic_slug"] = self.topic_slug
|
||||
context["slug"] = self.slug
|
||||
|
||||
attachment = Attachment.objects.filter(slug=self.slug).first()
|
||||
attachment = Attachment.objects.filter(
|
||||
Q(slug=self.slug) & Q(topic__slug=self.topic_slug)
|
||||
).first()
|
||||
context["attachment"] = attachment
|
||||
return context
|
||||
|
||||
@@ -266,7 +269,9 @@ class EtherpadCreateView(LoginRequiredMixin, CreateView):
|
||||
context["topic_slug"] = self.topic_slug
|
||||
context["slug"] = self.slug
|
||||
|
||||
attachment = Attachment.objects.filter(slug=self.slug).first()
|
||||
attachment = Attachment.objects.filter(
|
||||
Q(slug=self.slug) & Q(topic__slug=self.topic_slug)
|
||||
).first()
|
||||
context["attachment"] = attachment
|
||||
|
||||
return context
|
||||
@@ -298,7 +303,9 @@ class FileUploadCreateView(LoginRequiredMixin, CreateView):
|
||||
context["topic_slug"] = self.topic_slug
|
||||
context["slug"] = self.slug
|
||||
|
||||
attachment = Attachment.objects.filter(slug=self.kwargs.get("slug")).first()
|
||||
attachment = Attachment.objects.filter(
|
||||
Q(slug=self.slug) & Q(topic__slug=self.topic_slug)
|
||||
).first()
|
||||
context["attachment"] = attachment
|
||||
|
||||
return context
|
||||
|
||||
Reference in New Issue
Block a user