Commit 443616a7 authored by Sli's avatar Sli

Forum permission fix and form display

parent afa9bd87
Pipeline #1480 passed with stage
in 12 minutes and 2 seconds
...@@ -143,6 +143,12 @@ class Forum(models.Model): ...@@ -143,6 +143,12 @@ class Forum(models.Model):
def __str__(self): def __str__(self):
return "%s" % (self.name) 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): def get_absolute_url(self):
return reverse('forum:view_forum', kwargs={'forum_id': self.id}) return reverse('forum:view_forum', kwargs={'forum_id': self.id})
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<div id="forum"> <div id="forum">
<h3>{{ forum.name }}</h3> <h3>{{ forum.name }}</h3>
<p> <p>
{% 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) %}
<a class="ib button" href="{{ url('forum:new_forum') }}?parent={{ forum.id }}">{% trans %}New forum{% endtrans %}</a> <br/> <a class="ib button" href="{{ url('forum:new_forum') }}?parent={{ forum.id }}">{% trans %}New forum{% endtrans %}</a> <br/>
{% endif %} {% endif %}
{% if not forum.is_category %} {% if not forum.is_category %}
......
...@@ -71,6 +71,7 @@ class ForumFavoriteTopics(ListView): ...@@ -71,6 +71,7 @@ class ForumFavoriteTopics(ListView):
topic_list = self.request.user.favorite_topics.all() topic_list = self.request.user.favorite_topics.all()
return topic_list return topic_list
class ForumLastUnread(ListView): class ForumLastUnread(ListView):
model = ForumTopic model = ForumTopic
template_name = "forum/last_unread.jinja" template_name = "forum/last_unread.jinja"
...@@ -85,12 +86,18 @@ class ForumLastUnread(ListView): ...@@ -85,12 +86,18 @@ class ForumLastUnread(ListView):
return topic_list return topic_list
class ForumNameField(forms.ModelChoiceField):
def label_from_instance(self, obj):
return obj.get_full_name()
class ForumForm(forms.ModelForm): class ForumForm(forms.ModelForm):
class Meta: class Meta:
model = Forum model = Forum
fields = ['name', 'parent', 'number', 'owner_club', 'is_category', 'edit_groups', 'view_groups'] fields = ['name', 'parent', 'number', 'owner_club', 'is_category', 'edit_groups', 'view_groups']
edit_groups = make_ajax_field(Forum, 'edit_groups', 'groups', help_text="") edit_groups = make_ajax_field(Forum, 'edit_groups', 'groups', help_text="")
view_groups = make_ajax_field(Forum, 'view_groups', 'groups', help_text="") view_groups = make_ajax_field(Forum, 'view_groups', 'groups', help_text="")
parent = ForumNameField(Forum.objects.all())
class ForumCreateView(CanCreateMixin, CreateView): class ForumCreateView(CanCreateMixin, CreateView):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment