diff options
author | hrcerqueira <hrcerqueira@gmail.com> | 2010-03-04 02:14:18 +0000 |
---|---|---|
committer | hrcerqueira <hrcerqueira@gmail.com> | 2010-03-04 02:14:18 +0000 |
commit | 90140cbc1e1e5ce4c79cf872b6cef754b342f0bf (patch) | |
tree | bffd2256dc19d21f987f747ac8dde6954f9480e5 /forum | |
parent | 5c526e37056aace78960d974c208d19c3703aa48 (diff) | |
download | askbot-90140cbc1e1e5ce4c79cf872b6cef754b342f0bf.tar.gz askbot-90140cbc1e1e5ce4c79cf872b6cef754b342f0bf.tar.bz2 askbot-90140cbc1e1e5ce4c79cf872b6cef754b342f0bf.zip |
couple of fixes
Diffstat (limited to 'forum')
-rwxr-xr-x | forum/models/__init__.py | 2 | ||||
-rwxr-xr-x | forum/settings.py | 51 | ||||
-rwxr-xr-x | forum/skins/default/templates/header.html | 2 | ||||
-rwxr-xr-x | forum/skins/default/templates/index.html | 4 | ||||
-rwxr-xr-x | forum/skins/default/templates/questions.html | 118 | ||||
-rwxr-xr-x | forum/skins/default/templates/users.html | 4 | ||||
-rwxr-xr-x | forum/urls.py | 2 |
7 files changed, 90 insertions, 93 deletions
diff --git a/forum/models/__init__.py b/forum/models/__init__.py index fee52447..4e29c215 100755 --- a/forum/models/__init__.py +++ b/forum/models/__init__.py @@ -93,7 +93,7 @@ def delete_messages(self): def get_profile_url(self): """Returns the URL for this User's profile.""" - return '%s%s/' % (reverse('user', args=[self.id]), slugify(self.username)) + return reverse('user_prof', kwargs={'id': self.id, 'slug': slugify(self.username)}) def get_profile_link(self): profile_link = u'<a href="%s">%s</a>' % (self.get_profile_url(),self.username) diff --git a/forum/settings.py b/forum/settings.py new file mode 100755 index 00000000..f3a665b2 --- /dev/null +++ b/forum/settings.py @@ -0,0 +1,51 @@ +import os
+
+
+INSTALLED_APPS = ['forum']
+
+MIDDLEWARE_CLASSES = [
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'forum.middleware.anon_user.ConnectToSessionMessagesMiddleware',
+ 'forum.middleware.pagesize.QuestionsPageSizeMiddleware',
+ 'forum.middleware.cancel.CancelActionMiddleware',
+ 'django.middleware.transaction.TransactionMiddleware',
+]
+
+TEMPLATE_LOADERS = [
+ 'django.template.loaders.filesystem.load_template_source',
+ 'django.template.loaders.app_directories.load_template_source',
+ 'forum.modules.module_templates_loader',
+ 'forum.skins.load_template_source',
+]
+
+TEMPLATE_CONTEXT_PROCESSORS = [
+ 'django.core.context_processors.request',
+ 'forum.context.application_settings',
+ 'forum.user_messages.context_processors.user_messages',
+ 'django.core.context_processors.auth',
+]
+
+TEMPLATE_DIRS = [
+ os.path.join(os.path.dirname(__file__),'skins').replace('\\','/'),
+]
+
+def setup_settings(settings):
+
+ if (hasattr(settings, 'DEBUG') and getattr(settings, 'DEBUG')):
+ try:
+ import debug_toolbar
+ INSTALLED_APPS.append('debug_toolbar')
+ MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware')
+ except:
+ pass
+
+
+ settings.INSTALLED_APPS = set(settings.INSTALLED_APPS) | set(INSTALLED_APPS)
+ settings.MIDDLEWARE_CLASSES = set(settings.MIDDLEWARE_CLASSES) | set(MIDDLEWARE_CLASSES)
+ settings.TEMPLATE_LOADERS = set(settings.TEMPLATE_LOADERS) | set(TEMPLATE_LOADERS)
+ settings.TEMPLATE_CONTEXT_PROCESSORS = set(settings.TEMPLATE_CONTEXT_PROCESSORS) | set(TEMPLATE_CONTEXT_PROCESSORS)
+ settings.TEMPLATE_DIRS = set(settings.TEMPLATE_DIRS) | set(TEMPLATE_DIRS)
+
+
\ No newline at end of file diff --git a/forum/skins/default/templates/header.html b/forum/skins/default/templates/header.html index cb12bb97..e65ac73a 100755 --- a/forum/skins/default/templates/header.html +++ b/forum/skins/default/templates/header.html @@ -5,7 +5,7 @@ <div id="navBar"> <div id="top"> {% if request.user.is_authenticated %} - <a href="{% url users %}{{ request.user.id }}/{{ request.user.username }}/">{{ request.user.username }}</a> {% get_score_badge request.user %} + <a href="{% url user_profile id=request.user.id,slug=request.user.username|slugify %}">{{ request.user.username }}</a> {% get_score_badge request.user %} <a href="{% url logout %}">{% trans "logout" %}</a> {% else %} <a href="{% url auth_signin %}">{% trans "login" %}</a> diff --git a/forum/skins/default/templates/index.html b/forum/skins/default/templates/index.html index 5bbb192b..191387ef 100755 --- a/forum/skins/default/templates/index.html +++ b/forum/skins/default/templates/index.html @@ -54,7 +54,7 @@ <div class="userinfo">
<span class="relativetime" title="{{question.last_activity_at}}">{% diff_date question.last_activity_at %}</span>
{% if question.last_activity_by %}
- <a href="{{ question.last_activity_by.get_profile_url }}">{{ question.last_activity_by }}</a> {% get_score_badge question.last_activity_by %}
+ <a href="/users/{{ question.last_activity_by.id }}/{{ question.last_activity_by.username|slugify }}/">{{ question.last_activity_by }}</a> {% get_score_badge question.last_activity_by %}
{% endif %}
</div>
@@ -102,7 +102,7 @@ <li>
<a href="{% url badges %}{{award.badge_id}}/{{award.badge_name}}" title="{{ award.badge_description }}" class="medal">
<span class="badge{{ award.badge_type }}">●</span> {{ award.badge_name }}</a> {% trans "given to" %}
- <a href="{% url users %}{{award.user_id}}/{{award.user_name}}">{{ award.user_name }}</a>
+ <a href="/users/{{ award.user_id }}/{{ award.user_name|slugify }}/">{{ award.user_name }}</a>
</li>
{% endfor %}
</ul>
diff --git a/forum/skins/default/templates/questions.html b/forum/skins/default/templates/questions.html index c2d74eca..58ad4146 100755 --- a/forum/skins/default/templates/questions.html +++ b/forum/skins/default/templates/questions.html @@ -52,92 +52,38 @@ </div>
<div id="listA">
{% for question in questions.object_list %}
- <div class="qstA"
- {% if request.user.is_authenticated %}
- {% if question.interesting_score > 0 %}
- style="background:#ffff99;"
- {% else %}
- {% if not request.user.hide_ignored_questions %}
- {% if question.ignored_score > 0 %}
- style="background:#f3f3f3;"
- {% endif %}
- {% endif %}
- {% endif %}
- {% endif %}
- >
- <h2>
- <a href="{{ question.get_absolute_url }}">{{ question.get_question_title }}</a>
- </h2>
- <div class="stat">
- <table>
- <tr>
- <td><span class="num">{{ question.answer_count|intcomma }}</span> </td>
- <td><span class="num">{{ question.score|intcomma }}</span> </td>
- <td><span class="num">{{ question.view_count|cnprog_intword|safe }}</span> </td>
- </tr>
- <tr>
- <td><span class="unit">{% trans "answers" %}</span></td>
- <td><span class="unit">{% trans "votes" %}</span></td>
- <td><span class="unit">{% trans "views" %}</span></td>
- </tr>
- </table>
- </div>
-
- <div class="summary">
- {{ question.summary }}...
- </div>
-
- {% ifequal tab_id 'active'%}
- {% if question.wiki and settings.WIKI_ON %}
- <span class="from wiki">{% trans "community wiki" %}</span>
- <span class="date" title="{{ question.added_at }}">{% diff_date question.added_at %}</span>
- {% else %}
- <div class="from">
- {% comment %}{% gravatar question.last_activity_by 24 %}{% endcomment %}
- <span class="author"><a href="{{ question.last_activity_by.get_profile_url }}">{{ question.last_activity_by }}</a></span>
- <span class="score">{% get_score_badge question.last_activity_by %} </span>
- <span class="date" title="{{ question.last_activity_at }}">{% diff_date question.last_activity_at %}</span>
- </div>
- {% endif %}
- {% else %}
- {% if question.wiki and settings.WIKI_ON %}
- <span class="from wiki">{% trans "community wiki" %}</span>
- <span class="date" title="{{ question.added_at }}">{% diff_date question.added_at %}</span>
- {% else %}
- <div class="from">
- {% comment %}{% gravatar question.author 24 %}{% endcomment %}
- {% if question.last_activity_at != question.added_at %}
- {% if question.author.id != question.last_activity_by.id %}
- {% trans "Posted:" %}
- <span class="author"><a href="{{ question.author.get_profile_url }}">{{ question.author }}</a></span>
- <span class="score">{% get_score_badge question.author %} </span>
- / {% trans "Updated:" %}
- <span class="author"><a href="{{ question.last_activity_by.get_profile_url }}">{{ question.last_activity_by }}</a></span>
- <span class="score">{% get_score_badge question.last_activity_by %} </span>
- <span class="date" title="{{ question.last_activity_at }}">{% diff_date question.last_activity_at %}</span>
- {% else %}
- {% trans "Updated:" %}
- <span class="author"><a href="{{ question.last_activity_by.get_profile_url }}">{{ question.last_activity_by }}</a></span>
- <span class="score">{% get_score_badge question.last_activity_by %} </span>
- <span class="date" title="{{ question.last_activity_at }}">{% diff_date question.last_activity_at %}</span>
- {% endif %}
- {% else %}
- {% trans "Posted:" %}
- <span class="author"><a href="{{ question.author.get_profile_url }}">{{ question.author }}</a></span>
- <span class="score">{% get_score_badge question.author %} </span>
- <span class="date" title="{{ question.added_at }}">{% diff_date question.added_at %}</span>
- {% endif %}
- </div>
- {% endif %}
- {% endifequal %}
-
- <div class="tags">
- {% for tag in question.tagname_list %}
- <a href="{% url tag_questions tag|urlencode %}" title="{% trans "see questions tagged" %}'{{ tag }}'{% trans "using tags" %}" rel="tag">{{ tag }}</a>
- {% endfor %}
- </div>
- </div>
- {% endfor %}
+ <div class="short-summary">
+ <div class="counts">
+ <div class="votes">
+ <div class="item-count">{{question.score|intcomma}}</div>
+ <div>{% trans "votes" %}</div>
+ </div >
+ <div {% if question.answer_accepted %}title="{% trans "this answer has been accepted to be correct" %}"{% endif %} class="status {% if question.answer_accepted %}answered-accepted{% endif %} {% ifequal question.answer_count 0 %}unanswered{% endifequal %}{% ifnotequal question.answer_count 0 %}answered{% endifnotequal %}">
+ <div class="item-count">{{question.answer_count|intcomma}}</div>
+ <div>{% trans "answers" %}</div>
+ </div>
+ <div class="views">
+ <div class="item-count">{{question.view_count|cnprog_intword|safe}}</div>
+ <div>{% trans "views" %}</div>
+ </div>
+ </div>
+
+ <h2><a title="{{question.summary}}" href="{% url question id=question.id %}{{question.title|slugify}}">{{question.title}}</a></h2>
+
+ <div class="userinfo">
+ <span class="relativetime" title="{{question.last_activity_at}}">{% diff_date question.last_activity_at %}</span>
+ {% if question.last_activity_by %}
+ <a href="/users/{{ question.last_activity_by.id }}/{{ question.last_activity_by.username|slugify }}/">{{ question.last_activity_by }}</a> {% get_score_badge question.last_activity_by %}
+ {% endif %}
+ </div>
+
+ <div class="tags">
+ {% for tag in question.tagname_list %}
+ <a href="{% url tag_questions tag|urlencode %}" title="{% trans "see questions tagged" %} '{{ tag }}' {% trans "using tags" %}" rel="tag">{{ tag }}</a>
+ {% endfor %}
+ </div>
+ </div>
+ {% endfor %}
{% if searchtitle %}
{% if questions_count == 0 %}
<p class="evenMore" style="padding-top:30px;text-align:center;">
diff --git a/forum/skins/default/templates/users.html b/forum/skins/default/templates/users.html index 3a59b0c0..f24b60a1 100755 --- a/forum/skins/default/templates/users.html +++ b/forum/skins/default/templates/users.html @@ -47,8 +47,8 @@ <div class="user"> <ul> - <li class="thumb"><a href="{{ user.get_profile_url }}">{% gravatar user 32 %}</a></li> - <li><a href="{{ user.get_profile_url }}">{{user.username}}</a></li> + <li class="thumb"><a href="/users/{{ user.id }}/{{ user.username|slugify }}/">{% gravatar user 32 %}</a></li> + <li><a href="/users/{{ user.id }}/{{ user.username|slugify }}/">{{user.username}}</a></li> <li>{% get_score_badge user %}</li> </ul> </div> diff --git a/forum/urls.py b/forum/urls.py index 59693be7..671b3da8 100755 --- a/forum/urls.py +++ b/forum/urls.py @@ -76,7 +76,7 @@ urlpatterns = patterns('', url(r'^%s$' % _('users/'),app.users.users, name='users'), url(r'^%s(?P<id>\d+)/$' % _('moderate-user/'), app.users.moderate_user, name='moderate_user'), url(r'^%s(?P<id>\d+)/%s$' % (_('users/'), _('edit/')), app.users.edit_user, name='edit_user'), - url(r'^%s(?P<id>\d+)/(?P<slug>\w+)/$' % _('users/'), app.users.user, name='user'), + url(r'^%s(?P<id>\d+)/(?P<slug>.+)/$' % _('users/'), app.users.user, name='user_profile'), url(r'^%s$' % _('badges/'),app.meta.badges, name='badges'), url(r'^%s(?P<id>\d+)//*' % _('badges/'), app.meta.badge, name='badge'), url(r'^%s%s$' % (_('messages/'), _('markread/')),app.commands.read_message, name='read_message'), |