def create(cls, group, type, caption, description, approved, barrier, points, item_1=None, item_2=None, item_3=None): from the_tale.accounts.achievements.storage import achievements_storage order = cls._db_all().aggregate(models.Max('order'))['order__max'] if order is None: order = 0 model = cls._db_create(group=group, type=type, caption=caption, description=description, order=order, barrier=barrier, approved=approved, points=points, item_1=item_1._model if item_1 is not None else None, item_2=item_2._model if item_2 is not None else None, item_3=item_3._model if item_3 is not None else None) prototype = cls(model=model) achievements_storage.add_item(prototype.id, prototype) achievements_storage.update_version() return prototype
def save(self): from the_tale.accounts.achievements.storage import achievements_storage if id(self) != id(achievements_storage[self.id]): raise exceptions.SaveNotRegisteredAchievementError(achievement=self.id) super(AchievementPrototype, self).save() achievements_storage.update_version()