diff options
29 files changed, 574 insertions, 4 deletions
diff --git a/development.log b/development.log new file mode 100644 index 00000000..abe1aac0 --- /dev/null +++ b/development.log @@ -0,0 +1,72 @@ +==Aug 5, 2009 Evgeny== +====Interface changes=== +Merged in my code that: +* allows anonymous posting of Q&A and then login +* per-question email notifications via 'send_email_alerts' command +* allows space character in username +* improves openid login +* makes notification messages sticky - have to click "x" to dismiss +* unanswered questions are now those with no accepted answer +* added following setting parameters: + +settings.MIN_USERNAME_LENGTH = 1 +settings.EMAIL_UNIQUE = True|False +settings.EMAIL_VALIDATION = 'on'|'off' #thought of maybe adding other options so type is string +settings.GOOGLE_SITEMAP_CODE = <string> +settings.GOOGLE_ANALYTICS_KEY = <string> + +===Fixes=== +* fixed incorrect answer count issue in question.html +* translated Twittwer stuff in user_preferences.html +* translated question_retag.html, except one phrase +* added Adolfo's python2.4 fix +* fixed template debugging comments so that they don't break page layout +* reorganized header template so that it takes less vertical space + +===Code changes=== +* wrapped template context settings into a single settings dictionary +* on login anonymous session is recorded so that anonymously posted questions (if any) could be found later +* added models: AnonymousQuestion, AnonymousAnswer, EmailFeed (for notifications) +* User model has two new fields email_key - 32 byte hex hash and email_isvalid - boolean + file sql_scripts/update_2009_07_05_EF.sql will make upgrade to the live database +* added auth_processor to context.py which loads notification messages without deleting them + NOTE: default django auth processor must be removed! +* added ajax actions questionSubscribeUpdates/questionUnsubscribeUpdates + +==Aug 4 2009, Evgeny== +===Changes=== +* commented out LocaleMiddleware - language can be now switched with settings.LANGUAGE_CODE +* added DATABASE_ENGINE line to settings_local +===Merges=== +* Adolfo's slugification of urls +* Added Chaitanyas changes for traditional login/signup and INSTALL file + +==July 26 2009, Evgeny== + +django_authopenid: +considerably changed user interface +[comment] - sorry - this is not done yet + +log/forum/forms.py: +* added tag input validation using regex +* fixed bug with date type mismatch near self.fields['birthday'] = + in EditUserForm.__init__() + +/forum/templatetags/extra_tags.py: +* fixed date type mismatch in get_age() + +/templates/content/js/com.cnprog.post.js: +* fixed bug with post deletion/recovery + +javascript: +* changed to use of non-minified code - better for editing +and debugging + +/templates/question.html: +* fixed display of delete/undelete links + +templates: +added comments in the beginning/end of each template +for the debugging purposes - so that you know which template outputs what html +<!-- user_favorites.html --> +<!-- end user_favorites.html --> diff --git a/forum/management/commands/send_email_alerts.py b/forum/management/commands/send_email_alerts.py index 62f13d69..5e1eb3d0 100644 --- a/forum/management/commands/send_email_alerts.py +++ b/forum/management/commands/send_email_alerts.py @@ -57,6 +57,7 @@ class Command(NoArgsCommand): q_ans = Q_set.filter(answers__author=user) q_ans.cutoff_time = cutoff_time elif feed.feed_type == 'q_all': + if user.tag_filter_setting == 'ignored': ignored_tags = Tag.objects.filter(user_selections__reason='bad',user_selections__user=user) q_all = Q_set.exclude( tags__in=ignored_tags ) @@ -140,7 +141,6 @@ class Command(NoArgsCommand): output.append(_(string) % {'num':number}) def send_email_alerts(self): - #todo: move this to template for user in User.objects.all(): q_list = self.get_updated_questions_for_user(user) diff --git a/forum/managers.py b/forum/managers.py index 3f580bd3..9079e9a6 100644 --- a/forum/managers.py +++ b/forum/managers.py @@ -8,6 +8,28 @@ from forum.models import * from urllib import quote, unquote class QuestionManager(models.Manager): +<<<<<<< HEAD:forum/managers.py + def get_translation_questions(self, orderby, page_size): + questions = self.filter(deleted=False, author__id__in=[28,29]).order_by(orderby)[:page_size] + return questions + + def get_questions_by_pagesize(self, orderby, page_size): + questions = self.filter(deleted=False).order_by(orderby)[:page_size] + return questions + + def get_questions_by_tag(self, tagname, orderby): + questions = self.filter(deleted=False, tags__name = unquote(tagname)).order_by(orderby) + return questions + + def get_unanswered_questions(self, orderby): + questions = self.filter(deleted=False, answer_accepted=False).order_by(orderby) + return questions + + def get_questions(self, orderby): + questions = self.filter(deleted=False).order_by(orderby) + return questions +======= +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/managers.py def update_tags(self, question, tagnames, user): """ @@ -74,11 +96,20 @@ class QuestionManager(models.Manager): Questions with the individual tags will be added to list if above questions are not full. """ #print datetime.datetime.now() +<<<<<<< HEAD:forum/managers.py + from forum.models import Question + questions = list(Question.objects.filter(tagnames = question.tagnames, deleted=False).all()) + + tags_list = question.tags.all() + for tag in tags_list: + extend_questions = Question.objects.filter(tags__id = tag.id, deleted=False)[:50] +======= questions = list(self.filter(tagnames = question.tagnames, deleted=False).all()) tags_list = question.tags.all() for tag in tags_list: extend_questions = self.filter(tags__id = tag.id, deleted=False)[:50] +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/managers.py for item in extend_questions: if item not in questions and len(questions) < 10: questions.append(item) diff --git a/forum/models.py b/forum/models.py index acde1033..fe2121b5 100644 --- a/forum/models.py +++ b/forum/models.py @@ -3,7 +3,10 @@ import datetime import hashlib from urllib import quote_plus, urlencode from django.db import models, IntegrityError +<<<<<<< HEAD:forum/models.py +======= from django.utils.http import urlquote as django_urlquote +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/models.py from django.utils.html import strip_tags from django.core.urlresolvers import reverse from django.contrib.auth.models import User @@ -13,6 +16,10 @@ from django.template.defaultfilters import slugify from django.db.models.signals import post_delete, post_save, pre_save from django.utils.translation import ugettext as _ from django.utils.safestring import mark_safe +<<<<<<< HEAD:forum/models.py +import django.dispatch +import settings +======= from django.contrib.sitemaps import ping_google import django.dispatch from django.conf import settings @@ -20,6 +27,7 @@ import logging if settings.USE_SPHINX_SEARCH == True: from djangosphinx.models import SphinxSearch +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/models.py from forum.managers import * from const import * @@ -102,6 +110,8 @@ class Comment(models.Model): class Meta: ordering = ('-added_at',) db_table = u'comment' +<<<<<<< HEAD:forum/models.py +======= def save(self,**kwargs): super(Comment,self).save(**kwargs) @@ -110,6 +120,7 @@ class Comment(models.Model): except Exception: logging.debug('problem pinging google did you register you sitemap with google?') +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/models.py def __unicode__(self): return self.comment @@ -198,6 +209,10 @@ class Question(models.Model): votes = generic.GenericRelation(Vote) flagged_items = generic.GenericRelation(FlaggedItem) +<<<<<<< HEAD:forum/models.py + objects = QuestionManager() + +======= if settings.USE_SPHINX_SEARCH == True: search = SphinxSearch( index=' '.join(settings.SPHINX_SEARCH_INDICES), @@ -214,6 +229,7 @@ class Question(models.Model): except Exception: logging.debug('problem pinging google did you register you sitemap with google?') +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/models.py def save(self, **kwargs): """ Overridden to manually manage addition of tags when the object @@ -224,10 +240,13 @@ class Question(models.Model): """ initial_addition = (self.id is None) super(Question, self).save(**kwargs) +<<<<<<< HEAD:forum/models.py +======= try: ping_google() except Exception: logging.debug('problem pinging google did you register you sitemap with google?') +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/models.py if initial_addition: tags = Tag.objects.get_or_create_multiple(self.tagname_list(), self.author) @@ -242,7 +261,11 @@ class Question(models.Model): return u','.join([unicode(tag) for tag in self.tagname_list()]) def get_absolute_url(self): +<<<<<<< HEAD:forum/models.py + return '%s%s' % (reverse('question', args=[self.id]), slugify(self.title)) +======= return '%s%s' % (reverse('question', args=[self.id]), django_urlquote(slugify(self.title))) +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/models.py def has_favorite_by_user(self, user): if not user.is_authenticated(): @@ -364,12 +387,15 @@ class FavoriteQuestion(models.Model): def __unicode__(self): return '[%s] favorited at %s' %(self.user, self.added_at) +<<<<<<< HEAD:forum/models.py +======= class MarkedTag(models.Model): TAG_MARK_REASONS = (('good',_('interesting')),('bad',_('ignored'))) tag = models.ForeignKey(Tag, related_name='user_selections') user = models.ForeignKey(User, related_name='tag_selections') reason = models.CharField(max_length=16, choices=TAG_MARK_REASONS) +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/models.py class QuestionRevision(models.Model): """A revision of a Question.""" question = models.ForeignKey(Question, related_name='revisions') @@ -473,6 +499,8 @@ class Answer(models.Model): get_comments = get_object_comments get_last_update_info = post_get_last_update_info +<<<<<<< HEAD:forum/models.py +======= def save(self,**kwargs): super(Answer,self).save(**kwargs) try: @@ -480,6 +508,7 @@ class Answer(models.Model): except Exception: logging.debug('problem pinging google did you register you sitemap with google?') +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/models.py def get_user_vote(self, user): if user.__class__.__name__ == "AnonymousUser": return None @@ -497,7 +526,11 @@ class Answer(models.Model): return self.question.title def get_absolute_url(self): +<<<<<<< HEAD:forum/models.py + return '%s%s#%s' % (reverse('question', args=[self.question.id]), slugify(self.question.title), self.id) +======= return '%s%s#%s' % (reverse('question', args=[self.question.id]), django_urlquote(slugify(self.question.title)), self.id) +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/models.py class Meta: db_table = u'answer' @@ -638,7 +671,11 @@ class Book(models.Model): questions = models.ManyToManyField(Question, related_name='book', db_table='book_question') def get_absolute_url(self): +<<<<<<< HEAD:forum/models.py + return reverse('book', args=[self.short_name]) +======= return reverse('book', args=[django_urlquote(slugify(self.short_name))]) +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/models.py def __unicode__(self): return self.title @@ -728,6 +765,8 @@ User.add_to_class('date_of_birth', models.DateField(null=True, blank=True)) User.add_to_class('about', models.TextField(blank=True)) User.add_to_class('is_username_taken',classmethod(user_is_username_taken)) User.add_to_class('get_q_sel_email_feed_frequency',user_get_q_sel_email_feed_frequency) +<<<<<<< HEAD:forum/models.py +======= User.add_to_class('hide_ignored_questions', models.BooleanField(default=False)) User.add_to_class('tag_filter_setting', models.CharField( @@ -736,6 +775,7 @@ User.add_to_class('tag_filter_setting', default='ignored' ) ) +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/models.py # custom signal tags_updated = django.dispatch.Signal(providing_args=["question"]) diff --git a/forum/templatetags/extra_filters.py b/forum/templatetags/extra_filters.py index 22ec0109..865cd33d 100644 --- a/forum/templatetags/extra_filters.py +++ b/forum/templatetags/extra_filters.py @@ -1,5 +1,8 @@ from django import template +<<<<<<< HEAD:forum/templatetags/extra_filters.py +======= from django.core import serializers +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/templatetags/extra_filters.py from forum import auth import logging @@ -92,7 +95,10 @@ def cnprog_intword(number): return number except: return number +<<<<<<< HEAD:forum/templatetags/extra_filters.py +======= @register.filter def json_serialize(object): return serializers.serialize('json',object) +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/templatetags/extra_filters.py diff --git a/forum/templatetags/extra_tags.py b/forum/templatetags/extra_tags.py index 4f79e497..29fdd831 100644 --- a/forum/templatetags/extra_tags.py +++ b/forum/templatetags/extra_tags.py @@ -252,7 +252,11 @@ def diff_date(date, limen=2): return _('2 days ago') elif days == 1: return _('yesterday') +<<<<<<< HEAD:forum/templatetags/extra_tags.py + elif minutes > 60: +======= elif minutes >= 60: +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/templatetags/extra_tags.py return ungettext('%(hr)d hour ago','%(hr)d hours ago',hours) % {'hr':hours} else: return ungettext('%(min)d min ago','%(min)d mins ago',minutes) % {'min':minutes} @@ -333,8 +337,13 @@ class BlockResourceNode(template.Node): for item in self.items: bit = item.render(context) out += bit +<<<<<<< HEAD:forum/templatetags/extra_tags.py + out = out.replace(' ','') + return os.path.normpath(out) + '?v=%d' % settings.RESOURCE_REVISION +======= out = os.path.normpath(out) + '?v=%d' % settings.RESOURCE_REVISION return out.replace(' ','') +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:forum/templatetags/extra_tags.py @register.tag(name='blockresource') def blockresource(parser,token): diff --git a/forum/views.py b/forum/views.py index 4d214bad..ade6aaa7 100644 --- a/forum/views.py +++ b/forum/views.py @@ -773,6 +773,7 @@ def edit_answer(request, id): QUESTION_REVISION_TEMPLATE = ('<h1>%(title)s</h1>\n' '<div class="text">%(html)s</div>\n' '<div class="tags">%(tags)s</div>') + def question_revisions(request, id): post = get_object_or_404(Question, id=id) revisions = list(post.revisions.all()) @@ -1707,6 +1708,7 @@ def user_responses(request, user_id, user_view): 'username', 'user_id' ) + if len(answers) > 0: answers = [(Response(TYPE_RESPONSE['QUESTION_ANSWERED'], a['title'], a['question_id'], a['answer_id'], a['added_at'], a['username'], a['user_id'], a['html'])) for a in answers] diff --git a/junk.py b/junk.py new file mode 100644 index 00000000..c6c03d27 --- /dev/null +++ b/junk.py @@ -0,0 +1,3 @@ +import os + +print os.path.normpath('/haha//haha') diff --git a/locale/en/LC_MESSAGES/django.mo b/locale/en/LC_MESSAGES/django.mo Binary files differindex ef3007a0..502c1075 100644 --- a/locale/en/LC_MESSAGES/django.mo +++ b/locale/en/LC_MESSAGES/django.mo diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po index ee40fa36..3ce3d53d 100644 --- a/locale/en/LC_MESSAGES/django.po +++ b/locale/en/LC_MESSAGES/django.po @@ -9,7 +9,7 @@ msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2009-12-09 08:54-0800\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"PO-Revision-Date: 2009-12-15 16:53-0600\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" "MIME-Version: 1.0\n" @@ -800,6 +800,24 @@ msgstr "" #: forum/urls.py:72 forum/urls.py:73 msgid "badges/" msgstr "" +"Your subscription is saved, but email address %(email)s needs to be " +"validated, please see <a href='%(details_url)s'>more details here</a>" + +#: forum/views.py:1022 +msgid "email update frequency has been set to daily" +msgstr "" + +#: forum/views.py:1826 +msgid "changes saved" +msgstr "" + +#: forum/views.py:1832 +msgid "email updates canceled" +msgstr "" + +#: forum/views.py:1999 +msgid "uploading images is limited to users with >60 reputation points" +msgstr "sorry, file uploading requires karma >60" #: forum/urls.py:74 msgid "messages/" @@ -824,6 +842,11 @@ msgstr "" #: forum/urls.py:82 msgid "search/" msgstr "" +"<p>Please remember that you can always <a href='%(link)s'>adjust</a> frequency of the " +"email updates or turn them off entirely.<br/>If you believe that this message " +"was sent in an error, please email about it the forum administrator at %(email)" +"s.</p>" +"<p>Sincerely,</p><p>Your friendly Q&A forum server.</p>" #: forum/urls.py:83 msgid "feedback/" @@ -1096,6 +1119,11 @@ msgstr "" #: templates/404.html:43 msgid "see all tags" msgstr "" +"<span class=\"strong big\">You are welcome to start submitting your question " +"anonymously</span>. When you submit the post, you will be redirected to the " +"login/signup page. Your question will be saved in the current session and " +"will be published after you log in. Login/signup process is very simple. " +"Login takes about 30 seconds, initial signup takes a minute or less." #: templates/500.html:22 msgid "sorry, system error" @@ -1112,6 +1140,11 @@ msgstr "" #: templates/500.html:28 msgid "see latest questions" msgstr "" +"<span class='strong big'>Looks like your email address, %(email)s has not " +"yet been validated.</span> To post messages you must verify your email, " +"please see <a href='%(email_validation_faq_url)s'>more details here</a>." +"<br>You can submit your question now and validate email after that. Your " +"question will saved as pending meanwhile. " #: templates/500.html:29 msgid "see tags" @@ -1168,6 +1201,8 @@ msgstr "" #: templates/question.html:48 templates/question_edit.html:28 msgid "show preview" msgstr "" +"If your questions and answers are highly voted, your contribution to this " +"Q&A community will be recognized with the variety of badges." #: templates/answer_edit.html:48 templates/question_edit.html:66 #: templates/question_retag.html:53 templates/revisions_answer.html:38 @@ -2546,6 +2581,7 @@ msgstr[0] "" "<div class=\"questions-count\">%(q_num)s</div><p>question</p>" msgstr[1] "" "\n" + "<div class=\"questions-count\">%(q_num)s</div><p>questions<p>" #: templates/questions.html:201 @@ -3150,6 +3186,13 @@ msgstr "" #: templates/authopenid/complete.html:40 msgid "This account already exists, please use another." msgstr "" +"<p><span class=\"big strong\">You are here for the first time with your %" +"(provider)s login.</span> Please create your <strong>screen name</strong> " +"and save your <strong>email</strong> address. Saved email address will let " +"you <strong>subscribe for the updates</strong> on the most interesting " +"questions and will be used to create and retrieve your unique avatar image - " +"<a href='%(gravatar_faq_url)s'><strong>gravatar</strong></a>.</p>" + #: templates/authopenid/complete.html:55 msgid "Sorry, looks like we have some errors:" @@ -3177,6 +3220,15 @@ msgstr "" #: templates/authopenid/complete.html:91 msgid "Tag filter tool will be your right panel, once you log in." msgstr "" +"<strong>Receive forum updates by email</strong> - this will help our " +"community grow and become more useful.<br/>By default " +"<span class='orange'>Q&A</span> forum sends up to <strong>one " +"email digest per week</strong> - only when there is anything new.<br/>If " +"you like, please adjust this now or any time later from your user account." + +#: templates/authopenid/complete.html:91 +msgid "create account" +msgstr "Signup" #: templates/authopenid/complete.html:92 msgid "create account" @@ -3290,6 +3342,16 @@ msgstr "" #: templates/authopenid/external_legacy_login_info.html:7 msgid "Traditional login information" msgstr "" +"<span class='big strong'>Forgot you password? No problems - just get a new " +"one!</span><br/>Please follow the following steps:<br/>• submit your " +"user name below and check your email<br/>• <strong>follow the " +"activation link</strong> for the new password - sent to you by email and " +"login with the suggested password<br/>• at this you might want to " +"change your password to something you can remember better" + +#: templates/authopenid/sendpw.html:21 +msgid "Reset password" +msgstr "Send me a new password" #: templates/authopenid/external_legacy_login_info.html:12 msgid "how to login with password through external login website" diff --git a/middleware/__init__.py~HEAD b/middleware/__init__.py~HEAD new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/middleware/__init__.py~HEAD diff --git a/session_messages/.svn/all-wcprops b/session_messages/.svn/all-wcprops new file mode 100644 index 00000000..2a15b353 --- /dev/null +++ b/session_messages/.svn/all-wcprops @@ -0,0 +1,23 @@ +K 25 +svn:wc:ra_dav:version-url +V 38 +/svn/!svn/ver/5/trunk/session_messages +END +__init__.py +K 25 +svn:wc:ra_dav:version-url +V 50 +/svn/!svn/ver/5/trunk/session_messages/__init__.py +END +models.py +K 25 +svn:wc:ra_dav:version-url +V 48 +/svn/!svn/ver/2/trunk/session_messages/models.py +END +context_processors.py +K 25 +svn:wc:ra_dav:version-url +V 60 +/svn/!svn/ver/2/trunk/session_messages/context_processors.py +END diff --git a/session_messages/.svn/dir-prop-base b/session_messages/.svn/dir-prop-base new file mode 100644 index 00000000..4cc643b7 --- /dev/null +++ b/session_messages/.svn/dir-prop-base @@ -0,0 +1,6 @@ +K 10 +svn:ignore +V 6 +*.pyc + +END diff --git a/session_messages/.svn/entries b/session_messages/.svn/entries new file mode 100644 index 00000000..67c0db8a --- /dev/null +++ b/session_messages/.svn/entries @@ -0,0 +1,64 @@ +8 + +dir +5 +http://django-session-messages.googlecode.com/svn/trunk/session_messages +http://django-session-messages.googlecode.com/svn + + + +2009-03-10T23:30:03.043791Z +5 +carl.j.meyer +has-props + +svn:special svn:externals svn:needs-lock + + + + + + + + + + + +b8288d2d-7354-0410-af5b-714f73743f4b + +__init__.py +file + + + + +2009-10-25T23:36:02.000000Z +89aa0f71c9973e4889e5fad0b4771a34 +2009-03-10T23:30:03.043791Z +5 +carl.j.meyer + +models.py +file + + + + +2009-10-25T23:36:02.000000Z +c5b4f274dbb06bc66a14f0c18c9115cd +2008-08-14T23:13:23.180432Z +2 +carl.j.meyer + +context_processors.py +file + + + + +2009-10-25T23:36:02.000000Z +24779c7e504d3f7f1918fdf3fe8096bc +2008-08-14T23:13:23.180432Z +2 +carl.j.meyer + diff --git a/session_messages/.svn/format b/session_messages/.svn/format new file mode 100644 index 00000000..45a4fb75 --- /dev/null +++ b/session_messages/.svn/format @@ -0,0 +1 @@ +8 diff --git a/session_messages/.svn/text-base/__init__.py.svn-base b/session_messages/.svn/text-base/__init__.py.svn-base new file mode 100644 index 00000000..0136c888 --- /dev/null +++ b/session_messages/.svn/text-base/__init__.py.svn-base @@ -0,0 +1,36 @@ +""" +Lightweight session-based messaging system. + +Time-stamp: <2009-03-10 19:22:29 carljm __init__.py> + +""" +VERSION = (0, 1, 'pre') + +def create_message (request, message): + """ + Create a message in the current session. + + """ + assert hasattr(request, 'session'), "django-session-messages requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." + + try: + request.session['messages'].append(message) + except KeyError: + request.session['messages'] = [message] + +def get_and_delete_messages (request, include_auth=False): + """ + Get and delete all messages for current session. + + Optionally also fetches user messages from django.contrib.auth. + + """ + assert hasattr(request, 'session'), "django-session-messages requires session middleware to be installed. Edit your MIDDLEWARE_CLASSES setting to insert 'django.contrib.sessions.middleware.SessionMiddleware'." + + messages = request.session.pop('messages', []) + + if include_auth and request.user.is_authenticated(): + messages.extend(request.user.get_and_delete_messages()) + + return messages + diff --git a/session_messages/.svn/text-base/context_processors.py.svn-base b/session_messages/.svn/text-base/context_processors.py.svn-base new file mode 100644 index 00000000..df9840fd --- /dev/null +++ b/session_messages/.svn/text-base/context_processors.py.svn-base @@ -0,0 +1,48 @@ +""" +Context processor for lightweight session messages. + +Time-stamp: <2008-07-19 23:16:19 carljm context_processors.py> + +""" +from django.utils.encoding import StrAndUnicode + +from session_messages import get_and_delete_messages + +def session_messages (request): + """ + Returns session messages for the current session. + + """ + return { 'session_messages': LazyMessages(request) } + +class LazyMessages (StrAndUnicode): + """ + Lazy message container, so messages aren't actually retrieved from + session and deleted until the template asks for them. + + """ + def __init__(self, request): + self.request = request + + def __iter__(self): + return iter(self.messages) + + def __len__(self): + return len(self.messages) + + def __nonzero__(self): + return bool(self.messages) + + def __unicode__(self): + return unicode(self.messages) + + def __getitem__(self, *args, **kwargs): + return self.messages.__getitem__(*args, **kwargs) + + def _get_messages(self): + if hasattr(self, '_messages'): + return self._messages + self._messages = get_and_delete_messages(self.request) + return self._messages + messages = property(_get_messages) + diff --git a/session_messages/.svn/text-base/models.py.svn-base b/session_messages/.svn/text-base/models.py.svn-base new file mode 100644 index 00000000..b67ead6d --- /dev/null +++ b/session_messages/.svn/text-base/models.py.svn-base @@ -0,0 +1,3 @@ +""" +blank models.py +""" diff --git a/settings.py b/settings.py index 087c9fd8..96c20cc3 100755 --- a/settings.py +++ b/settings.py @@ -2,7 +2,6 @@ # Django settings for lanai project. import os.path import sys - SITE_ID = 1 ADMIN_MEDIA_PREFIX = '/forum/admin/media/' diff --git a/templates/authopenid/complete.html b/templates/authopenid/complete.html index c967e8e2..85f6d8b1 100644 --- a/templates/authopenid/complete.html +++ b/templates/authopenid/complete.html @@ -92,6 +92,7 @@ parameters: {% endif %} {{ form1.email }} </div> + <p class='nomargin'>{% trans "Tag filter tool will be your right panel, once you log in." %}</p> <p>{% trans "receive updates motivational blurb" %}</p> <div class='simple-subscribe-options'> {{email_feeds_form.subscribe}} diff --git a/templates/base.html b/templates/base.html index 17a32ef2..d4eb731b 100755 --- a/templates/base.html +++ b/templates/base.html @@ -18,8 +18,12 @@ <script src="http://www.google.com/jsapi" type="text/javascript"></script> <script type="text/javascript">google.load("jquery", "1.2.6");</script> <script type="text/javascript"> +<<<<<<< HEAD:templates/base.html + var i18nLang = '{{settings.LANGUAGE_CODE}}'; +======= var i18nLang = '{{settings.LANGUAGE_CODE}}'; var scriptUrl = '/{{settings.FORUM_SCRIPT_ALIAS}}' +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:templates/base.html </script> <script type='text/javascript' src='{% href "/content/js/com.cnprog.i18n.js" %}'></script> <script type='text/javascript' src='{% href "/content/js/jquery.i18n.js" %}'></script> diff --git a/templates/base_content.html b/templates/base_content.html index eacdc6d0..0ff4a9fd 100644 --- a/templates/base_content.html +++ b/templates/base_content.html @@ -6,9 +6,13 @@ <head> <title>{% block title %}{% endblock %} - {{ settings.APP_TITLE }}</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<<<<<<< HEAD:templates/base_content.html + <meta name="verify-v1" content="{{ settings.GOOGLE_SITEMAP_CODE }}" /> +======= {% if settings.GOOGLE_SITEMAP_CODE %} <meta name="google-site-verification" content="{{ settings.GOOGLE_SITEMAP_CODE }}" /> {% endif %} +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:templates/base_content.html <link rel="shortcut icon" href="{% href "/content/images/favicon.ico" %}" /> <link href="{% href "/content/style/style.css" %}" rel="stylesheet" type="text/css" /> {% spaceless %} @@ -17,8 +21,12 @@ <script src="http://www.google.com/jsapi" type="text/javascript"></script> <script type="text/javascript">google.load("jquery", "1.2.6");</script> <script type="text/javascript"> +<<<<<<< HEAD:templates/base_content.html + var i18nLang = '{{ settings.LANGUAGE_CODE }}'; +======= var i18nLang = '{{ settings.LANGUAGE_CODE }}'; var scriptUrl = '/{{settings.FORUM_SCRIPT_ALIAS}}' +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:templates/base_content.html </script> <script type='text/javascript' src='{% href "/content/js/com.cnprog.i18n.js" %}'></script> <script type='text/javascript' src='{% href "/content/js/jquery.i18n.js" %}'></script> diff --git a/templates/content/js/com.cnprog.admin.js b/templates/content/js/com.cnprog.admin.js index 39dff48c..974dce23 100644 --- a/templates/content/js/com.cnprog.admin.js +++ b/templates/content/js/com.cnprog.admin.js @@ -3,7 +3,11 @@ $(document).ready( function(){ success: function(a,b){$('.admin #action_status').html($.i18n._('changes saved'));}, dataType:'json', timeout:5000, +<<<<<<< HEAD:templates/content/js/com.cnprog.admin.js + url: $.i18n._('/') + $.i18n._('moderate-user/') + viewUserID + '/' +======= url: scriptUrl + $.i18n._('moderate-user/') + viewUserID + '/' +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:templates/content/js/com.cnprog.admin.js }; var form = $('.admin #moderate_user_form').ajaxForm(options); var box = $('.admin input#id_is_approved').click(function(){ diff --git a/templates/content/js/com.cnprog.i18n.js b/templates/content/js/com.cnprog.i18n.js index da9bf396..58cb8f16 100644 --- a/templates/content/js/com.cnprog.i18n.js +++ b/templates/content/js/com.cnprog.i18n.js @@ -59,6 +59,10 @@ var i18nZh = { }; var i18nEn = { +<<<<<<< HEAD:templates/content/js/com.cnprog.i18n.js + '/':'/', +======= +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:templates/content/js/com.cnprog.i18n.js 'need >15 points to report spam':'need >15 points to report spam ', '>15 points requried to upvote':'>15 points required to upvote ', 'tags cannot be empty':'please enter at least one tag', diff --git a/templates/content/js/wmd/wmd.js b/templates/content/js/wmd/wmd.js index e396d3cb..2234250b 100644 --- a/templates/content/js/wmd/wmd.js +++ b/templates/content/js/wmd/wmd.js @@ -54,7 +54,11 @@ Attacklab.wmdBase = function(){ var uploadImageHTML ="<div>" + $.i18n._('upload image') + "</div>" + "<input type=\"file\" name=\"file-upload\" id=\"file-upload\" size=\"26\" "+ "onchange=\"return ajaxFileUpload($('#image-url'));\"/><br>" + +<<<<<<< HEAD:templates/content/js/wmd/wmd.js + "<img id=\"loading\" src=\"" + $.i18n._("/") + "content/images/indicator.gif\" style=\"display:none;\"/>"; +======= "<img id=\"loading\" src=\"" + scriptUrl + "content/images/indicator.gif\" style=\"display:none;\"/>"; +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:templates/content/js/wmd/wmd.js // The default text that appears in the dialog input box when entering // links. diff --git a/templates/unanswered.html b/templates/unanswered.html new file mode 100644 index 00000000..80a23631 --- /dev/null +++ b/templates/unanswered.html @@ -0,0 +1,132 @@ +{% extends "base.html" %} +<!-- unanswered.html --> +{% load extra_tags %} +{% load i18n %} +{% load humanize %} +{% load extra_filters %} +{% load smart_if %} +{% block title %}{% spaceless %}{% trans "Unanswered questions" %}{% endspaceless %}{% endblock %} +{% block forejs %} + <script type="text/javascript"> + $().ready(function(){ + $("#nav_unanswered").attr('className',"on"); + }); + + </script> +{% endblock %} +{% block content %} +<div class="tabBar"> + <span class="headQuestions">{% trans "Unanswered questions" %}</span> + <div class="tabsA"> + <a id="latest" href="{% url unanswered %}?sort=latest" class="on" title="{% trans "most recently asked questions" %}">{% trans "newest" %}</a> + </div> +</div> +<div id="listA"> + {% for question in questions.object_list %} + <div class="qstA"> + <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 forum.views.tag tag|urlencode %}" title="{% trans "see questions tagged" %}'{{ tag }}'{% trans "using tags" %}" rel="tag">{{ tag }}</a> + {% endfor %} + </div> + </div> + {% endfor %} +</div> +{% endblock %} + +{% block tail %} + <div class="pager"> + {% cnprog_paginator context %} + </div> + <div class="pagesize"> + {% cnprog_pagesize context %} + </div> +{% endblock %} + +{% block sidebar %} +<div class="boxC"> + {% blocktrans with questions_count|intcomma as num_q %}have {{num_q}} unanswered questions{% endblocktrans %} + <!---<p>问题按 <strong>问题创建时间</strong> 排序。最新加入的问题将显示在最前面。</p>--> +</div> +<div class="boxC"> + <h3 class="subtitle">{% trans "Related tags" %}</h3> + <div class="body"> + <div class="tags"> + {% for tag in tags %} + <a rel="tag" title="{% trans "see questions tagged"%}'{{ tag.name }}'{% trans "using tags" %}" href="{% url forum.views.tag tag.name|urlencode %}">{{ tag.name }}</a> + <span class="tag-number"> × {{ tag.used_count|intcomma }}</span> + <br/> + {% endfor %} + <br/> + </div> + </div> +</div> + +{% endblock %} +<!-- end unanswered.html --> diff --git a/templates/user_email_subscriptions.html b/templates/user_email_subscriptions.html index c0204cbc..10440529 100644 --- a/templates/user_email_subscriptions.html +++ b/templates/user_email_subscriptions.html @@ -13,9 +13,12 @@ {% endif %} <form method="POST"> {% include "edit_user_email_feeds_form.html" %} +<<<<<<< HEAD:templates/user_email_subscriptions.html +======= <table class='form-as-table'> {{tag_filter_selection_form}} </table> +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:templates/user_email_subscriptions.html <div class="submit-row text-align-right"> <input type="submit" class="submit" name="save" value="{% trans "Update" %}"/> <input type="submit" class="submit" name="stop_email" value="{% trans "Stop sending email" %}"/> diff --git a/templates/user_info.html b/templates/user_info.html index c550e13f..4ebcddd6 100644 --- a/templates/user_info.html +++ b/templates/user_info.html @@ -19,7 +19,7 @@ <tr> <td align="center"> <div class="scoreNumber">{{view_user.reputation|intcomma}}</div> - <p><b style="color:#777;">{% trans "reputation" %}</b></p> + <p><b style="color:#777;">{% trans "karma" %}</b></p> </td> </tr> </table> diff --git a/templates/user_stats.html b/templates/user_stats.html index ecc39807..b72f5750 100644 --- a/templates/user_stats.html +++ b/templates/user_stats.html @@ -97,9 +97,14 @@ <td width="180" valign="top"> {% for tag in user_tags%} <a rel="tag" +<<<<<<< HEAD:templates/user_stats.html + title="{% blocktrans %}see other questions tagged '{{ tag }}' {% endblocktrans %}" + href="{% url forum.views.tag tag|urlencode %}">{{tag.name}}</a><span class="tag-number"> × {{ tag.used_count|intcomma }}</span><br/> +======= title="{% blocktrans with tag.name as tag_name %}see other questions with {{view_user}}'s contributions tagged '{{ tag_name }}' {% endblocktrans %}" href="{% url forum.views.tag tag|urlencode %}?user={{view_user.username}}">{{tag.name}}</a> <span class="tag-number">× {{ tag.user_tag_usage_count|intcomma }}</span><br/> +>>>>>>> 82d35490db90878f013523c4d1a5ec3af2df8b23:templates/user_stats.html {% if forloop.counter|divisibleby:"10" %} </td> <td width="180" valign="top"> |