Merge lp:~dholbach/harvest/schema-changes into lp:harvest

Proposed by Daniel Holbach
Status: Merged
Approved by: James Westby
Approved revision: 190
Merged at revision: 186
Proposed branch: lp:~dholbach/harvest/schema-changes
Merge into: lp:harvest
Diff against target: 82 lines (+35/-1)
3 files modified
harvest/common/launchpad.py (+0/-1)
harvest/opportunities/models.py (+17/-0)
harvest/opportunities/views.py (+18/-0)
To merge this branch: bzr merge lp:~dholbach/harvest/schema-changes
Reviewer Review Type Date Requested Status
James Westby Approve
Review via email: mp+26687@code.launchpad.net

This proposal supersedes a proposal from 2010-06-02.

To post a comment you must log in.
Revision history for this message
James Westby (james-w) wrote : Posted in a previous version of this proposal

Hi,

Looks ok to me.

Two comments though:

38 +class Person(models.Model):
39 + lpid = models.TextField(_("Who"), max_length=80)

is that long enough?

70 + if form.cleaned_data["comment"] != opportunity.comment:
71 + models.log_action(request.user.username,
72 + action="changed comment to: '%s'" % \
73 + form.cleaned_data["comment"],
74 + opportunity=opportunity)

that will overflow

    action = models.TextField(_("Action"), max_length=120)

if the comment is long won't it?

You probably want to ellipsise the comment in the action if it is
long.

Thanks,

James

review: Needs Fixing
Revision history for this message
Daniel Holbach (dholbach) wrote : Posted in a previous version of this proposal

You're right. Dylan also suggested to drop "Person" and just use the regular User or whatever it's called in core-Django.

Thanks for the review and the note about the too long comments.

Revision history for this message
Dylan McCall (dylanmccall) wrote : Posted in a previous version of this proposal

Adding a separate Person class seems a bit funny to me, since the built in User class (in django.contrib.auth) handles a lot of this for us. Granted, the built in class has that ugly distinction between first and last name, but adding an additional, separate class feels wrong to me. I'm concerned it could corrupt some of the beautiful magic being performed for us behind the scenes.

Besides, we will be working with User already :)

There is a way to store arbitrary extra information on auth's User object as well:
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

Here's a chunk of code which uses that:
http://www.arnebrodowski.de/blog/482-Tracking-user-activity-with-Django.html

Revision history for this message
Daniel Holbach (dholbach) wrote : Posted in a previous version of this proposal

I'm happy to have a UserProfile model related to User once we think it's necessary (connected upload rights, settings(?), …)

Revision history for this message
James Westby (james-w) wrote :

Looks good.

Thanks,

James

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'harvest/common/launchpad.py'
2--- harvest/common/launchpad.py 2010-01-27 12:34:37 +0000
3+++ harvest/common/launchpad.py 2010-06-03 11:20:38 +0000
4@@ -4,7 +4,6 @@
5
6 from django.conf import settings
7
8-import sys
9 import os
10
11 def lp_login(lp_instance=EDGE_SERVICE_ROOT):
12
13=== modified file 'harvest/opportunities/models.py'
14--- harvest/opportunities/models.py 2010-03-08 16:32:02 +0000
15+++ harvest/opportunities/models.py 2010-06-03 11:20:38 +0000
16@@ -1,5 +1,8 @@
17 from django.db import models
18 from django.utils.translation import ugettext as _
19+from django.contrib.auth.models import User
20+
21+import datetime
22
23 PACKAGE_GREEN_THRESHOLD = 5
24 PACKAGE_RED_THRESHOLD = 20
25@@ -84,6 +87,7 @@
26 last_updated = models.DateTimeField(_("Last Updated"), null=True)
27 since = models.DateTimeField(_("Since"), help_text=_("On the list since"), null=True)
28 reviewed = models.BooleanField(_("Irrelevant"), default=False, blank=True)
29+ applied = models.BooleanField(_("Applied"), default=False, blank=True)
30 sourcepackage = models.ForeignKey(SourcePackage)
31 opportunitylist = models.ForeignKey(OpportunityList)
32 comment = models.TextField(_("Comment"), blank=True)
33@@ -101,3 +105,16 @@
34 @models.permalink
35 def get_absolute_url(self):
36 return ('opportunity_detail', [self.id])
37+
38+class ActionLogEntry(models.Model):
39+ timestamp = models.DateTimeField(_("Timestamp"))
40+ who = models.ForeignKey(User)
41+ action = models.TextField(_("Action"), max_length=200)
42+ opportunity = models.ForeignKey(Opportunity, blank=True)
43+
44+def log_action(who, action=None, opportunity=None):
45+ log_entry = ActionLogEntry(timestamp=datetime.datetime.now(),
46+ who=who, action=action,
47+ opportunity=opportunity)
48+ log_entry.save()
49+
50
51=== modified file 'harvest/opportunities/views.py'
52--- harvest/opportunities/views.py 2010-03-08 16:33:21 +0000
53+++ harvest/opportunities/views.py 2010-06-03 11:20:38 +0000
54@@ -1,3 +1,4 @@
55+# -*- coding: utf-8 -*-
56 from django.contrib.auth.decorators import login_required
57 from django.core.paginator import Paginator, InvalidPage, EmptyPage
58 from django.utils.translation import ugettext as _
59@@ -54,6 +55,23 @@
60 if request.method == "POST":
61 form = forms.OpportunityForm(data=request.POST, instance=opportunity)
62 if form.is_valid():
63+ if form.cleaned_data["reviewed"] != opportunity.reviewed:
64+ models.log_action(request.user, action="marked as reviewed",
65+ opportunity=opportunity)
66+ if form.cleaned_data["applied"] != opportunity.applied:
67+ models.log_action(request.user, action="marked as applied",
68+ opportunity=opportunity)
69+ if form.cleaned_data["experience"] != opportunity.experience:
70+ models.log_action(request.user,
71+ action="changed experience to: %s" % form.cleaned_data["experience"],
72+ opportunity=opportunity)
73+ if form.cleaned_data["comment"] != opportunity.comment:
74+ if len(form.cleaned_data["comment"]) > 178:
75+ action = "changed comment to: '%s'" % (form.cleaned_data["comment"][:177]+u"…")
76+ else:
77+ action = "changed comment to: '%s'" % form.cleaned_data["comment"]
78+ models.log_action(request.user, action=action,
79+ opportunity=opportunity)
80 form.save()
81 return HttpResponseRedirect(request.POST["next"])
82 else:

Subscribers

People subscribed via source and target branches

to all changes: