当前位置: 首页>>代码示例>>Python>>正文


Python tagging.register函数代码示例

本文整理汇总了Python中tagging.register函数的典型用法代码示例。如果您正苦于以下问题:Python register函数的具体用法?Python register怎么用?Python register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了register函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的tagging.register函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。