зеркало из https://github.com/mozilla/kitsune.git
Remove EventWatch model and table. [bug 632184]
This commit is contained in:
Родитель
3c3c1a37bc
Коммит
804c7993ec
|
@ -1,10 +1,6 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from notifications.models import EventWatch, Watch, WatchFilter
|
||||
|
||||
|
||||
class EventWatchAdmin(admin.ModelAdmin):
|
||||
list_filter = ['content_type', 'event_type', 'locale']
|
||||
from notifications.models import Watch, WatchFilter
|
||||
|
||||
|
||||
class FilterInline(admin.TabularInline):
|
||||
|
@ -22,6 +18,5 @@ class WatchFilterAdmin(admin.ModelAdmin):
|
|||
raw_id_fields = ['watch']
|
||||
|
||||
|
||||
admin.site.register(EventWatch, EventWatchAdmin)
|
||||
admin.site.register(Watch, WatchAdmin)
|
||||
admin.site.register(WatchFilter, WatchFilterAdmin)
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
[
|
||||
{
|
||||
"pk": 1,
|
||||
"model": "notifications.eventwatch",
|
||||
"fields": {
|
||||
"watch_id": 1,
|
||||
"email": "user118533@nowhere",
|
||||
"content_type": ["forums", "thread"],
|
||||
"event_type": "reply"
|
||||
}
|
||||
},
|
||||
{
|
||||
"pk": 2,
|
||||
"model": "notifications.eventwatch",
|
||||
"fields": {
|
||||
"watch_id": 1,
|
||||
"email": "noone2@example.com",
|
||||
"content_type": ["forums", "thread"],
|
||||
"event_type": "reply"
|
||||
}
|
||||
}
|
||||
]
|
|
@ -31,49 +31,6 @@ def multi_raw(query, params, models):
|
|||
for model_class in models]
|
||||
|
||||
|
||||
class EventWatch(ModelBase):
|
||||
"""
|
||||
Allows anyone to watch a specific item for changes. Uses email instead of
|
||||
user ID so anonymous visitors can also watch things eventually.
|
||||
"""
|
||||
|
||||
content_type = models.ForeignKey(ContentType)
|
||||
# If watch_id is set to null, then the watch is for the model and not
|
||||
# an instance.
|
||||
watch_id = models.IntegerField(db_index=True, null=True)
|
||||
event_type = models.CharField(max_length=20, db_index=True)
|
||||
locale = LocaleField(default='', db_index=True)
|
||||
email = models.EmailField(db_index=True)
|
||||
hash = models.CharField(max_length=40, null=True, db_index=True)
|
||||
|
||||
class Meta:
|
||||
unique_together = (('content_type', 'watch_id', 'email',
|
||||
'event_type', 'locale'),)
|
||||
|
||||
@property
|
||||
def key(self):
|
||||
if self.hash:
|
||||
return self.hash
|
||||
|
||||
key_ = '%s-%s-%s-%s' % (self.content_type.id, self.watch_id,
|
||||
self.email, self.event_type)
|
||||
sha = hashlib.sha1()
|
||||
sha.update(key_)
|
||||
return sha.hexdigest()
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
"""Overriding save to set the hash."""
|
||||
self.hash = self.key
|
||||
|
||||
super(EventWatch, self).save(*args, **kwargs)
|
||||
|
||||
def get_remove_url(self):
|
||||
"""Get the URL to remove an EventWatch."""
|
||||
from sumo.helpers import urlparams
|
||||
url_ = reverse('notifications.remove', args=[self.key])
|
||||
return urlparams(url_, email=self.email)
|
||||
|
||||
|
||||
class Watch(ModelBase):
|
||||
"""Watch events."""
|
||||
# Key used by an Event to find watches it manages:
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
-- Remove the old notifications_eventwatch table.
|
||||
DROP TABLE notifications_eventwatch;
|
Загрузка…
Ссылка в новой задаче