Skip to content

Commit

Permalink
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
Show file tree
Hide file tree
Showing 125 changed files with 7,142 additions and 10,167 deletions.
1,914 changes: 1,130 additions & 784 deletions .idea/workspace.xml

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions INSTALL
Expand Up @@ -32,11 +32,14 @@ sudo easy_install html5lib
http://code.google.com/p/python-markdown2/
sudo easy_install markdown2

4. Optionally you may want to install Django Debug Toolbar for debugging.
4. Optional, but highly recommended, you may want to install south from http://south.aeracode.org/ , it will make upgrades a lot easier.


5. Also optionally you may want to install Django Debug Toolbar for debugging.
This is not required and OSQA will just ignore it if you don't have it.
http://github.com/robhudson/django-debug-toolbar/tree/master

5. Depending on which modules you decide to enable (see bellow for more info on modules),
6. Depending on which modules you decide to enable (see bellow for more info on modules),
you may need to install some aditional dependencies. Here's a list of the dependencies of each bundled module if any:

a) openidauth, depends on Python-openid
Expand Down Expand Up @@ -109,6 +112,8 @@ create database osqa DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;
grant all on osqa.* to 'osqa'@'localhost';
And then run "python manage.py syncdb" to synchronize your database.

If you're using south, then run "python manage.py migrate forum 0001 --fake".

When you're prompted to create a new superuser, answer "no". Once you get your site running, create a new user through the normal
OSQA account creation process and that will be your super user.

Expand Down
16 changes: 10 additions & 6 deletions UPGRADE
@@ -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.
132 changes: 132 additions & 0 deletions forum/activity.py
@@ -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)

0 comments on commit b515d68

Please sign in to comment.