Permalink
Browse files

update to revidion 54 in svn

  • Loading branch information...
1 parent ec7e971 commit 1b3e97f9b85e4c2c861e82883816e729997ad0ca hrc committed Apr 19, 2010
Showing with 8,278 additions and 1,891 deletions.
  1. +270 −219 .idea/workspace.xml
  2. +26 −37 forum/activity.py
  3. +20 −20 forum/authentication/__init__.py
  4. +9 −1 forum/badges/base.py
  5. +20 −20 forum/forms.py
  6. +433 −0 forum/migrations/0006_auto__add_node__add_field_vote_node__add_field_comment_node__add_field.py
  7. +549 −0 forum/migrations/0007_q_and_a_to_node.py
  8. +424 −0 forum/migrations/0008_auto__add_noderevision__del_field_vote_object_id__del_field_vote_conte.py
  9. +414 −0 forum/migrations/0009_convert_revisions.py
  10. +576 −0 forum/migrations/0010_auto__del_questionrevision__del_answerrevision__del_field_answer_vote_.py
  11. +323 −0 forum/migrations/0011_auto__add_field_node_active_revision.py
  12. +327 −0 forum/migrations/0012_set_active_revision.py
  13. +344 −0 forum/migrations/0013_auto__del_anonymousquestion__del_anonymousanswer__add_anonymousnode.py
  14. +310 −0 forum/migrations/0014_auto__add_field_question_accepted_answer.py
  15. +320 −0 forum/migrations/0015_accepted_answer_changes.py
  16. +310 −0 forum/migrations/0016_auto__del_field_question_answer_accepted__chg_field_question_node_ptr.py
  17. +312 −0 forum/migrations/0017_auto__add_field_repute_node__add_field_repute_canceled.py
  18. +376 −0 forum/migrations/0018_comments_to_node.py
  19. +322 −0 forum/migrations/0019_auto__del_likedcomment__del_comment__add_field_node_abs_parent__chg_fi.py
  20. +300 −0 forum/migrations/0020_create_absolute_parents.py
  21. +304 −0 forum/migrations/0021_create_new_pg_fts_triggers.py
  22. +16 −0 forum/migrations/__init__.py
  23. +11 −6 forum/models/__init__.py
  24. +20 −72 forum/models/answer.py
  25. +41 −77 forum/models/base.py
  26. +57 −0 forum/models/comment.py
  27. +7 −84 forum/models/meta.py
  28. +226 −0 forum/models/node.py
  29. +29 −151 forum/models/question.py
  30. +7 −3 forum/models/repute.py
  31. +1 −1 forum/models/tag.py
  32. +19 −19 forum/models/user.py
  33. +31 −22 forum/reputation.py
  34. +2 −2 forum/settings/email.py
  35. +13 −34 forum/skins/default/media/js/osqa.main.js
  36. +1 −1 forum/skins/default/media/style/style.css
  37. +2 −1 forum/skins/default/templates/about.html
  38. +1 −1 forum/skins/default/templates/base.html
  39. +7 −0 forum/skins/default/templates/node/accept_button.html
  40. +83 −0 forum/skins/default/templates/node/comments.html
  41. +8 −0 forum/skins/default/templates/node/favorite_mark.html
  42. +11 −0 forum/skins/default/templates/node/post_controls.html
  43. +11 −0 forum/skins/default/templates/node/revision.html
  44. +12 −0 forum/skins/default/templates/node/vote_buttons.html
  45. +28 −0 forum/skins/default/templates/notifications/feedback.html
  46. +1 −1 forum/skins/default/templates/notifications/newmember.html
  47. +4 −10 forum/skins/default/templates/osqaadmin/index.html
  48. +1 −1 forum/skins/default/templates/question.html
  49. +2 −2 forum/skins/default/templates/question_list/item.html
  50. +1 −1 forum/skins/default/templates/question_list/sort_tabs.html
  51. +0 −14 forum/skins/default/templates/questions.html
  52. +5 −13 forum/skins/default/templates/revisions_question.html
  53. +3 −3 forum/skins/default/templates/user.html
  54. +18 −0 forum/skins/default/templates/users/activity.html
  55. +95 −0 forum/skins/default/templates/users/edit.html
  56. +4 −0 forum/skins/default/templates/users/footer.html
  57. +114 −0 forum/skins/default/templates/users/info.html
  58. +11 −0 forum/skins/default/templates/users/questions.html
  59. +12 −0 forum/skins/default/templates/users/recent.html
  60. +42 −0 forum/skins/default/templates/users/reputation.html
  61. +23 −0 forum/skins/default/templates/users/responses.html
  62. +135 −0 forum/skins/default/templates/users/stats.html
  63. +126 −0 forum/skins/default/templates/users/subscriptions.html
  64. +27 −0 forum/skins/default/templates/users/tabs.html
  65. +73 −0 forum/skins/default/templates/users/users.html
  66. +28 −0 forum/skins/default/templates/users/votes.html
  67. +11 −11 forum/subscriptions.py
  68. +2 −2 forum/templatetags/extra_tags.py
  69. +126 −0 forum/templatetags/node_tags.py
  70. +1 −1 forum/templatetags/question_list_tags.py
  71. +46 −0 forum/templatetags/user_tags.py
  72. +15 −7 forum/urls.py
  73. +2 −1 forum/utils/mail.py
  74. +17 −1 forum/views/admin.py
  75. +23 −32 forum/views/commands.py
  76. +2 −2 forum/views/decorators.py
  77. +17 −22 forum/views/meta.py
  78. +65 −66 forum/views/readers.py
  79. +67 −674 forum/views/users.py
  80. +102 −203 forum/views/writers.py
  81. +27 −26 forum_modules/default_badges/badges.py
  82. +2 −2 forum_modules/pgfulltext/handlers.py
  83. +13 −11 forum_modules/pgfulltext/management.py
  84. +43 −13 forum_modules/pgfulltext/pg_fts_install.sql
  85. +1 −1 settings.py
  86. +38 −0 test.py
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,50 +1,41 @@
import datetime
from django.db.models.signals import post_save
from forum.models import *
-from forum.models.base import marked_deleted
-from forum.models.meta import vote_canceled
+from forum.models.base import marked_deleted, mark_canceled
+from forum.models.node import node_create
+from forum.models.answer import answer_accepted
from forum.authentication import user_updated
from forum.const import *
-def record_ask_event(instance, created, **kwargs):
- if created:
- activity = Activity(user=instance.author, active_at=instance.added_at, content_object=instance, activity_type=TYPE_ACTIVITY_ASK_QUESTION)
- activity.save()
-
-post_save.connect(record_ask_event, sender=Question)
-
-
-def record_answer_event(instance, created, **kwargs):
- if created:
- activity = Activity(user=instance.author, active_at=instance.added_at, content_object=instance, activity_type=TYPE_ACTIVITY_ANSWER)
- activity.save()
+def record_ask_event(instance, **kwargs):
+ activity = Activity(user=instance.author, active_at=instance.added_at, content_object=instance, activity_type=TYPE_ACTIVITY_ASK_QUESTION)
+ activity.save()
-post_save.connect(record_answer_event, sender=Answer)
+node_create.connect(record_ask_event, sender=Question)
-def record_comment_event(instance, created, **kwargs):
- if created:
- act_type = (instance.content_object.__class__ is Question) and TYPE_ACTIVITY_COMMENT_QUESTION or TYPE_ACTIVITY_COMMENT_ANSWER
- activity = Activity(user=instance.user, active_at=instance.added_at, content_object=instance, activity_type=act_type)
- activity.save()
+def record_answer_event(instance, **kwargs):
+ activity = Activity(user=instance.author, active_at=instance.added_at, content_object=instance, activity_type=TYPE_ACTIVITY_ANSWER)
+ activity.save()
-post_save.connect(record_comment_event, sender=Comment)
+node_create.connect(record_answer_event, sender=Answer)
-def record_question_revision_event(instance, created, **kwargs):
- if created and instance.revision <> 1:
- activity = Activity(user=instance.author, active_at=instance.revised_at, content_object=instance, activity_type=TYPE_ACTIVITY_UPDATE_QUESTION)
- activity.save()
+def record_comment_event(instance, **kwargs):
+ act_type = (instance.content_object.__class__ is Question) and TYPE_ACTIVITY_COMMENT_QUESTION or TYPE_ACTIVITY_COMMENT_ANSWER
+ activity = Activity(user=instance.user, active_at=instance.added_at, content_object=instance, activity_type=act_type)
+ activity.save()
-post_save.connect(record_question_revision_event, sender=QuestionRevision)
+node_create.connect(record_comment_event, sender=Comment)
-def record_answer_revision_event(instance, created, **kwargs):
- if created and instance.revision <> 1:
- activity = Activity(user=instance.author, active_at=instance.revised_at, content_object=instance, activity_type=TYPE_ACTIVITY_UPDATE_ANSWER)
+def record_revision_event(instance, created, **kwargs):
+ if created and instance.revision <> 1 and instance.node.node_type in ('question', 'answer',):
+ activity_type = instance.node.node_type == 'question' and TYPE_ACTIVITY_UPDATE_QUESTION or TYPE_ACTIVITY_UPDATE_ANSWER
+ activity = Activity(user=instance.author, active_at=instance.revised_at, content_object=instance, activity_type=activity_type)
activity.save()
-post_save.connect(record_answer_revision_event, sender=AnswerRevision)
+post_save.connect(record_revision_event, sender=NodeRevision)
def record_award_event(instance, created, **kwargs):
@@ -56,13 +47,11 @@ def record_award_event(instance, created, **kwargs):
post_save.connect(record_award_event, sender=Award)
-def record_answer_accepted(instance, created, **kwargs):
- if not created and 'accepted' in instance.get_dirty_fields() and instance.accepted:
- activity = Activity(user=instance.question.author, active_at=datetime.datetime.now(), \
- content_object=instance, activity_type=TYPE_ACTIVITY_MARK_ANSWER)
- activity.save()
+def record_answer_accepted(answer, user, **kwargs):
+ activity = Activity(user=user, active_at=datetime.datetime.now(), content_object=answer, activity_type=TYPE_ACTIVITY_MARK_ANSWER)
+ activity.save()
-post_save.connect(record_answer_accepted, sender=Answer)
+answer_accepted.connect(record_answer_accepted)
def update_last_seen(instance, **kwargs):
@@ -88,7 +77,7 @@ def record_cancel_vote(instance, **kwargs):
activity = Activity(user=instance.user, active_at=datetime.datetime.now(), content_object=instance, activity_type=act_type)
activity.save()
-vote_canceled.connect(record_cancel_vote)
+mark_canceled.connect(record_cancel_vote, sender=Vote)
def record_delete_post(instance, **kwargs):
@@ -36,23 +36,23 @@ def consumer(self):
user_logged_in = django.dispatch.Signal(providing_args=["user", "old_session"])
user_updated = django.dispatch.Signal(providing_args=["instance", "updated_by"])
-def post_stored_anonymous_content(user,old_session,**kwargs):
- from forum.models import AnonymousQuestion, AnonymousAnswer
- aq_list = AnonymousQuestion.objects.filter(session_key = old_session)
- aa_list = AnonymousAnswer.objects.filter(session_key = old_session)
- import settings
- if settings.EMAIL_VALIDATION == 'on':#add user to the record
- for aq in aq_list:
- aq.author = user
- aq.save()
- for aa in aa_list:
- aa.author = user
- aa.save()
- #maybe add pending posts message?
- else: #just publish the questions
- for aq in aq_list:
- aq.publish(user)
- for aa in aa_list:
- aa.publish(user)
-
-user_logged_in.connect(post_stored_anonymous_content)
+#def post_stored_anonymous_content(user,old_session,**kwargs):
+# from forum.models import AnonymousQuestion, AnonymousAnswer
+# aq_list = AnonymousQuestion.objects.filter(session_key = old_session)
+# aa_list = AnonymousAnswer.objects.filter(session_key = old_session)
+# import settings
+# if settings.EMAIL_VALIDATION == 'on':#add user to the record
+# for aq in aq_list:
+# aq.author = user
+# aq.save()
+# for aa in aa_list:
+# aa.author = user
+# aa.save()
+# #maybe add pending posts message?
+# else: #just publish the questions
+# for aq in aq_list:
+# aq.publish(user)
+# for aa in aa_list:
+# aa.publish(user)
+#
+#user_logged_in.connect(post_stored_anonymous_content)
View
@@ -5,7 +5,7 @@
from django.db.models.signals import post_save
from forum.models.user import activity_record
-from forum.models import Badge, Award, Activity
+from forum.models import Badge, Award, Activity, Node
import logging
@@ -74,6 +74,14 @@ def handler(instance):
super(PostCountableAbstractBadge, self).__init__(model, field, expected_value, handler)
+class NodeCountableAbstractBadge(CountableAbstractBadge):
+ def __init__(self, node_type, field, expected_value):
+
+ def handler(instance):
+ if instance.node_type == node_type:
+ self.award_badge(instance.author, instance)
+
+ super(NodeCountableAbstractBadge, self).__init__(Node, field, expected_value, handler)
class ActivityAbstractBadge(AbstractBadge):
View
@@ -126,27 +126,16 @@ class AskForm(forms.Form):
tags = TagNamesField()
wiki = WikiField()
- openid = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 40, 'class':'openid-input'}))
- user = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
- email = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
class AnswerForm(forms.Form):
text = EditorField()
wiki = WikiField()
- openid = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 40, 'class':'openid-input'}))
- user = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
- email = forms.CharField(required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
- email_notify = EmailNotifyField()
- def __init__(self, question, user, *args, **kwargs):
+
+ def __init__(self, question, *args, **kwargs):
super(AnswerForm, self).__init__(*args, **kwargs)
- self.fields['email_notify'].widget.attrs['id'] = 'question-subscribe-updates';
+
if question.wiki and settings.WIKI_ON:
self.fields['wiki'].initial = True
- if user.is_authenticated():
- if user in question.followed_by.all():
- self.fields['email_notify'].initial = True
- return
- self.fields['email_notify'].initial = False
class CloseForm(forms.Form):
@@ -165,27 +154,34 @@ class RevisionForm(forms.Form):
"""
revision = forms.ChoiceField(widget=forms.Select(attrs={'style' : 'width:520px'}))
- def __init__(self, post, latest_revision, *args, **kwargs):
+ def __init__(self, post, *args, **kwargs):
super(RevisionForm, self).__init__(*args, **kwargs)
+
revisions = post.revisions.all().values_list(
'revision', 'author__username', 'revised_at', 'summary')
date_format = '%c'
self.fields['revision'].choices = [
(r[0], u'%s - %s (%s) %s' % (r[0], r[1], r[2].strftime(date_format), r[3]))
for r in revisions]
- self.fields['revision'].initial = latest_revision.revision
+
+ self.fields['revision'].initial = post.active_revision.revision
class EditQuestionForm(forms.Form):
title = TitleField()
text = EditorField()
tags = TagNamesField()
summary = SummaryField()
- def __init__(self, question, revision, *args, **kwargs):
+ def __init__(self, question, revision=None, *args, **kwargs):
super(EditQuestionForm, self).__init__(*args, **kwargs)
+
+ if revision is None:
+ revision = question.active_revision
+
self.fields['title'].initial = revision.title
- self.fields['text'].initial = revision.text
+ self.fields['text'].initial = revision.body
self.fields['tags'].initial = revision.tagnames
+
# Once wiki mode is enabled, it can't be disabled
if not question.wiki:
self.fields['wiki'] = WikiField()
@@ -194,9 +190,13 @@ class EditAnswerForm(forms.Form):
text = EditorField()
summary = SummaryField()
- def __init__(self, answer, revision, *args, **kwargs):
+ def __init__(self, answer, revision=None, *args, **kwargs):
super(EditAnswerForm, self).__init__(*args, **kwargs)
- self.fields['text'].initial = revision.text
+
+ if revision is None:
+ revision = answer.active_revision
+
+ self.fields['text'].initial = revision.body
class EditUserForm(forms.Form):
email = forms.EmailField(label=u'Email', help_text=_('this email does not have to be linked to gravatar'), required=True, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
Oops, something went wrong.

0 comments on commit 1b3e97f

Please sign in to comment.