From 0762b79da73cb02e1be04c2de4aaa55eda221901 Mon Sep 17 00:00:00 2001 From: Evgeny Fadeev Date: Sun, 11 Apr 2010 17:14:25 -0400 Subject: question views merged, changed UI a bit, full text search broken --- django_authopenid/views.py | 2 +- forum/const.py | 1 + forum/forms.py | 1 - forum/middleware/view_log.py | 1 - forum/search/state_manager.py | 4 - forum/skins/default/media/style/style.css | 85 +++++++++++++++------- forum/skins/default/templates/about.html | 2 +- forum/skins/default/templates/ask.html | 2 + forum/skins/default/templates/ask_form.html | 66 +++++++++++++++++ forum/skins/default/templates/base.html | 1 + forum/skins/default/templates/base_content.html | 1 + forum/skins/default/templates/faq.html | 2 +- forum/skins/default/templates/feedback.html | 2 +- forum/skins/default/templates/header.html | 49 +------------ forum/skins/default/templates/index.html | 2 +- forum/skins/default/templates/index_.html | 2 +- forum/skins/default/templates/input_bar.html | 45 ++++++++++++ forum/skins/default/templates/question.html | 2 +- forum/skins/default/templates/questions.html | 10 +-- forum/skins/default/templates/tags.html | 6 +- forum/skins/default/templates/user.html | 2 +- forum/skins/default/templates/user_reputation.html | 7 +- forum/skins/default/templates/users.html | 2 +- forum/templatetags/extra_tags.py | 4 - forum/views/readers.py | 4 +- forum/views/users.py | 3 +- 26 files changed, 204 insertions(+), 104 deletions(-) create mode 100644 forum/skins/default/templates/ask_form.html create mode 100644 forum/skins/default/templates/input_bar.html diff --git a/django_authopenid/views.py b/django_authopenid/views.py index e2d8b67c..4f7d3efa 100755 --- a/django_authopenid/views.py +++ b/django_authopenid/views.py @@ -90,7 +90,7 @@ def login(request,user): _login(request,user) #4) transfer search_state to new session if found if search_state: - search_session.set_logged_in() + search_state.set_logged_in() request.session['search_state'] = search_state #5) send signal with old session key as argument logging.debug('logged in user %s with session key %s' % (user.username, session_key)) diff --git a/forum/const.py b/forum/const.py index dd85bb2e..11c833ea 100755 --- a/forum/const.py +++ b/forum/const.py @@ -131,3 +131,4 @@ CONST = { #how to filter questions by tags in email digests? TAG_EMAIL_FILTER_CHOICES = (('ignored', _('exclude ignored tags')),('interesting',_('allow only selected tags'))) MAX_ALERTS_PER_EMAIL = 7 +USERS_PAGE_SIZE = 28 diff --git a/forum/forms.py b/forum/forms.py index 2c2df738..b205c6e1 100755 --- a/forum/forms.py +++ b/forum/forms.py @@ -174,7 +174,6 @@ class AdvancedSearchForm(forms.Form): def clean(self): #todo rewrite - print self.cleaned_data if self.cleaned_data['scope'] == '': del self.cleaned_data['scope'] if self.cleaned_data['tags'] is None: diff --git a/forum/middleware/view_log.py b/forum/middleware/view_log.py index 213292fe..6472322b 100644 --- a/forum/middleware/view_log.py +++ b/forum/middleware/view_log.py @@ -49,7 +49,6 @@ class ViewLogMiddleware(object): else: view_str = view_func.__name__ if view_str == 'wrap': - print str(view_func.__module__)# == 'forum.utils.decorators': return if settings.DEBUG == True: diff --git a/forum/search/state_manager.py b/forum/search/state_manager.py index 4b3772b6..8a66deb3 100644 --- a/forum/search/state_manager.py +++ b/forum/search/state_manager.py @@ -15,7 +15,6 @@ class SearchState(object): self.page = 1 self.logged_in = False logging.debug('new search state initialized') - print 'new search state' def __str__(self): out = 'scope=%s\n' % self.scope @@ -77,10 +76,7 @@ class SearchState(object): if 'tags' in input: if self.tags: old_tags = self.tags.copy() - print 'old tags %s' % str(old_tags) - print 'new tags %s' % str(input['tags']) self.tags = self.tags.union(input['tags']) - print 'combined %s' % str(self.tags) if self.tags != old_tags: self.reset_page() else: diff --git a/forum/skins/default/media/style/style.css b/forum/skins/default/media/style/style.css index 81c6965e..f96e9d67 100755 --- a/forum/skins/default/media/style/style.css +++ b/forum/skins/default/media/style/style.css @@ -217,7 +217,7 @@ blockquote { } #room { - padding: 10px 0 10px 0; + padding: 0 0 10px 0; background-color: #FFF; border-bottom: 1px solid #777; } @@ -250,16 +250,15 @@ blockquote { /*#licenseLogo {position:absolute;top:10px;right:10px;}*/ -/*顶部及导航栏*/ +/* why is this called top? - this contains links like login, faq, etc */ #top { position: absolute; top: 0px; - right: 0px; + right: 250px; height: 20px; text-align: right; padding: 3px; background-color: #ffffff; - width: 500px; } /*#header {width:960px;}*/ @@ -269,13 +268,21 @@ blockquote { margin-left: 20px; text-decoration: underline; font-size: 12px; - color: #333333; + color: #555555; } #logo { padding: 5px 0px 0px 0px; } +#logoContainer { +} +#navTabContainer { + width: 500px; + text-align: left; +} + +/* navBar includes logo, main tabs and links like logout, about, faq */ #navBar { float: clear; position: relative; @@ -284,7 +291,7 @@ blockquote { } #navBar .nav { - margin: 20px 0px 0px 16px; /*letter-spacing:1px; */ + margin: 20px 0px 0px 0px; /*letter-spacing:1px; */ } #navBar .nav a { @@ -334,29 +341,24 @@ blockquote { text-decoration: underline; } +/* todo: this is probably not used any more */ #navBar .nav div.focus { float: right; padding-right: 0px; } #searchBar { - width: 958px; - background-color: #888a85; /*#e9b96e;*/ - border: 1px solid #aaaaaa; - padding: 4px 0 5px 5px; -} -#fakeSearchBar { - width: 958px; - height: 4px; - background-color: #888a85; /*#e9b96e;*/ + display:inline-block; + background-color: #cccccc;/*888a85; /*#e9b96e;*/ border: 1px solid #aaaaaa; + padding: 4px 7px 5px 5px; } #searchBar .searchInput { font-size: 24px; line-height: 24px; height: 36px; - width: 620px; + width: 598px; margin: 0px; padding: 5px 0 0 5px; } @@ -365,7 +367,7 @@ blockquote { font-size: 24px; line-height: 24px; height: 36px; - width: 570px; + width: 552px; padding: 5px 0 0 5px; margin: 0px; } @@ -391,6 +393,26 @@ blockquote { text-align: center; } +#askFormBar { + display:inline-block; + background-color: #e3e3e3;/*888a85; /*#e9b96e;*/ + border: 1px solid #aaaaaa; + padding: 4px 7px 5px 5px; +} +#askFormBar p { + width: 685px; + margin:0 0 5px 0; +} +#askFormBar .questionTitleInput { + font-size: 24px; + line-height: 24px; + height: 36px; + width: 680px; + margin: 0px; + padding: 5px 0 0 5px; +} + + #searchBar .options { padding: 3px 0 3px 0; font-size: 100%; @@ -654,13 +676,16 @@ blockquote { } .boxC { - background: #cacdc6; /*f9f7ed;*/ + background: white /*#cacdc6; /*f9f7ed;*/ padding: 10px; margin-bottom: 8px; + margin-left: 10px; + /* border-top: 1px solid #eeeeec; border-left: 1px solid #eeeeec; border-right: 1px solid #a9aca5; border-bottom: 1px solid #babdb6; + */ } .boxC p { @@ -877,6 +902,7 @@ a:hover.medal { width: 100%; clear: both; margin-bottom: 3px; + margin-top: 3px; } .tabsA { @@ -996,6 +1022,7 @@ a:hover.medal { padding-left: 24px; } +/* todo: make this class applicable to all headers it is actually uses in tags.html too */ .headUsers { float: left; height: 23px; @@ -1531,7 +1558,8 @@ span.form-error { font-size: 100%; min-height: 200px; line-height: 18px; - width: 100%; + width: 697px; + margin:0; } #id_title { @@ -1539,9 +1567,9 @@ span.form-error { } .wmd-preview { - margin-top: 10px; + margin: 10px 0 0 0; padding: 6px; - width: 100%; + width: 691px; background-color: #F5F5F5; min-height: 20px; } @@ -1729,7 +1757,6 @@ ins .post-tag { } .narrow .stats { - background: transparent none repeat scroll 0 0; float: left; height: 48px; margin: 0 0 0 7px; @@ -1738,6 +1765,11 @@ ins .post-tag { font-family: Arial; } +/* todo: remove this hack? */ +.user-stats-table .narrow { + width: 660px; +} + .stats div { font-size: 11px; text-align: center; @@ -2546,15 +2578,16 @@ p.signup_p { } .karma-diagram { - width:550px; - height:250px; + width:390px; + height:300px; float:left; + margin-right:10px; } .karma-details { float:right; - width:385px; - height:300px; + width:300px; + height:250px; overflow-y:auto; word-wrap:break-word; } diff --git a/forum/skins/default/templates/about.html b/forum/skins/default/templates/about.html index 66dcc3fd..686141b3 100644 --- a/forum/skins/default/templates/about.html +++ b/forum/skins/default/templates/about.html @@ -1,4 +1,4 @@ -{% extends "base_content.html" %} +{% extends "base.html" %} {% load i18n %} {% load extra_tags %} diff --git a/forum/skins/default/templates/ask.html b/forum/skins/default/templates/ask.html index 083b01d9..4278f4cb 100644 --- a/forum/skins/default/templates/ask.html +++ b/forum/skins/default/templates/ask.html @@ -56,6 +56,7 @@ {% endblock %} +{% comment %} {% block content %}
{% trans "Ask a question" %} @@ -124,6 +125,7 @@
{% endblock %} +{% endcomment %} {% block sidebar %} {% include "question_edit_tips.html" %} diff --git a/forum/skins/default/templates/ask_form.html b/forum/skins/default/templates/ask_form.html new file mode 100644 index 00000000..25e9fe6c --- /dev/null +++ b/forum/skins/default/templates/ask_form.html @@ -0,0 +1,66 @@ +{% load i18n %} +{% load smart_if %} +
+
+
+ {% comment %} + + {% endcomment %} +
+ {% if not request.user.is_authenticated %} +

{% trans "login to post question info" %}

+ {% else %} + {% ifequal settings.EMAIL_VALIDATION 'on' %} + {% if not request.user.email_isvalid %} + {% blocktrans with request.user.email as email %}must have valid {{email}} to post, + see {{email_validation_faq_url}} + {% endblocktrans %} + {% endif %} + {% endifequal %} + {% endif %} + +
+ {{ form.title.errors }} +
+
+ {{ form.title.help_text }} +
+
+ +
+
+ {{ form.text }} + +
+ + + + {% if settings.WIKI_ON %} + + {% endif %} + + +
+ {% trans "toggle preview" %} + + {{ form.wiki }} {{ form.wiki.label_tag }} +
+
+
+ +
+
+ {{ form.tags.label_tag }}: {% trans "(required)" %}
+ {{ form.tags }} {{ form.tags.errors }} +
+

+ {{ form.tags.help_text }} +

+ {% if not request.user.is_authenticated %} + + {% else %} + + {% endif %} +
+
diff --git a/forum/skins/default/templates/base.html b/forum/skins/default/templates/base.html index fe5a95a3..0b85e7fb 100644 --- a/forum/skins/default/templates/base.html +++ b/forum/skins/default/templates/base.html @@ -68,6 +68,7 @@
+ {% include "input_bar.html" %} {% block content%} {% endblock%} diff --git a/forum/skins/default/templates/base_content.html b/forum/skins/default/templates/base_content.html index c98e1f67..fff7838d 100644 --- a/forum/skins/default/templates/base_content.html +++ b/forum/skins/default/templates/base_content.html @@ -55,6 +55,7 @@
+ {% include "input_bar.html" %} {% block content%} {% endblock%} diff --git a/forum/skins/default/templates/faq.html b/forum/skins/default/templates/faq.html index ca963237..cc790ccc 100644 --- a/forum/skins/default/templates/faq.html +++ b/forum/skins/default/templates/faq.html @@ -1,4 +1,4 @@ -{% extends "base_content.html" %} +{% extends "base.html" %} {% load extra_tags %} {% load humanize %} diff --git a/forum/skins/default/templates/feedback.html b/forum/skins/default/templates/feedback.html index 38bb48ff..af4f635f 100644 --- a/forum/skins/default/templates/feedback.html +++ b/forum/skins/default/templates/feedback.html @@ -1,4 +1,4 @@ -{% extends "base_content.html" %} +{% extends "base.html" %} {% load i18n %} {% load extra_tags %} diff --git a/forum/skins/default/templates/header.html b/forum/skins/default/templates/header.html index efc0d8f2..5d634dd7 100644 --- a/forum/skins/default/templates/header.html +++ b/forum/skins/default/templates/header.html @@ -14,15 +14,15 @@ {% trans "about" %} {% trans "faq" %}
- +
- -
+ +
- {% if active_tab != "ask" %} - - {% else %} -
- {% endif %}
diff --git a/forum/skins/default/templates/index.html b/forum/skins/default/templates/index.html index b90d788a..f94f84fc 100644 --- a/forum/skins/default/templates/index.html +++ b/forum/skins/default/templates/index.html @@ -23,7 +23,7 @@ {% endblock %} {% block content %}
-
{% trans "Questions" %}
+
{% trans "Questions" %}
{% trans "newest" %} {% trans "hottest" %} diff --git a/forum/skins/default/templates/index_.html b/forum/skins/default/templates/index_.html index 8ba169a7..36531f62 100644 --- a/forum/skins/default/templates/index_.html +++ b/forum/skins/default/templates/index_.html @@ -22,7 +22,7 @@ {% endblock %} {% block content %}
-
{% trans "Questions" %}
+
{% trans "Questions" %}
{% trans "newest" %} {% trans "hottest" %} diff --git a/forum/skins/default/templates/input_bar.html b/forum/skins/default/templates/input_bar.html new file mode 100644 index 00000000..59236350 --- /dev/null +++ b/forum/skins/default/templates/input_bar.html @@ -0,0 +1,45 @@ +{% load i18n %} +{% load smart_if %} +{% if active_tab != "ask" %} + +{% else %} + {% include "ask_form.html" %} +{% endif %} diff --git a/forum/skins/default/templates/question.html b/forum/skins/default/templates/question.html index c3564a34..79ff9a5b 100644 --- a/forum/skins/default/templates/question.html +++ b/forum/skins/default/templates/question.html @@ -226,7 +226,7 @@
-
+
{% blocktrans count answers|length as counter %} One Answer: {% plural %} diff --git a/forum/skins/default/templates/questions.html b/forum/skins/default/templates/questions.html index 03ccc324..f864180f 100644 --- a/forum/skins/default/templates/questions.html +++ b/forum/skins/default/templates/questions.html @@ -27,7 +27,7 @@ {% block content %}
{% comment %} -
+
{% if searchtag %} {% trans "Found by tags" %} {% else %} @@ -50,7 +50,7 @@
{% trans "In:" %} {% trans "all" %} - {% trans "unanswered" %} + {% trans "unanswered" %} {% if request.user.is_authenticated %} {% trans "favorite" %} {% endif %} @@ -99,18 +99,18 @@ {% trans "coldest" %} + title="{% trans "click to see hottest questions" %}">{% trans "less answers" %} {% else %} {% if sort == "hottest" %} {% trans "hottest" %} + title="{% trans "click to see coldest questions" %}">{% trans "more answers" %} {% else %} {% trans "hottest" %} + title="{% trans "click to see hottest questions" %}">{% trans "more answers" %} {% endif %} {% endif %} diff --git a/forum/skins/default/templates/tags.html b/forum/skins/default/templates/tags.html index 2bc01070..6627db32 100644 --- a/forum/skins/default/templates/tags.html +++ b/forum/skins/default/templates/tags.html @@ -1,4 +1,4 @@ -{% extends "base_content.html" %} +{% extends "base.html" %} {% load i18n %} {% load extra_tags %} @@ -27,7 +27,7 @@ {% block content %}
-
{% trans "Tag list" %}
+
{% trans "Tag list" %}
{% trans "by name" %} {% trans "by popularity" %} @@ -36,7 +36,7 @@

{% if stag %} - {% trans "All tags matching query" %} '{{ stag }}' {% trans "all tags - make this empty in english" %}: + {% blocktrans %}All tags matching '{{ stag }}'{% endblocktrans %}: {% endif %} {% if not tags.object_list %} {% trans "Nothing found" %} diff --git a/forum/skins/default/templates/user.html b/forum/skins/default/templates/user.html index 5931f31c..8fd9e267 100644 --- a/forum/skins/default/templates/user.html +++ b/forum/skins/default/templates/user.html @@ -1,4 +1,4 @@ -{% extends "base_content.html" %} +{% extends "base.html" %} {% load extra_tags %} {% load extra_filters %} diff --git a/forum/skins/default/templates/user_reputation.html b/forum/skins/default/templates/user_reputation.html index 954fb44d..f6a33d93 100644 --- a/forum/skins/default/templates/user_reputation.html +++ b/forum/skins/default/templates/user_reputation.html @@ -4,6 +4,7 @@ {% load extra_filters %} {% load humanize %} {% load i18n %} +{% load smart_if %} {% block userjs %} @@ -24,7 +25,11 @@ {% block usercontent %}

-

{% trans "Change in karma per question or answer" %}

+ {% if view_user.id == user.id %} +

{% trans "Your karma change log." %}

+ {% else %} +

{% blocktrans with view_user.username as user_name %}{{user_name}}'s karma change log{% endblocktrans %}

+ {% endif %}
{% for rep in reputation %}

diff --git a/forum/skins/default/templates/users.html b/forum/skins/default/templates/users.html index 78715e05..f3ccd6e9 100644 --- a/forum/skins/default/templates/users.html +++ b/forum/skins/default/templates/users.html @@ -1,4 +1,4 @@ -{% extends "base_content.html" %} +{% extends "base.html" %} {% load extra_tags %} {% load humanize %} diff --git a/forum/templatetags/extra_tags.py b/forum/templatetags/extra_tags.py index a10c473b..83aeb4c7 100755 --- a/forum/templatetags/extra_tags.py +++ b/forum/templatetags/extra_tags.py @@ -467,13 +467,10 @@ class IsManyNode(template.Node): maybe = False for item in self.test_items: is_good = item.resolve(context) - print item, is_good if maybe == True and is_good: - print 'have many!' return self.true_nodelist.render(context) if is_good: maybe = True - print 'have one item' return self.false_nodelist.render(context) @register.tag(name='ifmany') @@ -497,7 +494,6 @@ def ifmany(parser,token): true_nodelist = parser.parse((end_tag,else_tag,)) token = parser.next_token() if token.contents == else_tag: - print 'have else clause' false_nodelist = parser.parse((end_tag,)) token = parser.next_token() else: diff --git a/forum/views/readers.py b/forum/views/readers.py index 01dfc035..7fd30a25 100644 --- a/forum/views/readers.py +++ b/forum/views/readers.py @@ -81,10 +81,10 @@ def questions(request):#a view generating listing of questions, used by 'unanswe search_state = request.session.get('search_state', SearchState()) view_log = request.session['view_log'] - print view_log + #print view_log if view_log.get_previous(1) != 'questions': if view_log.get_previous(2) != 'questions': - print 'user stepped too far, resetting search state' + #print 'user stepped too far, resetting search state' search_state.reset() if request.user.is_authenticated(): diff --git a/forum/views/users.py b/forum/views/users.py index 2356bf38..8af5a1e8 100755 --- a/forum/views/users.py +++ b/forum/views/users.py @@ -16,6 +16,7 @@ from forum.utils.html import sanitize_html from forum import auth import calendar from django.contrib.contenttypes.models import ContentType +from forum.const import USERS_PAGE_SIZE question_type = ContentType.objects.get_for_model(Question) answer_type = ContentType.objects.get_for_model(Answer) @@ -30,8 +31,6 @@ question_revision_type_id = question_revision_type.id answer_revision_type_id = answer_revision_type.id repute_type_id = repute_type.id -USERS_PAGE_SIZE = 35# refactor - move to some constants file - def users(request): is_paginated = True sortby = request.GET.get('sort', 'reputation') -- cgit v1.2.3-1-g7c22