Permalink
Browse files

Merge branch 'master' of git://github.com/evgenyfadeev/CNPROG into ev…

…genyfadeev/master

Conflicts:
	forum/auth.py
	forum/models.py
	forum/views.py
  • Loading branch information...
2 parents 0240902 + cdc85fd commit 604bd7c1964dfed98c28ddf88bfe6711aef840da Adolfo Fitoria committed Aug 6, 2009
Showing with 11,327 additions and 5,885 deletions.
  1. +0 −1 .gitignore
  2. +2 −0 INSTALL
  3. +4 −0 TODO
  4. +8 −0 cnprog.wsgi
  5. +33 −2 context.py
  6. +49 −7 development.log
  7. +45 −37 django_authopenid/forms.py
  8. +1 −1 django_authopenid/middleware.py
  9. +4 −1 django_authopenid/urls.py
  10. +185 −23 django_authopenid/views.py
  11. +4 −0 drop-all-tables.sh
  12. +4 −1 forum/admin.py
  13. +444 −0 forum/auth.py
  14. +43 −43 forum/feed.py
  15. +209 −193 forum/forms.py
  16. +349 −348 forum/management/commands/once_award_badges.py
  17. +41 −0 forum/management/commands/send_email_alerts.py
  18. +259 −259 forum/managers.py
  19. +804 −0 forum/models.py
  20. +82 −82 forum/templatetags/extra_filters.py
  21. +240 −240 forum/templatetags/extra_tags.py
  22. +74 −75 forum/user.py
  23. +2,085 −0 forum/views.py
  24. BIN locale/en/LC_MESSAGES/django.mo
  25. +1,117 −499 locale/en/LC_MESSAGES/django.po
  26. BIN locale/es/LC_MESSAGES/django.mo
  27. +1,551 −834 locale/es/LC_MESSAGES/django.po
  28. BIN locale/zh_CN/LC_MESSAGES/django.mo
  29. +355 −388 locale/zh_CN/LC_MESSAGES/django.po
  30. +11 −11 manage.py
  31. +1 −0 rmpyc
  32. +107 −99 settings.py
  33. +25 −0 settings_local.py
  34. +3 −0 sql_scripts/update_2009_07_05_EF.sql
  35. +1 −1 templates/404.html
  36. +2 −2 templates/500.html
  37. +9 −59 templates/about.html
  38. +1 −1 templates/answer_edit.html
  39. +43 −44 templates/answer_edit_tips.html
  40. +21 −31 templates/ask.html
  41. +73 −27 templates/authopenid/changeemail.html
  42. +2 −0 templates/authopenid/changeopenid.html
  43. +2 −0 templates/authopenid/changepw.html
  44. +9 −8 templates/authopenid/complete.html
  45. +9 −8 templates/authopenid/confirm_email.txt
  46. +2 −0 templates/authopenid/delete.html
  47. +15 −0 templates/authopenid/email_validation.txt
  48. +2 −1 templates/authopenid/failure.html
  49. +2 −0 templates/authopenid/sendpw.html
  50. +9 −9 templates/authopenid/sendpw_email.txt
  51. +2 −0 templates/authopenid/settings.html
  52. +101 −21 templates/authopenid/signin.html
  53. +3 −0 templates/authopenid/signup.html
  54. +1 −1 templates/badge.html
  55. +8 −6 templates/badges.html
  56. +15 −14 templates/base.html
  57. +16 −11 templates/base_content.html
  58. +1 −1 templates/book.html
  59. +1 −1 templates/close.html
  60. BIN templates/content/jquery-openid/images/aol.gif
  61. BIN templates/content/jquery-openid/images/blogger.ico
  62. BIN templates/content/jquery-openid/images/claimid.ico
  63. BIN templates/content/jquery-openid/images/facebook.gif
  64. BIN templates/content/jquery-openid/images/flickr.ico
  65. BIN templates/content/jquery-openid/images/google.gif
  66. BIN templates/content/jquery-openid/images/livejournal.ico
  67. BIN templates/content/jquery-openid/images/myopenid.ico
  68. BIN templates/content/jquery-openid/images/openid-inputicon.gif
  69. BIN templates/content/jquery-openid/images/openid.gif
  70. BIN templates/content/jquery-openid/images/openidico.png
  71. BIN templates/content/jquery-openid/images/technorati.ico
  72. BIN templates/content/jquery-openid/images/verisign.ico
  73. BIN templates/content/jquery-openid/images/vidoop.ico
  74. BIN templates/content/jquery-openid/images/wordpress.ico
  75. BIN templates/content/jquery-openid/images/yahoo.gif
  76. +92 −0 templates/content/jquery-openid/jquery.openid.js
  77. +33 −0 templates/content/jquery-openid/openid.css
  78. +67 −67 templates/content/js/com.cnprog.editor.js
  79. +5 −3 templates/content/js/com.cnprog.i18n.js
  80. +631 −616 templates/content/js/com.cnprog.post.js
  81. +1 −1 templates/content/js/com.cnprog.utils.js
  82. +195 −195 templates/content/js/jquery.ajaxfileupload.js
  83. +6 −6 templates/content/style/default.css
  84. +1 −1 templates/content/style/openid.css
  85. +1,118 −999 templates/content/style/style.css
  86. +132 −98 templates/faq.html
  87. +33 −28 templates/footer.html
  88. +70 −70 templates/header.html
  89. +6 −4 templates/index.html
  90. +2 −2 templates/logout.html
  91. +3 −1 templates/pagesize.html
  92. +8 −6 templates/paginator.html
  93. +1 −1 templates/privacy.html
  94. +14 −7 templates/question.html
  95. +1 −1 templates/question_edit.html
  96. +11 −14 templates/question_retag.html
  97. +58 −30 templates/questions.html
  98. +1 −1 templates/revisions_answer.html
  99. +1 −2 templates/revisions_question.html
  100. +1 −0 templates/tags.html
  101. +1 −1 templates/unanswered.html
  102. BIN templates/upfiles/1245715031297631.png
  103. BIN templates/upfiles/12457157052552259.png
  104. +31 −33 templates/user.html
  105. +1 −1 templates/user_edit.html
  106. +1 −1 templates/user_favorites.html
  107. +2 −0 templates/user_info.html
  108. +9 −6 templates/user_preferences.html
  109. +1 −1 templates/user_recent.html
  110. +1 −1 templates/user_reputation.html
  111. +1 −1 templates/user_responses.html
  112. +1 −1 templates/user_stats.html
  113. +0 −2 templates/user_tabs.html
  114. +1 −1 templates/user_votes.html
  115. +1 −0 templates/users.html
  116. +67 −64 urls.py
  117. +92 −92 utils/cache.py
  118. +51 −51 utils/html.py
  119. +86 −86 utils/lists.py
View
@@ -1,4 +1,3 @@
-settings_local.py
*.pyc
*.swp
nbproject
View
@@ -15,6 +15,8 @@ Used for HTML sanitizer
5. Markdown2
http://code.google.com/p/python-markdown2/
+6. Django Debug Toolbar
+http://github.com/robhudson/django-debug-toolbar/tree/master
INSTALL STEPS:
-----------------------------------------------
View
@@ -0,0 +1,4 @@
+*check change email function - there is a strange 'password' field in form
+*make reusable question-block template for index questions unanswered - get rid of copy-paste
+*unused votes count in user profile not working - left that commented out in templates/user_info.html
+*badge award notification messages need to be set fixed at place where badges are awarded
View
@@ -0,0 +1,8 @@
+import os
+import sys
+
+sys.path.append('/var/www/vhosts')
+os.environ['DJANGO_SETTINGS_MODULE'] = 'cnprog.settings'
+
+import django.core.handlers.wsgi
+application = django.core.handlers.wsgi.WSGIHandler()
View
@@ -1,9 +1,40 @@
from django.conf import settings
def application_settings(context):
- return {
+ my_settings = {
'APP_TITLE' : settings.APP_TITLE,
'APP_URL' : settings.APP_URL,
'APP_KEYWORDS' : settings.APP_KEYWORDS,
'APP_DESCRIPTION' : settings.APP_DESCRIPTION,
- 'APP_INTRO' : settings.APP_INTRO
+ 'APP_INTRO' : settings.APP_INTRO,
+ 'EMAIL_VALIDATION': settings.EMAIL_VALIDATION,
+ 'LANGUAGE_CODE': settings.LANGUAGE_CODE,
+ 'GOOGLE_SITEMAP_CODE':settings.GOOGLE_SITEMAP_CODE,
+ 'GOOGLE_ANALYTICS_KEY':settings.GOOGLE_ANALYTICS_KEY,
}
+ return {'settings':my_settings}
+
+def auth_processor(request):
+ """
+ Returns context variables required by apps that use Django's authentication
+ system.
+
+ If there is no 'user' attribute in the request, uses AnonymousUser (from
+ django.contrib.auth).
+ """
+ if hasattr(request, 'user'):
+ user = request.user
+ if user.is_authenticated():
+ messages = user.message_set.all()
+ else:
+ messages = None
+ else:
+ from django.contrib.auth.models import AnonymousUser
+ user = AnonymousUser()
+ messages = None
+
+ from django.core.context_processors import PermWrapper
+ return {
+ 'user': user,
+ 'messages': messages,
+ 'perms': PermWrapper(user),
+ }
View
@@ -1,27 +1,69 @@
-# development
+==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'] =
+* 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()
+* fixed date type mismatch in get_age()
/templates/content/js/com.cnprog.post.js:
-- fixed bug with post deletion/recovery
+* fixed bug with post deletion/recovery
javascript:
-- changed to use of non-minified code - better for editing
+* changed to use of non-minified code - better for editing
and debugging
/templates/question.html:
-- fixed display of delete/undelete links
+* fixed display of delete/undelete links
templates:
added comments in the beginning/end of each template
@@ -158,7 +158,7 @@ def clean_username(self):
raise forms.ValidationError(_('invalid user name'))
if self.cleaned_data['username'] in RESERVED_NAMES:
raise forms.ValidationError(_('sorry, this name can not be used, please try another'))
- if len(self.cleaned_data['username']) < 3:
+ if len(self.cleaned_data['username']) < settings.MIN_USERNAME_LENGTH:
raise forms.ValidationError(_('username too short'))
try:
user = User.objects.get(
@@ -171,19 +171,22 @@ def clean_username(self):
raise forms.ValidationError(_('this name is already in use - please try anoter'))
def clean_email(self):
- """For security reason one unique email in database"""
+ """Optionally, for security reason one unique email in database"""
if 'email' in self.cleaned_data:
- try:
- user = User.objects.get(email = self.cleaned_data['email'])
- except User.DoesNotExist:
+ if settings.EMAIL_UNIQUE == True:
+ try:
+ user = User.objects.get(email = self.cleaned_data['email'])
+ except User.DoesNotExist:
+ return self.cleaned_data['email']
+ except User.MultipleObjectsReturned:
+ raise forms.ValidationError(u'There is already more than one \
+ account registered with that e-mail address. Please try \
+ another.')
+ raise forms.ValidationError(_("This email is already \
+ registered in our database. Please choose another."))
+ else:
return self.cleaned_data['email']
- except User.MultipleObjectsReturned:
- raise forms.ValidationError(u'There is already more than one \
- account registered with that e-mail address. Please try \
- another.')
- raise forms.ValidationError(_("This email is already \
- registered in our database. Please choose another."))
-
+ #what if not???
class OpenidVerifyForm(forms.Form):
""" openid verify form (associate an openid with an account) """
@@ -204,8 +207,7 @@ def clean_username(self):
""" validate username """
if 'username' in self.cleaned_data:
if not username_re.search(self.cleaned_data['username']):
- raise forms.ValidationError(_("Usernames can only contain \
- letters, numbers and underscores"))
+ raise forms.ValidationError(_('invalid user name'))
try:
user = User.objects.get(
username__exact = self.cleaned_data['username']
@@ -241,7 +243,7 @@ def get_user(self):
attrs_dict = { 'class': 'required' }
-username_re = re.compile(r'^\w+$')
+username_re = re.compile(r'^[\w ]+$')
class RegistrationForm(forms.Form):
""" legacy registration form """
@@ -286,17 +288,20 @@ def clean_email(self):
""" validate if email exist in database
:return: raise error if it exist """
if 'email' in self.cleaned_data:
- try:
- user = User.objects.get(email = self.cleaned_data['email'])
- except User.DoesNotExist:
+ if settings.EMAIL_UNIQUE == True:
+ try:
+ user = User.objects.get(email = self.cleaned_data['email'])
+ except User.DoesNotExist:
+ return self.cleaned_data['email']
+ except User.MultipleObjectsReturned:
+ raise forms.ValidationError(u'There is already more than one \
+ account registered with that e-mail address. Please try \
+ another.')
+ raise forms.ValidationError(u'This email is already registered \
+ in our database. Please choose another.')
+ else:
return self.cleaned_data['email']
- except User.MultipleObjectsReturned:
- raise forms.ValidationError(u'There is already more than one \
- account registered with that e-mail address. Please try \
- another.')
- raise forms.ValidationError(u'This email is already registered \
- in our database. Please choose another.')
- return self.cleaned_data['email']
+ #what if not?
def clean_password2(self):
"""
@@ -361,18 +366,21 @@ def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, \
def clean_email(self):
""" check if email don't exist """
if 'email' in self.cleaned_data:
- if self.user.email != self.cleaned_data['email']:
- try:
- user = User.objects.get(email = self.cleaned_data['email'])
- except User.DoesNotExist:
- return self.cleaned_data['email']
- except User.MultipleObjectsReturned:
- raise forms.ValidationError(u'There is already more than one \
- account registered with that e-mail address. Please try \
- another.')
- raise forms.ValidationError(u'This email is already registered \
- in our database. Please choose another.')
- return self.cleaned_data['email']
+ if settings.EMAIL_UNIQUE == True:
+ if self.user.email != self.cleaned_data['email']:
+ try:
+ user = User.objects.get(email = self.cleaned_data['email'])
+ except User.DoesNotExist:
+ return self.cleaned_data['email']
+ except User.MultipleObjectsReturned:
+ raise forms.ValidationError(u'There is already more than one \
+ account registered with that e-mail address. Please try \
+ another.')
+ raise forms.ValidationError(u'This email is already registered \
+ in our database. Please choose another.')
+ else:
+ return self.cleaned_data['email']
+ #what if not?
def clean_password(self):
@@ -21,4 +21,4 @@ def process_response(self, request, response):
mimeparse.best_match(['text/html', 'application/xrds+xml'],
request.META['HTTP_ACCEPT']) == 'application/xrds+xml':
return HttpResponseRedirect(reverse('yadis_xrdf'))
- return response
+ return response
@@ -7,6 +7,8 @@
url(r'^yadis.xrdf$', 'xrdf', name='yadis_xrdf'),
# manage account registration
url(r'^%s$' % _('signin/'), 'signin', name='user_signin'),
+ url(r'^%s%s$' % (_('signin/'),_('newquestion/')), 'signin', kwargs = {'newquestion':True}),
+ url(r'^%s%s$' % (_('signin/'),_('newanswer/')), 'signin', kwargs = {'newanswer':True}),
url(r'^%s$' % _('signout/'), 'signout', name='user_signout'),
url(r'^%s%s$' % (_('signin/'), _('complete/')), 'complete_signin',
name='user_complete_signin'),
@@ -21,7 +23,8 @@
# manage account settings
#url(r'^$', 'account_settings', name='user_account_settings'),
#url(r'^%s$' % _('password/'), 'changepw', name='user_changepw'),
- #url(r'^%s$' % _('email/'), 'changeemail', name='user_changeemail'),
+ url(r'^%s$' % 'email/', 'changeemail', name='user_changeemail',kwargs = {'action':'change'}),
+ url(r'^%s%s$' % ('email/','validate/'), 'changeemail', name='user_changeemail',kwargs = {'action':'validate'}),
#url(r'^%s$' % _('openid/'), 'changeopenid', name='user_changeopenid'),
url(r'^%s$' % _('delete/'), 'delete', name='user_delete'),
)
Oops, something went wrong.

0 comments on commit 604bd7c

Please sign in to comment.