Permalink
Browse files

A few small changes.

* If the author of a question related to a badge is not an admin, then the badge is not ussed when its answers reach the required number of votes.
* Making sure no repeated prefixes are added to the vote comments.
* Fixing bug in down vote reputation looses.
* If there is no user in the database the first that logs in with username+password becomes admin (not really necessary for the pilot but usefull for development).
  • Loading branch information...
1 parent b7504f7 commit 1d93ba8fd7bfe773da472e71bb7773c35a8e1478 @zuzelvp committed Feb 22, 2011
Showing with 12 additions and 5 deletions.
  1. +3 −0 forum/authentication/drupal_auth_backend.py
  2. +1 −1 forum/models/action.py
  3. +6 −4 forum/models/comment.py
  4. +2 −0 forum/models/meta.py
View
3 forum/authentication/drupal_auth_backend.py
@@ -36,6 +36,9 @@ def authenticate(self, username=None, password=None):
pwd_valid = self.check_password(drupal_user, user, password)
if pwd_valid:
DrupalAuthBackend.get_user_data(drupal_user, user)
+ if User.objects.all().count() == 0:
+ user.is_superuser = True
+ user.is_staff = True
user.save()
return user
else:
View
2 forum/models/action.py
@@ -304,7 +304,7 @@ def _add_to_rep(self, value):
if self.user.reputation + value < 0:
return 0
else:
- return models.F('reputation') + value
+ return self.user.reputation + value
def save(self, *args, **kwargs):
super(ActionRepute, self).save(*args, **kwargs)
View
10 forum/models/comment.py
@@ -17,12 +17,14 @@ def _update_parent_comment_count(self, diff):
@property
def comment(self):
- if not self.body[3:].startswith(self.prefix()):
- self.body = self.body[:3] + self.prefix() + self.body[3:]
+ prev_body = self.body
+ self.body = prev_body[:3] + self.prefix() + prev_body[3:]
if settings.FORM_ALLOW_MARKDOWN_IN_COMMENTS:
- return self.as_markdown('limitedsyntax')
+ result = self.as_markdown('limitedsyntax')
else:
- return self.body
+ result = self.body
+ self.body = prev_body
+ return result
@property
def headline(self):
View
2 forum/models/meta.py
@@ -227,6 +227,8 @@ def procces_voting_action(cls, action, new):
if action.node.node_type == 'answer':
answer = action.node
question = answer.parent
+ if not question.author.is_superuser:
+ return
user = action.node.author
for name in question.tagname_list():
try:

0 comments on commit 1d93ba8

Please sign in to comment.