Просмотр исходного кода

- Updated fixtures to create basic example forum and contain sane defaults
- Updated forums list style
- Updated threads list style
- Fixed ACL compiler for threads app
- Basic deleted user post styles

Ralfp 12 лет назад
Родитель
Сommit
231f9d5635

+ 7 - 8
misago/forumroles/fixtures.py

@@ -1,11 +1,10 @@
+from misago.forumroles.models import ForumRole
 from misago.utils import ugettext_lazy as _
 from misago.utils import get_msgid
-from misago.forumroles.models import ForumRole
-
 
 def load_fixtures():
     role = ForumRole()
-    role.name(get_msgid(_('Full Access')))
+    role.name = _('Full Access').message
     role.set_permissions({
                           'can_see_forum': True,
                           'can_see_forum_contents': True,
@@ -44,7 +43,7 @@ def load_fixtures():
     role.save(force_insert=True)
     
     role = ForumRole()
-    role.name(get_msgid(_('Standard Access and Upload')))
+    role.name = _('Standard Access and Upload').message
     role.set_permissions({
                           'can_see_forum': True,
                           'can_see_forum_contents': True,
@@ -66,7 +65,7 @@ def load_fixtures():
     role.save(force_insert=True)
     
     role = ForumRole()
-    role.name(get_msgid(_('Standard Access')))
+    role.name = _('Standard Access').message
     role.set_permissions({
                           'can_see_forum': True,
                           'can_see_forum_contents': True,
@@ -85,7 +84,7 @@ def load_fixtures():
     role.save(force_insert=True)
     
     role = ForumRole()
-    role.name(get_msgid(_('Read and Download')))
+    role.name = _('Read and Download').message
     role.set_permissions({
                           'can_see_forum': True,
                           'can_see_forum_contents': True,
@@ -95,7 +94,7 @@ def load_fixtures():
     role.save(force_insert=True)
     
     role = ForumRole()
-    role.name(get_msgid(_('Threads list only')))
+    role.name = _('Threads list only').message
     role.set_permissions({
                           'can_see_forum': True,
                           'can_see_forum_contents': True,
@@ -103,7 +102,7 @@ def load_fixtures():
     role.save(force_insert=True)
     
     role = ForumRole()
-    role.name(get_msgid(_('Read only')))
+    role.name = _('Read only').message
     role.set_permissions({
                           'can_see_forum': True,
                           'can_see_forum_contents': True,

+ 24 - 22
misago/forums/fixtures.py

@@ -1,7 +1,6 @@
 from django.utils import timezone
 from misago.monitor.fixtures import load_monitor_fixture
 from misago.forums.models import Forum
-from misago.markdown import post_markdown
 from misago.threads.models import Thread, Post
 from misago.utils import slugify
 
@@ -10,30 +9,33 @@ def load_fixtures():
     Forum(token='private', name='private', slug='private', type='forum').insert_at(target=None,save=True)
     Forum(token='reports', name='reports', slug='reports', type='forum').insert_at(target=None,save=True)
     
-    root = Forum(token='root', name='root', slug='root').insert_at(target=None,save=True)
-    cat = Forum(type='category', name='First Category', slug='first-category').insert_at(target=root,save=True)
-    forum = Forum(type='forum', name='First Forum', slug='first-forum', threads=1, posts=1).insert_at(target=cat,save=True)
+    root = Forum(token='root', name='root', slug='root')
+    root.insert_at(target=None,save=True)
+    cat = Forum(type='category', name='First Category', slug='first-category')
+    cat.insert_at(target=root,save=True)
+    forum = Forum(type='forum', name='First Forum', slug='first-forum', threads=1, posts=1)
+    forum.insert_at(target=cat,save=True)
     Forum(type='redirect', name='Project Homepage', slug='project-homepage', redirect='http://misago-project.org').insert_at(target=cat,save=True)
     Forum.objects.populate_tree(True)
-       
+    
     now = timezone.now()
-    thread = Thread.create(
-                           forum=forum,
-                           name='Welcome to Misago!',
-                           slug=slugify('Welcome to Misago!'),
-                           start=now,
-                           last=now,
-                           )
-    post = Post.create(
-                       forum=forum,
-                       thread=thread,
-                       user_name='Misago Project',
-                       ip='127.0.0.1',
-                       agent='',
-                       post='Welcome to Misago!',
-                       post_preparsed='Welcome to Misago!',
-                       date=now,
-                       )
+    thread = Thread.objects.create(
+                                   forum=forum,
+                                   name='Welcome to Misago!',
+                                   slug=slugify('Welcome to Misago!'),
+                                   start=now,
+                                   last=now,
+                                   )
+    post = Post.objects.create(
+                               forum=forum,
+                               thread=thread,
+                               user_name='Misago Project',
+                               ip='127.0.0.1',
+                               agent='',
+                               post='Welcome to Misago!',
+                               post_preparsed='Welcome to Misago!',
+                               date=now,
+                               )
     thread.start_post = post
     thread.start_poster_name = 'Misago Project'
     thread.start_poster_slug = 'misago-project'

+ 2 - 2
misago/forums/models.py

@@ -26,14 +26,14 @@ class ForumManager(models.Manager):
                     self.forums_tree[forum.token] = forum
             cache.set('forums_tree', self.forums_tree)
     
-    def forum_parents(self, forum, include_self):
+    def forum_parents(self, forum, include_self=False):
         self.populate_tree()
         parents = []
         parent = self.forums_tree[forum]
         if include_self:
             parents.append(parent)
         while parent.level > 1:
-            parent = self.forums_tree[parent.pk]
+            parent = self.forums_tree[parent.parent_id]
             parents.append(parent)
         return reversed(parents)
         

+ 6 - 5
misago/readstracker/trackers.py

@@ -29,11 +29,12 @@ class ThreadsTracker(object):
         self.user = user
         self.forum = forum
         self.cutoff = timezone.now() - timedelta(days=settings.READS_TRACKER_LENGTH)
-        try:
-            self.record = Record.objects.get(user=user,forum=forum)
-        except Record.DoesNotExist:
-            self.record = Record(user=user,forum=forum,cleared=self.cutoff)
-        self.threads = self.record.get_threads()
+        if user.is_authenticated():
+            try:
+                self.record = Record.objects.get(user=user,forum=forum)
+            except Record.DoesNotExist:
+                self.record = Record(user=user,forum=forum,cleared=self.cutoff)
+            self.threads = self.record.get_threads()
     
     def get_read_date(self, thread):
         if not self.user.is_authenticated():

+ 1 - 0
misago/roles/fixtures.py

@@ -1,5 +1,6 @@
 from misago.roles.models import Role
 from misago.utils import ugettext_lazy as _
+from misago.utils import get_msgid
 
 def load_fixtures():
     role = Role(name=_("Administrator").message, token='admin', protected=True)

+ 6 - 0
misago/setup/fixtures.py

@@ -12,6 +12,9 @@ def load_app_fixtures(app):
         return True
     except (ImportError, AttributeError):
         return False
+    except Exception as e:
+        print 'Could not load fixtures from %s:\n%s' % (app, e)
+        return False
 
     
 def update_app_fixtures(app):
@@ -25,4 +28,7 @@ def update_app_fixtures(app):
         fixture.update_fixtures()
         return True
     except (ImportError, AttributeError):
+        return False
+    except Exception as e:
+        print 'Could not update fixtures from %s:\n%s' % (app, e)
         return False

+ 7 - 4
misago/threads/acl.py

@@ -299,10 +299,13 @@ def build_forums(acl, perms, forums, forum_roles):
             try:
                 role = forum_roles[perm['forums'][forum.pk]]
                 for p in forum_role:
-                    if p in ['attachment_size', 'attachment_limit'] and role[p] == 0:
-                        forum_role[p] = 0
-                    elif int(role[p]) > forum_role[p]:
-                        forum_role[p] = int(role[p])
+                    try:
+                        if p in ['attachment_size', 'attachment_limit'] and role[p] == 0:
+                            forum_role[p] = 0
+                        elif int(role[p]) > forum_role[p]:
+                            forum_role[p] = int(role[p])
+                    except KeyError:
+                        pass
             except KeyError:
                 pass
         acl.threads.acl[forum.pk] = forum_role

+ 0 - 1
misago/threads/fixtures.py

@@ -79,7 +79,6 @@ settings_fixtures = (
 
 
 def load_fixtures():
-    load_monitor_fixture(monitor_fixtures)
     load_settings_fixture(settings_fixtures)
     
     

+ 1 - 1
misago/threads/views/list.py

@@ -21,7 +21,7 @@ class ThreadsView(BaseView, ThreadsFormMixin):
     def fetch_forum(self, forum):
         self.forum = Forum.objects.get(pk=forum, type='forum')
         self.request.acl.forums.allow_forum_view(self.forum)
-        self.parents = Forum.objects.forum_parents(forum.pk)
+        self.parents = Forum.objects.forum_parents(self.forum.pk)
         if self.forum.lft + 1 != self.forum.rght:
             self.forum.subforums = Forum.objects.treelist(self.request.acl.forums, self.forum, tracker=ForumsTracker(self.request.user))
         self.tracker = ThreadsTracker(self.request.user, self.forum)

+ 2 - 1
static/sora/css/sora.css

@@ -950,7 +950,7 @@ td.lead-cell{color:#555555;font-weight:bold;}
 .nav-tabs button{padding-left:7px;padding-right:7px;}
 .forums-list{padding-top:4px;}.forums-list .category h2{color:#666666;font-size:110%;margin-bottom:0px;}.forums-list .category h2 small{color:#a6a6a6;font-size:100%;}
 .forums-list .category-important .well-forum{border:1px solid #0099e6;-webkit-box-shadow:0px 0px 0px 3px #66ccff;-moz-box-shadow:0px 0px 0px 3px #66ccff;box-shadow:0px 0px 0px 3px #66ccff;}
-.forums-list .well-forum{margin:0px -8px;margin-bottom:14px;overflow:auto;padding:12px 8px;padding-bottom:8px;}.forums-list .well-forum .row .span3{margin-left:0px;padding-left:16px;}
+.forums-list .well-forum{margin-bottom:14px;overflow:auto;padding:12px 8px;padding-bottom:8px;}.forums-list .well-forum .row .span3{margin-left:0px;padding-left:16px;}
 .forums-list .well-forum .forum-icon{background-color:#eeeeee;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;float:left;padding:3px 6px;position:relative;bottom:4px;margin-bottom:-4px;}
 .forums-list .well-forum .forum-new{background-color:#0088cc !important;}
 .forums-list .well-forum .redirect-icon{background-color:#46a546;}
@@ -961,6 +961,7 @@ td.lead-cell{color:#555555;font-weight:bold;}
 .forums-list .well-forum .forum-stat .positive{background-color:#cdeacd;color:#3e933e;}
 .forums-list .well-forum h3{margin:0px;padding:0px;font-size:110%;line-height:100%;}.forums-list .well-forum h3 .read-forum{color:#75a5bd;}
 .forums-list .well-forum .muted{margin-top:4px;color:#737373;}
+.forums-list .span4 .well-forum,.forums-list .span2 .well-forum{margin:0px -8px;}
 .forum-list-side{padding-top:10px;}
 .subforums-list{margin:0px;position:relative;bottom:32px;}.subforums-list .category{margin-bottom:-24px;}
 .threads-list .thread-icon{background-color:#eeeeee;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;padding:5px 6px;}

+ 8 - 3
static/sora/css/sora/forums.less

@@ -22,14 +22,13 @@
       .box-shadow(0px 0px 0px 3px lighten(@linkColor, 30%));
     }
   }
-  
+    
   .well-forum {
-    margin: 0px -8px;
     margin-bottom: 14px;
     overflow: auto;
     padding: 12px 8px;
     padding-bottom: 8px;
-    
+        
     .row {
       .span3 {
         margin-left: 0px;
@@ -108,6 +107,12 @@
       color: lighten(@textColor, 25%);
     }
   }
+  
+  .span4, .span2 {
+    .well-forum {
+      margin: 0px -8px; 
+    }
+  }
 }
 
 .forum-list-side {

+ 3 - 3
templates/sora/macros.html

@@ -52,10 +52,10 @@
 
 {# Render forum on list #}
 {% macro draw_forum(category, forum, width=12) %}
-<div{% if category.template != 'row' %} class="{% if category.template == 'half' %}span{{ widthratio(50, 100, width) }}{% elif category.template == 'quarter' %}span{{ widthratio(25, 100, width) }}{% endif %}"{% endif %}>
+<div{% if category.template != 'row' %} class="span{% if category.template == 'half' %}{{ widthratio(50, 100, width) }}{% elif category.template == 'quarter' %}{{ widthratio(25, 100, width) }}{% endif %}"{% endif %}>
   <div class="well well-forum{% if forum.style %} {{ forum.style }}{% endif %}">
     <div class="forum-icon {% if forum.type == 'redirect' %} redirect-icon{% elif not forum.is_read %} forum-new{% endif %}"><i class="icon-{% if forum.type == 'redirect' %}circle-arrow-right{% else %}comment{% endif %} icon-white"></i></div>
-    {% if category.template != 'quarter' %}<div class="forum-details">{% endif %}
+    <div class="forum-details">
       <div class="pull-left">
         <h3><a href="{{ forum.type|url(slug=forum.slug, forum=forum.id) }}"{% if forum.type != 'redirect' and forum.is_read %} class="read-forum"{% endif %}>{{ forum.name }}</a></h3>
         {% if forum.description %}<div class="muted">{{ forum.description }}</div>{% endif %}
@@ -76,7 +76,7 @@
       {% endif %}
       {% endif %}
       {% endif %}
-    {% if category.template != 'quarter' %}</div>{% endif %}
+    </div>
   </div>
 </div>
 {% endmacro %}

+ 2 - 2
templates/sora/threads/list.html

@@ -72,9 +72,9 @@
           {% if thread.deleted %}<li><span class="tooltip-top" title="{% trans %}This thread has been deleted.{% endtrans %}"><i class="icon-remove"></i></span></li>{% endif %}
         </ul>
       </td>
-      <td class="span2 thread-author"><span class="tooltip-top" title="{{ thread.start|reltimesince }}">{% if thread.start_poster_id %}{% if settings.avatars_on_threads_list %}<img src="{{ thread.start_poster.get_avatar(24) }}" alt="" class="avatar-tiny"> {% endif %}<a href="{% url 'user' user=thread.start_poster_id, username=thread.start_poster_slug %}">{{ thread.start_poster_name }}</a>{% else %}{% if settings.avatars_on_threads_list %}<img src="{{ macros.avatar_guest(24) }}" alt="" class="avatar-tiny"> {% endif %}<em class="muted">{{ thread.start_poster_name }}</em>{% endif %}</span></td>
+      <td class="span3 thread-author"><span class="tooltip-top" title="{{ thread.start|reltimesince }}">{% if thread.start_poster_id %}{% if settings.avatars_on_threads_list %}<img src="{{ thread.start_poster.get_avatar(24) }}" alt="" class="avatar-tiny"> {% endif %}<a href="{% url 'user' user=thread.start_poster_id, username=thread.start_poster_slug %}">{{ thread.start_poster_name }}</a>{% else %}{% if settings.avatars_on_threads_list %}<img src="{{ macros.avatar_guest(24) }}" alt="" class="avatar-tiny"> {% endif %}<em class="muted">{{ thread.start_poster_name }}</em>{% endif %}</span></td>
       <td class="span1 thread-stat">{{ thread.replies|intcomma }}</td>
-      <td class="span2 thread-poster"><span class="tooltip-top" title="{{ thread.last|reltimesince }}">{% if thread.last_poster_id %}{% if settings.avatars_on_threads_list %}<img src="{{ thread.last_poster.get_avatar(24) }}" alt="" class="avatar-tiny"> {% endif %}<a href="{% url 'user' user=thread.last_poster_id, username=thread.last_poster_slug %}">{{ thread.last_poster_name }}</a>{% else %}{% if settings.avatars_on_threads_list %}<img src="{{ macros.avatar_guest(24) }}" alt="" class="avatar-tiny"> {% endif %}<em class="muted">{{ thread.last_poster_name }}</em>{% endif %}</span></td>
+      <td class="span3 thread-poster"><span class="tooltip-top" title="{{ thread.last|reltimesince }}">{% if thread.last_poster_id %}{% if settings.avatars_on_threads_list %}<img src="{{ thread.last_poster.get_avatar(24) }}" alt="" class="avatar-tiny"> {% endif %}<a href="{% url 'user' user=thread.last_poster_id, username=thread.last_poster_slug %}">{{ thread.last_poster_name }}</a>{% else %}{% if settings.avatars_on_threads_list %}<img src="{{ macros.avatar_guest(24) }}" alt="" class="avatar-tiny"> {% endif %}<em class="muted">{{ thread.last_poster_name }}</em>{% endif %}</span></td>
       {% if user.is_authenticated() and list_form %}
       <td class="check-cell">{% if thread.forum_id == forum.pk %}<label class="checkbox"><input form="threads_form" name="{{ list_form['list_items']['html_name'] }}" type="checkbox" class="checkbox-member" value="{{ thread.pk }}"{% if list_form['list_items']['has_value'] and ('' ~ thread.pk) in list_form['list_items']['value'] %} checked="checked"{% endif %}></label>{% else %}&nbsp;{% endif %}</td>
       {% endif %}

+ 8 - 3
templates/sora/threads/thread.html

@@ -46,10 +46,15 @@
   {% if post.message %}{{ macros.draw_message(post.message) }}{% endif %}
   <div id="post-{{ post.pk }}" class="well well-post{% if post.user and post.user.rank and post.user.rank.style %} {{ post.user.rank.style }}{% endif %}">
     <div class="post-author">
-      <img src="{{ post.user.get_avatar(80) }}" alt="" class="avatar-normal">
+      <img src="{% if post.user_id %}{{ post.user.get_avatar(80) }}{% else %}{{ macros.avatar_guest(80) }}{% endif %}" alt="" class="avatar-normal">
       <div class="post-bit">
-        <a href="{% url 'user' user=post.user.pk, username=post.user.username_slug %}" class="lead">{{ post.user.username }}</a>{% if post.user.get_title() %}
-        <p class="user-title">{{ _(post.user.get_title()) }}</p>{% endif %}
+        {% if post.user_id %}
+        <a href="{% url 'user' user=post.user.pk, username=post.user.username_slug %}" class="lead">{{ post.user.username }}</a>
+        {% if post.user.get_title() %}<p class="user-title">{{ _(post.user.get_title()) }}</p>{% endif %}
+        {% else %}
+        <span class="lead">{{ post.user_name }}</span>
+        <p class="user-title">{% trans %}Unregistered{% endtrans %}</p>
+        {% endif %}
         <p class="post-date">{{ post.date|reltimesince|low }}</p>
       </div>
     </div>