Skip to content

Instantly share code, notes, and snippets.

@andymckay
Created April 12, 2011 23:53
Show Gist options
  • Save andymckay/916698 to your computer and use it in GitHub Desktop.
Save andymckay/916698 to your computer and use it in GitHub Desktop.
diff --git a/apps/editors/models.py b/apps/editors/models.py
index 58eb5d7..d2b2fe7 100644
--- a/apps/editors/models.py
+++ b/apps/editors/models.py
@@ -15,7 +15,7 @@ from editors.sql_model import RawSQLModel
from translations.fields import TranslatedField
from tower import ugettext as _
from users.models import UserProfile
-from versions.models import Version
+from versions.models import Version, version_uploaded
import commonware.log
@@ -228,5 +228,5 @@ def send_notifications(sender, instance, **kw):
subscriber.delete()
-models.signals.post_save.connect(send_notifications, sender=Version,
- dispatch_uid='version_send_notifications')
+version_uploaded.connect(send_notifications, sender=Version,
+ dispatch_uid='version_send_notifications')
diff --git a/apps/versions/models.py b/apps/versions/models.py
index 581d2d2..2a1c4f1 100644
--- a/apps/versions/models.py
+++ b/apps/versions/models.py
@@ -3,6 +3,7 @@ import os
from django.conf import settings
from django.db import models
+import django.dispatch
import jinja2
import commonware.log
@@ -100,6 +101,7 @@ class Version(amo.models.ModelBase):
# After the upload has been copied to all
# platforms, remove the upload.
upload.path.unlink()
+ version_uploaded.send(sender=v)
return v
@property
@@ -241,7 +243,7 @@ def update_status(sender, instance, **kw):
except models.ObjectDoesNotExist:
pass
-
+version_uploaded = django.dispatch.Signal()
models.signals.post_save.connect(update_status, sender=Version,
dispatch_uid='version_update_status')
models.signals.post_delete.connect(update_status, sender=Version,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment