add MiniAddon as lighter alternative (bug 624905)

This commit is contained in:
Andy McKay 2011-01-11 14:08:07 -08:00
Родитель 6113c2c3d9
Коммит 24bbaf4ea4
2 изменённых файлов: 15 добавлений и 4 удалений

Просмотреть файл

@ -12,7 +12,7 @@ import amo
import captcha.fields
from amo.utils import (ImageCheck, slug_validator, slugify, sorted_groupby,
remove_icons)
from addons.models import Addon, ReverseNameLookup, Category, AddonCategory
from addons.models import MiniAddon, Addon, ReverseNameLookup, Category, AddonCategory
from addons.widgets import IconWidgetRenderer, CategoriesSelectMultiple
from applications.models import Application
from devhub import tasks
@ -403,9 +403,9 @@ class UpdateForm(happyforms.Form):
def clean_id(self):
try:
addon = Addon.objects.get(guid=self.cleaned_data['id'])
except Addon.DoesNotExist:
raise forms.ValidationError(_('Id is required.'))
addon = MiniAddon.objects.get(guid=self.cleaned_data['id'])
except MiniAddon.DoesNotExist:
raise forms.ValidationError(_('ID is required.'))
return addon
def clean_appOS(self):

Просмотреть файл

@ -825,6 +825,17 @@ def watch_status(sender, instance, **kw):
dbsignals.pre_save.connect(watch_status, sender=Addon)
class MiniAddon(Addon):
"""A smaller lightweight version of Addon suitable for the
update script or other areas that don't need all the transforms.
This class exists to give the addon a different key for cache machine."""
objects = caching.CachingManager()
class Meta:
proxy = True
class Persona(caching.CachingMixin, models.Model):
"""Personas-specific additions to the add-on model."""
addon = models.OneToOneField(Addon)