diff --git a/forum/models.py b/forum/models.py index 875dbe3c..75d4404d 100644 --- a/forum/models.py +++ b/forum/models.py @@ -143,6 +143,12 @@ class Forum(models.Model): def __str__(self): return "%s" % (self.name) + def get_full_name(self): + name = '' + for parent in self.get_parent_list(): + name += parent.name + '/' + return name + self.name + def get_absolute_url(self): return reverse('forum:view_forum', kwargs={'forum_id': self.id}) diff --git a/forum/templates/forum/forum.jinja b/forum/templates/forum/forum.jinja index 426160ff..89a0e3a7 100644 --- a/forum/templates/forum/forum.jinja +++ b/forum/templates/forum/forum.jinja @@ -16,7 +16,7 @@
- {% if user.is_in_group(settings.SITH_GROUP_FORUM_ADMIN_ID) or user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) %}
+ {% if user.is_in_group(settings.SITH_GROUP_FORUM_ADMIN_ID) or user.is_in_group(settings.SITH_GROUP_COM_ADMIN_ID) or user.can_edit(forum) %}
{% trans %}New forum{% endtrans %}
{% endif %}
{% if not forum.is_category %}
diff --git a/forum/views.py b/forum/views.py
index 2ecd2f19..73f8423c 100644
--- a/forum/views.py
+++ b/forum/views.py
@@ -71,6 +71,7 @@ class ForumFavoriteTopics(ListView):
topic_list = self.request.user.favorite_topics.all()
return topic_list
+
class ForumLastUnread(ListView):
model = ForumTopic
template_name = "forum/last_unread.jinja"
@@ -85,12 +86,18 @@ class ForumLastUnread(ListView):
return topic_list
+class ForumNameField(forms.ModelChoiceField):
+ def label_from_instance(self, obj):
+ return obj.get_full_name()
+
+
class ForumForm(forms.ModelForm):
class Meta:
model = Forum
fields = ['name', 'parent', 'number', 'owner_club', 'is_category', 'edit_groups', 'view_groups']
edit_groups = make_ajax_field(Forum, 'edit_groups', 'groups', help_text="")
view_groups = make_ajax_field(Forum, 'view_groups', 'groups', help_text="")
+ parent = ForumNameField(Forum.objects.all())
class ForumCreateView(CanCreateMixin, CreateView):