forked from evgenyfadeev/askbot-devel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Lots of changes, here's a randomly ordered list on the top of my head:
-several optimizations in the code and database schema -lots of rewritten views, specially regarding ajax commands -completely refactored javascript, and upgrade to jquery 1.4.2 -all stuff that was only possible via ajax, like voting or commenting, etc, is now possible to do with javascript disabled -completely renewed comment system, which adds some new features like "liking" comments and editing comments -rewritten activity records and reputation handlers -denormalized data is now handled at "saves" and not in views... -instance level caching for some models -last remainings of sql in models are gone -rewritten permission system, and prepared to receive more granular permissions in the future -most model managers were rewritten or optimized -TONS of bugs were erradicated and I'm probably forgetting something :-)
- Loading branch information
hrc
authored and
hrc
committed
Apr 6, 2010
1 parent
5b60c2c
commit b515d68
Showing
125 changed files
with
7,142 additions
and
10,167 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
If you're upgrading your code, please take the following steps in consideration: | ||
|
||
If your current code is older than March 27 2010, you'll have to run the syncdb management command again | ||
and the create_subscriptions command. | ||
|
||
If your code is older than March 29 2010, you'll have to run the create_extended_user management command. | ||
If you're upgrading your code, please take the following steps in consideration: | ||
|
||
If your current code is older than March 27 2010, you'll have to run the syncdb management command again | ||
and the create_subscriptions command. | ||
|
||
If your code is older than March 29 2010, you'll have to run the create_extended_user management command. | ||
|
||
Starting at April 6 2010 we started bundling south migrations with OSQA. If your code is older than that, you'll need to run | ||
"python manage.py migrate forum 0001 --fake", after that, or if your code is newer than this date just run "python manage.py migrate forum" | ||
each time you upgrade your code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
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.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() | ||
|
||
post_save.connect(record_answer_event, sender=Answer) | ||
|
||
|
||
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() | ||
|
||
post_save.connect(record_comment_event, sender=Comment) | ||
|
||
|
||
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() | ||
|
||
post_save.connect(record_question_revision_event, sender=QuestionRevision) | ||
|
||
|
||
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) | ||
activity.save() | ||
|
||
post_save.connect(record_answer_revision_event, sender=AnswerRevision) | ||
|
||
|
||
def record_award_event(instance, created, **kwargs): | ||
if created: | ||
activity = Activity(user=instance.user, active_at=instance.awarded_at, content_object=instance, | ||
activity_type=TYPE_ACTIVITY_PRIZE) | ||
activity.save() | ||
|
||
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() | ||
|
||
post_save.connect(record_answer_accepted, sender=Answer) | ||
|
||
|
||
def update_last_seen(instance, **kwargs): | ||
user = instance.user | ||
user.last_seen = datetime.datetime.now() | ||
user.save() | ||
|
||
post_save.connect(update_last_seen, sender=Activity) | ||
|
||
|
||
def record_vote(instance, created, **kwargs): | ||
if created: | ||
act_type = (instance.vote == 1) and TYPE_ACTIVITY_VOTE_UP or TYPE_ACTIVITY_VOTE_DOWN | ||
|
||
activity = Activity(user=instance.user, active_at=instance.voted_at, content_object=instance, activity_type=act_type) | ||
activity.save() | ||
|
||
post_save.connect(record_vote, sender=Vote) | ||
|
||
|
||
def record_cancel_vote(instance, **kwargs): | ||
act_type = (instance.vote == 1) and TYPE_ACTIVITY_CANCEL_VOTE_UP or TYPE_ACTIVITY_CANCEL_VOTE_DOWN | ||
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) | ||
|
||
|
||
def record_delete_post(instance, delete_by, **kwargs): | ||
act_type = (instance.__class__ is Question) and TYPE_ACTIVITY_DELETE_QUESTION or TYPE_ACTIVITY_DELETE_ANSWER | ||
activity = Activity(user=delete_by, active_at=datetime.datetime.now(), content_object=instance, activity_type=act_type) | ||
activity.save() | ||
|
||
marked_deleted.connect(record_delete_post, sender=Question) | ||
marked_deleted.connect(record_delete_post, sender=Answer) | ||
|
||
|
||
def record_update_tags(instance, created, **kwargs): | ||
if not created and 'tagnames' in instance.get_dirty_fields(): | ||
activity = Activity(user=question.author, active_at=datetime.datetime.now(), content_object=instance, activity_type=TYPE_ACTIVITY_UPDATE_TAGS) | ||
activity.save() | ||
|
||
post_save.connect(record_update_tags, sender=Question) | ||
|
||
|
||
def record_mark_offensive(instance, created, **kwargs): | ||
if created: | ||
activity = Activity(user=instance.user, active_at=datetime.datetime.now(), content_object=instance.content_object, activity_type=TYPE_ACTIVITY_MARK_OFFENSIVE) | ||
activity.save() | ||
|
||
post_save.connect(record_mark_offensive, sender=FlaggedItem) | ||
|
||
|
||
def record_favorite_question(instance, created, **kwargs): | ||
if created: | ||
activity = Activity(user=instance.user, active_at=datetime.datetime.now(), content_object=instance, activity_type=TYPE_ACTIVITY_FAVORITE) | ||
activity.save() | ||
|
||
post_save.connect(record_favorite_question, sender=FavoriteQuestion) | ||
|
||
|
||
def record_user_full_updated(instance, **kwargs): | ||
activity = Activity(user=instance, active_at=datetime.datetime.now(), content_object=instance, activity_type=TYPE_ACTIVITY_USER_FULL_UPDATED) | ||
activity.save() | ||
|
||
user_updated.connect(record_user_full_updated, sender=User) | ||
|
Oops, something went wrong.