本文整理汇总了Python中tagging.register函数的典型用法代码示例。如果您正苦于以下问题:Python register函数的具体用法?Python register怎么用?Python register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了register函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: handle_model
def handle_model(self):
self.model.add_to_class('tags', TagField(_('tags')))
# use another name for the tag descriptor See
# http://code.google.com/p/django-tagging/issues/detail?id=95 for the
# reason why
tagging.register(self.model, tag_descriptor_attr='etags')
开发者ID:finid,项目名称:feincms,代码行数:7,代码来源:tags.py
示例2: register
def register(cls, admin_cls, *args):
TagField.help_text = _('Use commas to separate tags.')
cls.add_to_class('tags', TagField(_('tags')))
# use another name for the tag descriptor
# See http://code.google.com/p/django-tagging/issues/detail?id=95 for the reason why
tagging.register(cls, tag_descriptor_attr='etags')
admin_cls.search_fields += ('tags',)
admin_cls.show_on_top.append('tags')
开发者ID:mjmeintjes,项目名称:feincms-elephantblog,代码行数:9,代码来源:tags.py
示例3: available_bookownership
pass
except TypeError:
pass
if self.cover == "":
if book is None:
book = utils.get_book_from_cache(str(self.douban_id))
if book is None:
return self.cover
self.cover = book['link'][2]['@href']
self.save()
return self.cover.replace('spic', 'lpic')
def available_bookownership(self):
return self.bookownership_set.filter(~Q(status=u"5"))
tagging.register(Book)
class BookComment(models.Model):
datetime = models.DateTimeField()
book = models.ForeignKey(Book)
user = models.ForeignKey(User)
title = models.CharField(max_length=256)
content = models.CharField(max_length=2048)
status = models.IntegerField()
BO_STAT = (
("1", "可借"),
("2", "不可借"),
("3", "借出"),
开发者ID:EchoUtopia,项目名称:sichu_web,代码行数:31,代码来源:models.py
示例4: get_technologies
def get_technologies(self):
return self.technologies.all()
def get_saved_by(self):
from accounts.models import RhizomeUser
return RhizomeUser.objects \
.filter(saved_artworks__id = self.id) \
.filter(is_active = True) \
.filter(visible=True)
def get_collection_fragment_url(self):
return "/artbase/collections/artwork/%s/fragment.html" % self.id
try:
tagging.register(ArtworkStub,tag_descriptor_attr="artwork_stub")
except tagging.AlreadyRegistered:
# http://code.google.com/p/django-tagging/issues/detail?id=128
# Not sure the right way to register a model for tagging b/c it
# raises this error if registered more than once. We end up registering
# the first time during "manage.py syncdb" and then a second time when
# actually attempting to run the site.
pass
def on_stub_save(sender, **kwargs):
#
# happens whenever someone saves, this could be refined to work with status changes instead
#
instance = kwargs['instance']
if instance.status != "unsubmitted" or instance.status != "deleted":
instance.user.get_profile().add_points_for_object(instance)
开发者ID:hgw,项目名称:rhizome.org,代码行数:30,代码来源:models.py
示例5: _
self.country.save()
if self.region:
self.region.num_people = self.region.djangoperson_set.count()
self.region.save()
class Meta:
verbose_name = _('Django person')
verbose_name_plural = _('Django people')
def irc_tracking_allowed(self):
return not self.machinetags.filter(
namespace='privacy', predicate='irctrack', value='private',
).count()
tagging.register(DjangoPerson,
tag_descriptor_attr='skilltags',
tagged_item_manager_attr='skilltagged',
)
class PortfolioSite(models.Model):
title = models.CharField(_('Title'), max_length=100)
url = models.URLField(_('URL'), max_length=255)
contributor = models.ForeignKey(DjangoPerson,
verbose_name=_('Contributor'))
def __unicode__(self):
return u'%s <%s>' % (self.title, self.url)
class Meta:
verbose_name = _('Portfolio site')
verbose_name_plural = _('Portfolio sites')
开发者ID:mcdonc,项目名称:djangopeople,代码行数:32,代码来源:models.py
示例6: super
if self.auto_sync:
self.need_sync = True
super(SoftwareCollection, self).save(*args, **kwargs)
def delete(self, *args, **kwargs):
# rename of repos root is faster than deleting
# (name can not start with '.', therefore this is save)
os.rename(self.get_repos_root(), os.path.join(
settings.REPOS_ROOT,
self.maintainer.username,
'.{}.deleted'.format(self.id)
))
# delete scl in the database
super(SoftwareCollection, self).delete(*args, **kwargs)
tagging.register(SoftwareCollection)
class Repo(models.Model):
# automatic value (scl.slug/name) used as unique key
slug = models.SlugField(max_length=150, editable=False)
scl = models.ForeignKey(SoftwareCollection, related_name='repos')
name = models.CharField(_('Name'), max_length=50)
copr_url = models.CharField(_('Copr URL'), max_length=200)
download_count = models.IntegerField(default=0, editable=False)
enabled = models.BooleanField(_('Enabled'), default=True)
class Meta:
# in fact, since slug is made of those and slug is unique,
# this is not necessarry, but as a side effect, it create index,
# which may be useful
开发者ID:tradej,项目名称:softwarecollections,代码行数:31,代码来源:models.py
示例7: __unicode__
class Meta:
verbose_name_plural = "Entries"
ordering = ['-pub_date']
def __unicode__(self):
return self.title
def get_absolute_url(self):
return ('coltrane_entry_detail', (), {'year': self.pub_date.strftime("%Y"),
'month': self.pub_date.strftime("%b").lower(),
'day': self.pub_date.strftime("%d"),
'slug': self.slug })
get_absolute_url = models.permalink(get_absolute_url)
tagging.register(Entry, tag_descriptor_attr='etags')
class Link(models.Model):
title = models.CharField(max_length = 250)
description = models.TextField(blank = True)
description_html = models.TextField(blank = True)
url = models.URLField(unique = True)
posted_by = models.ForeignKey(User)
pub_date = models.DateTimeField(default = datetime.datetime.now)
slug = models.SlugField(unique_for_date = 'pub_date')
tags = TagField()
enable_comments = models.BooleanField(default = True)
post_elsewhere = models.BooleanField('Post to Delicious', default = True)
via_name = models.CharField('Via', max_length = 250, blank = True, help_text = 'The name of the person whose site you spotted the link on. Optional.')
via_url = models.URLField('Via URL', blank = True, help_text = 'The URL of the site where you spotted the link')
开发者ID:swoopej,项目名称:Django_Blog,代码行数:29,代码来源:models.py
示例8: _
text = models.TextField()
verbose_name = _("Text Collaboration")
verbose_name_plural = _("Text Collaborations")
class Meta:
abstract = False
def __unicode__(self):
return unicode(self.text)
@models.permalink
def get_absolute_url(self):
return ("textcontent_details_id", [str(self.id)])
tagging.register(TextContent)
class AudioContent(Content):
"""
Content with sound
"""
file = models.FileField(storage=_FILE_STORAGE, upload_to="audio/%Y/%m/%d")
verbose_name = _("Audio Collaboration")
verbose_name_plural = _("Audio Collaborations")
class Meta:
abstract = False
开发者ID:linkinpark342,项目名称:museic,代码行数:29,代码来源:models.py
示例9: Q
"""
from ecomstore.checkout.models import Order, OrderItem
from django.db.models import Q
orders = Order.objects.filter(orderitem__product=self)
users = User.objects.filter(order__orderitem__product=self)
items = OrderItem.objects.filter( Q(order__in=orders) |
Q(order__user__in=users)
).exclude(product=self)
products = Product.active.filter(orderitem__in=items).distinct()
return products
@property
def cache_key(self):
return self.get_absolute_url()
try:
tagging.register(Product)
except tagging.AlreadyRegistered:
pass
class ActiveProductReviewManager(models.Manager):
""" Manager class to return only those product reviews where each instance is approved """
def all(self):
return super(ActiveProductReviewManager, self).all().filter(is_approved=True)
class ProductReview(models.Model):
""" model class containing product review data associated with a product instance """
RATINGS = ((5,5),(4,4),(3,3),(2,2),(1,1),)
product = models.ForeignKey(Product)
user = models.ForeignKey(User)
title = models.CharField(max_length=50)
开发者ID:Kanyutu,项目名称:ecomstore,代码行数:31,代码来源:models.py
示例10: smart_unicode
self.metering_mode = smart_unicode(tags.get('EXIF MeteringMode', '')).strip()
self.focal_length = smart_unicode(tags.get('EXIF FocalLength', '')).strip()
self.color_space = smart_unicode(tags.get('EXIF ColorSpace', '')).strip()
self.focal_length = smart_unicode(tags.get('EXIF FocalLength', '')).strip()
self.ycbcr_positioning = smart_unicode(tags.get('Image YCbCrPositioning', '')).strip()
self.sensing_method = smart_unicode(tags.get('EXIF SensingMethod', '')).strip()
if not self.date_created:
if self.date_raw:
self.date_created = self.date_raw
class Meta:
ordering = ['-date_created']
get_latest_by = 'date_created'
tagging.register(Photo, tag_descriptor_attr='_tags')
class FlickrPhoto(models.Model):
"""A FlickrPhoto object hangs on top of a Photo object to add Flickr-specific metadata."""
photo = models.ForeignKey(Photo)
flickr_photo_id = models.CharField(max_length=200)
secret = models.CharField(max_length=30)
server = models.PositiveSmallIntegerField()
isfavorite = models.BooleanField(blank=True, default=False)
license = models.IntegerField()
rotation = models.IntegerField()
originalsecret = models.CharField(max_length=30, blank=True)
originalformat = models.CharField(max_length=100)
media = models.CharField(max_length=200)
owner = models.ForeignKey('FlickrUser')
ispublic = models.BooleanField(default=True)
开发者ID:syncopated,项目名称:97bottles,代码行数:31,代码来源:models.py
示例11: Widget
from django.contrib.auth.models import User
from django.db import models
import tagging
class Widget(models.Model):
name = models.CharField(max_length=50)
user = models.ForeignKey(User)
tagging.register(Widget)
开发者ID:ax003d,项目名称:PythonSamples,代码行数:11,代码来源:models.py
示例12: super
if(self.parent.album.highlight is not None and
self.parent.album.highlight.id == self.id):
self.parent.highlight = self.get_next()
self.parent.save()
tasks.albumitem_delete_directory.delay(self.get_directory())
return super(AlbumConvertableItem, self).delete()
def __unicode__(self):
return self.title
def get_tags(self):
return tagging.models.Tag.objects.get_for_object(self)
tagging.register(AlbumConvertableItem, tag_descriptor_attr='tagss')
class Image(AlbumConvertableItem):
pass
signals.pre_save.connect(albumitem_save, sender=Image)
def generate_image_thumbs(sender, instance, **kwargs):
if(kwargs['created']):
tasks.albumitem_generate_thumbnails.delay(instance, settings.ALBUMS_THUMBSIZES)
signals.post_save.connect(generate_image_thumbs, sender=Image)
class Video(AlbumConvertableItem):
def get_video_path(self, filename):
return os.path.join(self.get_directory(), filename)
video = models.FileField(upload_to=get_video_path)
video_ready = models.BooleanField(default=False, null=False)
开发者ID:jgroszko,项目名称:django-albums,代码行数:31,代码来源:models.py
示例13: Taggable
from django.db import models
from tagging.fields import TagField
import tagging
class Taggable(models.Model):
name = models.CharField(max_length=50)
tags = TagField(null=True, blank=True)
def __unicode__(self):
return self.name
tagging.register(Taggable, tag_descriptor_attr='etags')
开发者ID:cellarosi,项目名称:django-autocomplete-light,代码行数:14,代码来源:models.py
示例14: streams
data[item.key] = item.value
return data
def streams(self):
return Stream.objects.filter(event=self)
def update(self, data):
if isinstance(data, basestring):
data = json.loads(data)
valid_fields = ["end", "tags"]
for key, value in data.iteritems():
if key in valid_fields:
setattr(self, key, value)
tagging.register(Event, tag_descriptor_attr="tag_list")
class Attribute(models.Model):
event = models.ForeignKey(Event)
key = models.CharField(max_length=20)
value = models.CharField(max_length=60)
def __unicode__(self):
return "Key: %s, Value: %s" % (self.key, self.value)
class Stream(models.Model):
event = models.ForeignKey(Event)
name = models.CharField(max_length=20)
text = models.TextField(blank=True, null=True)
开发者ID:gmjosack,项目名称:auditor,代码行数:31,代码来源:models.py
示例15: __unicode__
rtype = models.ForeignKey(ResourceType, verbose_name="Resource Type", blank=True, null=True)
def __unicode__(self):
return '%s' % self.url
def get_absolute_url(self):
return '/resources/%s' % self.id
class PersonalResource(models.Model):
added = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
title = models.CharField(max_length=140, blank=True)
note = models.TextField(blank=True)
resource = models.ForeignKey('aresource.Resource')
person = models.ForeignKey('people.Person')
video = models.BooleanField()
rtype = models.ForeignKey('aresource.ResourceType',verbose_name="Resource Type", blank=True, null=True)
tag = TagField()
def __unicode__(self):
return self.resource
def get_absolute_url(self):
return '/people/user-resources/%s/%s' % (self.person.user, self.pk)
tagging.register(PersonalResource)
开发者ID:bmount,项目名称:courseslate,代码行数:30,代码来源:models.py
示例16: TextBook
# THIS MODEL IS DEPRECATED AND WILL BE REMOVED IN FUTURE VERSIONS.
class TextBook(models.Model):
"""THIS MODEL IS DEPRECATED AND WILL BE REMOVED IN FUTURE VERSIONS
SINCE THIS MODEL IS A MERE COPY OF Task MODEL.
Whatever this model tries to do can be done on views side thereby
keeping our database as normalized as possible avoiding redundancies.
"""
name = models.CharField(max_length=1024)
chapters = models.ManyToManyField(Task, related_name="textbooks")
tags_field = TagField(verbose_name="Tags")
created_by = models.ForeignKey(User, related_name="created_textbooks")
approved_by = models.ForeignKey(User, null=True, blank=True, related_name="approved_textbooks")
status = models.CharField(max_length=255, choices=TB_STATUS_CHOICES, default="Unpublished")
creation_datetime = models.DateTimeField(auto_now_add=True)
approval_datetime = models.DateTimeField(blank=True, null=True)
last_modified = models.DateTimeField(auto_now=True, default=datetime.now())
tagging.register(Task)
tagging.register(TextBook)
开发者ID:FOSSEE,项目名称:pytask,代码行数:29,代码来源:models.py
示例17: upvotes
def upvotes(self):
return self.votes.filter(vote_up=True).count()
def downvotes(self):
return self.votes.filter(vote_up=False).count()
def allvotes(self):
return self.votes.count()
def voted(self, visitor_id):
try:
v = self.votes.get(visitor__pk=visitor_id)
return 1 if v.vote_up else -1
except ObjectDoesNotExist:
return 0
class Vote(models.Model):
visitor = models.ForeignKey(Session)
post = models.ForeignKey(Post, related_name='votes')
vote_up = models.BooleanField()
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
submitted_from = models.IPAddressField()
class Meta:
unique_together = (('visitor', 'post'),)
tagging.register(Post)
开发者ID:ebroder,项目名称:ibtsocs,代码行数:29,代码来源:models.py
示例18: IssueManager
# Denormalized data - for sort order
offensiveness = models.IntegerField(default=0)
score = models.IntegerField(default=0)
hotness = models.IntegerField(default=0)
votes = models.IntegerField(default=0)
objects = IssueManager()
active = ActiveManager()
laws = LawManager()
def __unicode__(self):
return self.title
tagging.register(Issue)
class IssueAdmin(admin.ModelAdmin):
prepopulated_fields = {'slug' : ("title",)}
date_hierarchy = "time_stamp"
list_display = ('title', 'time_stamp', 'user', 'is_draft' )
list_filter = ('title', 'time_stamp', 'user', 'is_draft' )
def votes(self , obj):
return Vote.objects.get_for_object(obj).count()
admin.site.register(Issue, IssueAdmin)
开发者ID:spreeker,项目名称:democracygame,代码行数:29,代码来源:models.py
示例19: was_solved_by
return Problem.STATE_CHOICES[self.state][1]
def was_solved_by(self, user):
return Solver.objects.filter(problem=self, user=user,
solved=True).exists()
def get_absolute_url(self):
return reverse("judge-problem-read", kwargs={"slug": self.slug})
class Meta:
permissions = (
('read_problem', 'Can read problem always'),
('edit_problem', 'Can edit problem always'),
)
tagging.register(Problem)
class Attachment(models.Model):
problem = models.ForeignKey(Problem, db_index=True)
file = models.FileField(max_length=1024, upload_to='/will_not_be_used/')
class Submission(models.Model):
(RECEIVED, COMPILING, RUNNING, JUDGING, COMPILE_ERROR,
OK, ACCEPTED, WRONG_ANSWER, RUNTIME_ERROR, TIME_LIMIT_EXCEEDED,
CANT_BE_JUDGED, REJUDGE_REQUESTED) = range(12)
STATES_KOR = dict([(RECEIVED, u"수신"),
(COMPILING, u"컴파일중"),
(RUNNING, u"실행중"),
(JUDGING, u"채점중"),
(COMPILE_ERROR, u"컴파일 실패"),
(OK, u"수행완료"),
开发者ID:Corea,项目名称:algospot,代码行数:31,代码来源:models.py
示例20: super
is_new = True
else:
is_new = False
super(Project, self).save(*args, **kwargs)
if is_new:
project_created.send(sender=self)
def delete(self, *args, **kwargs):
self.resources.all().delete()
project_deleted.send(sender=self)
super(Project, self).delete(*args, **kwargs)
@permalink
def get_absolute_url(self):
return ('project_detail', None, { 'project_slug': self.slug })
@property
def wordcount(self):
return self.resources.aggregate(Sum('wordcount'))['wordcount__sum']
@property
def team_member_count(self):
return len(User.objects.filter(team_members__project=self))
try:
tagging.register(Project, tag_descriptor_attr='tagsobj')
except tagging.AlreadyRegistered, e:
logger.debug('Tagging: %s' % str(e))
log_model(Project)
开发者ID:hfeeki,项目名称:transifex,代码行数:30,代码来源:models.py
注:本文中的tagging.register函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论