FlagRequest model behavior tweaks
* Add a default field to be used for latest() calls. * Remove signal-based set of created date; instead, set it explicitly so all of our packages and flag request have the exact same date and time attached. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
f0a858aab6
commit
087aca5cce
@ -184,6 +184,9 @@ class FlagRequest(models.Model):
|
||||
is_legitimate = models.BooleanField(default=True,
|
||||
help_text="Is this actually an out-of-date flag request?")
|
||||
|
||||
class Meta:
|
||||
get_latest_by = 'created'
|
||||
|
||||
def who(self):
|
||||
if self.user:
|
||||
return self.user.get_full_name()
|
||||
@ -258,7 +261,7 @@ class Meta:
|
||||
|
||||
|
||||
# hook up some signals
|
||||
for sender in (PackageRelation, SignoffSpecification, Signoff, FlagRequest):
|
||||
for sender in (PackageRelation, SignoffSpecification, Signoff):
|
||||
pre_save.connect(set_created_field, sender=sender,
|
||||
dispatch_uid="packages.models")
|
||||
|
||||
|
@ -61,9 +61,11 @@ def flag(request, name, repo, arch):
|
||||
|
||||
@transaction.commit_on_success
|
||||
def perform_updates():
|
||||
pkgs.update(flag_date=datetime.utcnow())
|
||||
now = datetime.utcnow()
|
||||
pkgs.update(flag_date=now)
|
||||
# store our flag request
|
||||
flag_request = FlagRequest(user_email=email, message=message,
|
||||
flag_request = FlagRequest(created=now,
|
||||
user_email=email, message=message,
|
||||
ip_address=ip_addr, pkgbase=pkg.pkgbase,
|
||||
version=version, repo=pkg.repo,
|
||||
num_packages=len(flagged_pkgs))
|
||||
|
Loading…
Reference in New Issue
Block a user