# -*- coding: utf-8 -*-
from base import *
# -*- coding: utf-8 -*-
from base import *
import re
from tag import Tag
import re
from tag import Tag
if not self.nis.deleted:
tag.add_to_usage_count(1)
if not self.nis.deleted:
tag.add_to_usage_count(1)
if not self.nis.deleted:
for name in tag_changes['removed']:
try:
tag = Tag.objects.get(name=name)
tag.add_to_usage_count(-1)
if not self.nis.deleted:
for name in tag_changes['removed']:
try:
tag = Tag.objects.get(name=name)
tag.add_to_usage_count(-1)
+ except Tag.DoesNotExist:
if action:
for tag in self.tags.all():
tag.add_to_usage_count(-1)
if action:
for tag in self.tags.all():
tag.add_to_usage_count(-1)
else:
for tag in Tag.objects.filter(name__in=self.tagname_list()):
tag.add_to_usage_count(1)
else:
for tag in Tag.objects.filter(name__in=self.tagname_list()):
tag.add_to_usage_count(1)
def delete(self, *args, **kwargs):
for tag in self.tags.all():
tag.add_to_usage_count(-1)
def delete(self, *args, **kwargs):
for tag in self.tags.all():
tag.add_to_usage_count(-1)
self.active_revision = None
self.save()
self.active_revision = None
self.save()
return force_unicode(self.name)
def add_to_usage_count(self, value):
return force_unicode(self.name)
def add_to_usage_count(self, value):
- if self.used_count + value < 0:
+ if int(self.used_count + value) < 0:
self.used_count = 0
else:
self.used_count = 0
else:
- self.used_count = models.F('used_count') + value
+ self.used_count += value
+
+ self.save()
def cache_key(self):
return self._generate_cache_key(Tag.safe_cache_name(self.name))
def cache_key(self):
return self._generate_cache_key(Tag.safe_cache_name(self.name))