Browse Source

Lacking options addedd to forums admin

Ralfp 12 years ago
parent
commit
0ab0d00c70

+ 1 - 1
misago/acl/middleware.py

@@ -18,7 +18,7 @@ class ACLMiddleware(object):
         except AttributeError, InvalidCacheBackendError:
             user_acl = build_acl(request, request.user.get_roles())
             cache.set(acl_key, user_acl, 2592000)
-
+        
         request.acl = user_acl
         if request.user.is_authenticated() and (request.acl.team or request.user.is_god()) != request.user.is_team:
             request.user.is_team = (request.acl.team or request.user.is_god())

+ 30 - 5
misago/forums/forms.py

@@ -1,13 +1,15 @@
 from django.utils.translation import ugettext_lazy as _
 from django import forms
 from mptt.forms import TreeNodeChoiceField
-from misago.forms import Form
+from misago.forms import Form, YesNoSwitch
 from misago.forums.models import Forum
 
 class CategoryForm(Form):
     parent = False
     name = forms.CharField(max_length=255)
     description = forms.CharField(widget=forms.Textarea,required=False)
+    closed = forms.BooleanField(widget=YesNoSwitch,required=False)
+    style = forms.CharField(max_length=255,required=False)
     template = forms.ChoiceField(choices=(
                                           ('rows', _('One forum per row')),
                                           ('fifty', _('Two forums per row')),
@@ -16,11 +18,18 @@ class CategoryForm(Form):
     
     layout = (
               (
-               _("Category Options"),
+               _("Basic Options"),
                (
                 ('parent', {'label': _("Category Parent")}),
                 ('name', {'label': _("Category Name")}),
                 ('description', {'label': _("Category Description")}),
+                ('closed', {'label': _("Closed Category")}),
+                ),
+              ),
+              (
+               _("Display Options"),
+               (
+                ('style', {'label': _("Category Style"), 'help_text': _('You can add custom CSS classess to this category, to change way it looks on board index.')}),
                 ('template', {'label': _("Category Layout")}),
                 ),
               ),
@@ -35,6 +44,8 @@ class ForumForm(Form):
     parent = False
     name = forms.CharField(max_length=255)
     description = forms.CharField(widget=forms.Textarea,required=False)
+    closed = forms.BooleanField(widget=YesNoSwitch,required=False)
+    style = forms.CharField(max_length=255,required=False)
     template = forms.ChoiceField(choices=(
                                           ('rows', _('One forum per row')),
                                           ('fifty', _('Two forums per row')),
@@ -45,12 +56,12 @@ class ForumForm(Form):
     
     layout = (
               (
-               _("Forum Options"),
+               _("Basic Options"),
                (
                 ('parent', {'label': _("Forum Parent")}),
                 ('name', {'label': _("Forum Name")}),
                 ('description', {'label': _("Forum Description")}),
-                ('template', {'label': _("Subforums Layout")}),
+                ('closed', {'label': _("Closed Forum")}),
                 ),
               ),
               (
@@ -60,6 +71,13 @@ class ForumForm(Form):
                 ('prune_last', {'label': _("Delete threads with last post older than"), 'help_text': _('Enter number of days since since last reply in topic after which topic will be deleted or zero to don\'t delete topics.')}),
                 ),
               ),
+              (
+               _("Display Options"),
+               (
+                ('style', {'label': _("Forum Style"), 'help_text': _('You can add custom CSS classess to this forum to change way it looks on forums lists.')}),
+                ('template', {'label': _("Subforums List Layout")}),
+                ),
+              ),
              )
     
     def __init__(self, *args, **kwargs):
@@ -72,10 +90,11 @@ class RedirectForm(Form):
     name = forms.CharField(max_length=255)
     description = forms.CharField(widget=forms.Textarea,required=False)
     redirect = forms.URLField(max_length=255)
+    style = forms.CharField(max_length=255,required=False)
     
     layout = (
               (
-               _("Redirect Options"),
+               _("Basic Options"),
                (
                 ('parent', {'label': _("Redirect Parent")}),
                 ('name', {'label': _("Redirect Name")}),
@@ -83,6 +102,12 @@ class RedirectForm(Form):
                 ('description', {'label': _("Redirect Description")}),
                 ),
               ),
+              (
+               _("Display Options"),
+               (
+                ('style', {'label': _("Redirect Style"), 'help_text': _('You can add custom CSS classess to this redirect to change way it looks on forums lists.')}),
+                ),
+              ),
              )
     
     def __init__(self, *args, **kwargs):

+ 1 - 0
misago/forums/models.py

@@ -24,6 +24,7 @@ class Forum(MPTTModel):
     prune_start = models.PositiveIntegerField(default=0)
     prune_last = models.PositiveIntegerField(default=0)
     redirect = models.CharField(max_length=255, null=True, blank=True)
+    style = models.CharField(max_length=255, null=True, blank=True)
     template = models.CharField(max_length=255, null=True, blank=True)
     closed = models.BooleanField(default=False)
     

+ 10 - 0
misago/forums/views.py

@@ -84,7 +84,9 @@ class NewCategory(FormWidget):
                      name=form.cleaned_data['name'],
                      slug=slugify(form.cleaned_data['name']),
                      type='category',
+                     style=form.cleaned_data['style'],
                      template=form.cleaned_data['template'],
+                     closed=form.cleaned_data['closed'],
                      )
         new_forum.set_description(form.cleaned_data['description'])
         new_forum.insert_at(form.cleaned_data['parent'], position='last-child', save=True)
@@ -109,7 +111,9 @@ class NewForum(FormWidget):
                      name=form.cleaned_data['name'],
                      slug=slugify(form.cleaned_data['name']),
                      type='forum',
+                     style=form.cleaned_data['style'],
                      template=form.cleaned_data['template'],
+                     closed=form.cleaned_data['closed'],
                      prune_days=form.cleaned_data['prune_days'],
                      prune_start=form.cleaned_data['prune_start'],
                      )
@@ -142,6 +146,7 @@ class NewRedirect(FormWidget):
                      name=form.cleaned_data['name'],
                      slug=slugify(form.cleaned_data['name']),
                      redirect=form.cleaned_data['redirect'],
+                     style=form.cleaned_data['style'],
                      type='redirect',
                      )
         new_forum.set_description(form.cleaned_data['description'])
@@ -224,6 +229,8 @@ class Edit(FormWidget):
             initial['redirect'] = model.redirect
         else:
             initial['template'] = model.template
+            initial['style'] = model.style
+            initial['closed'] = model.closed
             
         if model.type == 'forum':
             initial['prune_start'] = model.prune_start
@@ -237,7 +244,10 @@ class Edit(FormWidget):
         if target.type == 'redirect':
             target.redirect = form.cleaned_data['redirect']
         else:
+            target.style = form.cleaned_data['style']
             target.template = form.cleaned_data['template']
+            target.closed = form.cleaned_data['closed']
+            
         if target.type == 'forum':
             target.prune_start = form.cleaned_data['prune_start']
             target.prune_last = form.cleaned_data['prune_last']

+ 4 - 0
misago/users/models.py

@@ -465,6 +465,8 @@ class Guest(object):
     """
     Misago Guest dummy
     """    
+    is_team = False
+    
     def is_anonymous(self):
         return True
     
@@ -485,6 +487,8 @@ class Crawler(Guest):
     """
     Misago Crawler dummy
     """
+    is_team = False
+    
     def __init__(self, username):
         self.username = username
     

+ 2 - 1
templates/sora/layout.html

@@ -23,6 +23,7 @@
 </div>
 
 <div class="container">
+
   {% if messages %}
   <div class="alerts-global">
   	{{ messages_list(messages) }}
@@ -30,7 +31,7 @@
   
   {% block content %}
   {% endblock %}
-  
+    
   <footer>{% if settings.board_credits %}
     <p>{{ settings.board_credits|safe }}</p>{% endif %}
     <p class="software">This community is powered by <a href="http://misago-project.org">Misago forum software</a> by Rafał Pitoń</p>