• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

Revision62b22a6cb94bbf8bac34dff2a627f64542a3dac5 (tree)
Time2012-07-18 04:25:22
AuthorYuriy <yuriyarhipovua@yand...>
CommiterCory Johns

Log Message

[#4481] ticket:103 Add votes

Change Summary

Incremental Difference

--- a/Allura/allura/model/artifact.py
+++ b/Allura/allura/model/artifact.py
@@ -668,7 +668,7 @@ class VotableArtifact(MappedClass):
668668 class __mongometa__:
669669 session = main_orm_session
670670 name = 'vote'
671-
671+ votes = FieldProperty(int, if_missing=0)
672672 votes_up = FieldProperty(int, if_missing=0)
673673 votes_down = FieldProperty(int, if_missing=0)
674674 votes_up_users = FieldProperty([str], if_missing=list())
@@ -683,6 +683,7 @@ class VotableArtifact(MappedClass):
683683 self.votes_down = self.votes_down - 1
684684 self.votes_up_users.append(user.username)
685685 self.votes_up += 1
686+ self.votes += 1
686687
687688 def vote_down(self, user):
688689 if user.username in self.votes_down_users:
@@ -693,6 +694,7 @@ class VotableArtifact(MappedClass):
693694 self.votes_up = self.votes_up - 1
694695 self.votes_down_users.append(user.username)
695696 self.votes_down += 1
697+ self.votes -= 1
696698
697699 def user_voted(self, user):
698700 """Check that user voted for this artifact.
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -276,6 +276,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
276276 milestone_s=self.milestone,
277277 status_s=self.status,
278278 text=self.description,
279+ votes_i=self.votes,
279280 snippet_s=self.summary)
280281 for k,v in self.custom_fields.iteritems():
281282 result[k + '_s'] = unicode(v)
@@ -575,6 +576,7 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
575576 assigned_to_id=self.assigned_to_id and str(self.assigned_to_id) or None,
576577 status=self.status,
577578 private=self.private,
579+ votes=self.votes,
578580 custom_fields=self.custom_fields)
579581
580582 @classmethod
@@ -604,6 +606,9 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
604606 tickets.append(t)
605607 else:
606608 count = count -1
609+ if c.app.config.options.get('EnableVoting'):
610+ columns.append(dict(name='votes', sort_name='votes', label='Votes', active=True))
611+
607612 return dict(
608613 tickets=tickets,
609614 count=count, q=json.dumps(query), limit=limit, page=page, sort=sort,
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -324,6 +324,8 @@ def mongo_columns():
324324 for field in c.app.globals.sortable_custom_fields_shown_in_search():
325325 columns.append(
326326 dict(name=field['name'], sort_name=field['name'], label=field['label'], active=True))
327+ if c.app.config.options.get('EnableVoting'):
328+ columns.append(dict(name='votes', sort_name='votes', label='Votes', active=True))
327329 return columns
328330
329331 def solr_columns():
@@ -334,6 +336,8 @@ def solr_columns():
334336 dict(name='assigned_to', sort_name='assigned_to_s', label='Owner', active=True)]
335337 for field in c.app.globals.sortable_custom_fields_shown_in_search():
336338 columns.append(dict(name=field['name'], sort_name=field['sortable_name'], label=field['label'], active=True))
339+ if c.app.config.options.get('EnableVoting'):
340+ columns.append(dict(name='votes', sort_name='votes_i', label='Votes', active=True))
337341 return columns
338342
339343 class RootController(BaseController):