diff --git a/djangoproject/core/models.py b/djangoproject/core/models.py index 37b9792f..65d19bf1 100644 --- a/djangoproject/core/models.py +++ b/djangoproject/core/models.py @@ -298,15 +298,18 @@ def get_image3x1(self): def get_tags(self): return Tag.objects.filter(objtype="Project", objid=self.id) - def to_json(self): - return json.dumps({ + def to_dict_json(self): + return { 'id': self.id, 'name': self.name, 'description': self.description, 'homeURL': self.homeURL, 'trackerURL': self.trackerURL, 'image3x1': self.image3x1.url if self.image3x1 else None, - }) + } + + def to_json(self): + return json.dumps(self.to_dict_json()) def __unicode__(self): return self.name @@ -385,12 +388,16 @@ def changeIssue(self, issuedict): self.title = issuedict.get('title') self.touch() - def to_json(self): - return json.dumps({ + def to_dict_json(self): + return { 'id': self.id, 'title': self.title, - 'description': self.description - }) + 'description': self.description, + 'link': self.get_view_link(), + } + + def to_json(self): + return json.dumps(self.to_dict_json()) def getTotalOffersPriceUSD(self): return self.getTotalOffersPrice_by_currency('USD') @@ -567,8 +574,8 @@ class Offer(models.Model): REVOKED = "REVOKED" PAID = "PAID" - def to_json(self): - return json.dumps({ + def to_dict_json(self): + return { 'id': self.id, 'price': float(str(self.price)), 'currency': self.currency, @@ -576,7 +583,10 @@ def to_json(self): 'no_forking': self.no_forking, 'require_release': self.require_release, 'status': self.status, - }) + } + + def to_json(self): + return json.dumps(self.to_dict_json()) @classmethod def newOffer(cls, issue, sponsor, price, currency, acceptanceCriteria, no_forking, require_release, expiration_days): @@ -915,11 +925,13 @@ class PaymentPart(models.Model): solution = models.ForeignKey(Solution) paypalEmail = models.EmailField(max_length=256, null=True) price = models.DecimalField(max_digits=16, decimal_places=8) - money_sent = models.ForeignKey(MoneySent, null = True) + money_sent = models.ForeignKey(MoneySent, null=True) def to_dict_json(self): return { 'programmer_id': self.programmer.id, + 'programmer_image': self.programmer.gravatar_url_small(), + 'programmer_screenname': self.programmer.getUserInfo().screenname, 'solution_id': self.solution.id, 'price': float(str(self.price)) if self.price else None, } @@ -970,10 +982,15 @@ def to_dict_json(self): 'action': self.action, 'entity': self.entity, # 'creationDate': self.id, + 'user_image': self.user.gravatar_url_medium(), + 'user_screenname': self.user.getUserInfo().screenName, 'user_id': self.user.id, 'project_id': self.project.id if self.project else None, + 'project': self.project.to_dict_json() if self.project else None, 'issue_id': self.issue.id if self.issue else None, + 'issue': self.issue.to_dict_json() if self.issue else None, 'offer_id': self.offer.id if self.offer else None, + 'offer': self.offer.to_dict_json() if self.offer else None, 'solution_id': self.solution.id if self.solution else None, 'issue_comment_id': self.issue_comment.id if self.issue_comment else None, 'old_json': self.old_json, diff --git a/djangoproject/core/services/activity_services.py b/djangoproject/core/services/activity_services.py index 24515ce8..a5c37108 100644 --- a/djangoproject/core/services/activity_services.py +++ b/djangoproject/core/services/activity_services.py @@ -1,4 +1,5 @@ from core.models import ActionLog +from django.db.models import Q __author__ = 'tony' @@ -6,6 +7,6 @@ def get_latest_activity(project_id): query = ActionLog.objects.all() if project_id: - query = query.filter(project__id=project_id) + query = query.filter(Q(project__id=project_id) & (~Q(action__in=['ADD_ISSUE_COMMENT', 'EDIT_ISSUE_COMMENT']))) query = query.order_by('-creationDate') return query[0:10] diff --git a/djangoproject/statfiles/static/js/activitylist/activitylist.html b/djangoproject/statfiles/static/js/activitylist/activitylist.html index 93b865eb..8e5ceaa8 100644 --- a/djangoproject/statfiles/static/js/activitylist/activitylist.html +++ b/djangoproject/statfiles/static/js/activitylist/activitylist.html @@ -1,5 +1,76 @@
-
- {[{describe(activity)}]} +
+
+
+ {[{ activity.when }]}
+ {[{ activity.user_screenname }]} + has edited project details. More... +
+
+ {[{ activity.when }]}
+ {[{ activity.user_screenname }]} + added tag {[{ activity.new_json }]} to project. +
+
+ {[{ activity.when }]}
+ {[{ activity.user_screenname }]} + removed tag {[{ activity.new_json }]} from project. +
+
+ {[{ activity.when }]}
+ {[{ activity.user_screenname }]} + sponsored issue {[{ activity.issue.title }]}, + with a {[{ activity.new_dic.currency }]} {[{ activity.new_dic.price }]} offer. +
+
+ {[{ activity.when }]}
+ has changed his offer on issue {[{ activity.issue.title }]} + More... +
+
+ {[{ activity.when }]}
+ {[{ activity.user_screenname }]} + revoked his {[{ activity.new_dic.currency }]} {[{ activity.new_dic.price }]} offer + on issue {[{ activity.issue.title }]} + More... +
+
+ {[{ activity.when }]}
+ {[{ activity.user_screenname }]} + proposed issue {[{ activity.issue.title }]} +
+
+ {[{ activity.when }]}
+ {[{ activity.user_screenname }]} + started working on issue {[{ activity.issue.title }]} + More... +
+
+ {[{ activity.when }]}
+ {[{ activity.user_screenname }]} + stopped working on issue {[{ activity.issue.title }]} + More... +
+
+ {[{ activity.when }]}
+ {[{ activity.user_screenname }]} + resolved issue {[{ activity.issue.title }]} +
+
+ {[{ activity.when }]}
+ {[{ activity.user_screenname }]} + made a {[{ activity.new_dic.currency }]} {[{ activity.new_dic.total }]} payment + for issue {[{ activity.issue.title }]}
+ Receivers:
+
    +
  • + {[{ part.programmer_screenname }]}: {[{ activity.new_dic.currency }]} {[{ part.price }]} +
  • +
+
+
+ Unknown activity: {[{activity.action }]} +
+
\ No newline at end of file diff --git a/djangoproject/statfiles/static/js/activitylist/activitylist.js b/djangoproject/statfiles/static/js/activitylist/activitylist.js index b7c45abd..14d78d2e 100644 --- a/djangoproject/statfiles/static/js/activitylist/activitylist.js +++ b/djangoproject/statfiles/static/js/activitylist/activitylist.js @@ -30,8 +30,21 @@ mod.directive('activitylist', function() { }, templateUrl: '/static/js/activitylist/activitylist.html', controller: function ($scope, FSApi) { + + var instrument = function(activity){ + try{ + activity.new_dic = JSON.parse(activity.new_json); + activity.old_dic = JSON.parse(activity.old_json); + } catch(err){ + //that's ok + } + }; + FSApi.get_latest_activity($scope.projectId).onResult(function(result){ $scope.activities=result; + for(var i=0; i < $scope.activities.length; i++){ + instrument($scope.activities[i]) + } $scope.$digest(); });