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
=== modified file 'harvest/common/launchpad.py'
--- harvest/common/launchpad.py 2010-01-27 12:34:37 +0000
+++ harvest/common/launchpad.py 2010-06-03 11:20:38 +0000
@@ -4,7 +4,6 @@
44
5from django.conf import settings5from django.conf import settings
66
7import sys
8import os7import os
98
10def lp_login(lp_instance=EDGE_SERVICE_ROOT):9def lp_login(lp_instance=EDGE_SERVICE_ROOT):
1110
=== modified file 'harvest/opportunities/models.py'
--- harvest/opportunities/models.py 2010-03-08 16:32:02 +0000
+++ harvest/opportunities/models.py 2010-06-03 11:20:38 +0000
@@ -1,5 +1,8 @@
1from django.db import models1from django.db import models
2from django.utils.translation import ugettext as _2from django.utils.translation import ugettext as _
3from django.contrib.auth.models import User
4
5import datetime
36
4PACKAGE_GREEN_THRESHOLD = 57PACKAGE_GREEN_THRESHOLD = 5
5PACKAGE_RED_THRESHOLD = 208PACKAGE_RED_THRESHOLD = 20
@@ -84,6 +87,7 @@
84 last_updated = models.DateTimeField(_("Last Updated"), null=True)87 last_updated = models.DateTimeField(_("Last Updated"), null=True)
85 since = models.DateTimeField(_("Since"), help_text=_("On the list since"), null=True)88 since = models.DateTimeField(_("Since"), help_text=_("On the list since"), null=True)
86 reviewed = models.BooleanField(_("Irrelevant"), default=False, blank=True)89 reviewed = models.BooleanField(_("Irrelevant"), default=False, blank=True)
90 applied = models.BooleanField(_("Applied"), default=False, blank=True)
87 sourcepackage = models.ForeignKey(SourcePackage)91 sourcepackage = models.ForeignKey(SourcePackage)
88 opportunitylist = models.ForeignKey(OpportunityList)92 opportunitylist = models.ForeignKey(OpportunityList)
89 comment = models.TextField(_("Comment"), blank=True)93 comment = models.TextField(_("Comment"), blank=True)
@@ -101,3 +105,16 @@
101 @models.permalink105 @models.permalink
102 def get_absolute_url(self):106 def get_absolute_url(self):
103 return ('opportunity_detail', [self.id])107 return ('opportunity_detail', [self.id])
108
109class ActionLogEntry(models.Model):
110 timestamp = models.DateTimeField(_("Timestamp"))
111 who = models.ForeignKey(User)
112 action = models.TextField(_("Action"), max_length=200)
113 opportunity = models.ForeignKey(Opportunity, blank=True)
114
115def log_action(who, action=None, opportunity=None):
116 log_entry = ActionLogEntry(timestamp=datetime.datetime.now(),
117 who=who, action=action,
118 opportunity=opportunity)
119 log_entry.save()
120
104121
=== modified file 'harvest/opportunities/views.py'
--- harvest/opportunities/views.py 2010-03-08 16:33:21 +0000
+++ harvest/opportunities/views.py 2010-06-03 11:20:38 +0000
@@ -1,3 +1,4 @@
1# -*- coding: utf-8 -*-
1from django.contrib.auth.decorators import login_required2from django.contrib.auth.decorators import login_required
2from django.core.paginator import Paginator, InvalidPage, EmptyPage3from django.core.paginator import Paginator, InvalidPage, EmptyPage
3from django.utils.translation import ugettext as _4from django.utils.translation import ugettext as _
@@ -54,6 +55,23 @@
54 if request.method == "POST":55 if request.method == "POST":
55 form = forms.OpportunityForm(data=request.POST, instance=opportunity)56 form = forms.OpportunityForm(data=request.POST, instance=opportunity)
56 if form.is_valid():57 if form.is_valid():
58 if form.cleaned_data["reviewed"] != opportunity.reviewed:
59 models.log_action(request.user, action="marked as reviewed",
60 opportunity=opportunity)
61 if form.cleaned_data["applied"] != opportunity.applied:
62 models.log_action(request.user, action="marked as applied",
63 opportunity=opportunity)
64 if form.cleaned_data["experience"] != opportunity.experience:
65 models.log_action(request.user,
66 action="changed experience to: %s" % form.cleaned_data["experience"],
67 opportunity=opportunity)
68 if form.cleaned_data["comment"] != opportunity.comment:
69 if len(form.cleaned_data["comment"]) > 178:
70 action = "changed comment to: '%s'" % (form.cleaned_data["comment"][:177]+u"…")
71 else:
72 action = "changed comment to: '%s'" % form.cleaned_data["comment"]
73 models.log_action(request.user, action=action,
74 opportunity=opportunity)
57 form.save()75 form.save()
58 return HttpResponseRedirect(request.POST["next"])76 return HttpResponseRedirect(request.POST["next"])
59 else:77 else:

Subscribers

People subscribed via source and target branches

to all changes: