django.db.models.permalink

Here are the examples of the python api django.db.models.permalink taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

186 Examples 7

Example 1

Project: django-blogdor Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):        
        params = {
            'year': self.date_published.year,
            'slug': self.slug,
        }
        urlname = 'blogdor_post'
        if WP_PERMALINKS:
            urlname += '_wpcompat'
            params['month'] = "%02d" % self.date_published.month,
            params['day'] = "%02d" % self.date_published.day
        return (urlname, (), params)

Example 2

Project: source Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        return ('article_detail', (), {
            'section': self.section.slug,
            'slug': self.slug
        })

Example 3

Project: storybase Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        """Calculate the canonical URL for a Story"""
        if self.slug:
            return ('story_detail', [self.slug])

        return ('story_detail', [self.story_id])

Example 4

Project: ocf Source File: models.py
    @models.permalink
    def get_agg_remove_url(self, aggregate):
        "Returns URL to remove aggregate from project"
        return ("project_remove_agg", (), {
            "proj_id": self.id,
            "agg_id": aggregate.id})

Example 5

Project: 2buntu-blog Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        kwargs, slug = {'id': self.id}, slugify(self.title)
        if slug:
            kwargs['slug'] = slug
        return ('articles:view', (), kwargs)

Example 6

Project: django-bible Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        """
        Returns the absolute url
        """
        return ('chapter_detail', [self.book.slug, self.number])

Example 7

Project: lflux Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        if hasattr(self, '_version'):
            return ('story', [self.versions.current().slug],)
        else:
            return ('story', [self.slug],)

Example 8

Project: django-repositories Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        """
        The path to the repository
        
        :rtype: ``string``
        """
        return self._vcs.get_absolute_url()

Example 9

Project: weblate Source File: translation.py
Function: get_translate_url
    @models.permalink
    def get_translate_url(self):
        return ('translate', (), {
            'project': self.subproject.project.slug,
            'subproject': self.subproject.slug,
            'lang': self.language.code
        })

Example 10

Project: django-knowledge Source File: models.py
    @models.permalink
    def get_absolute_url(self):
        from django.template.defaultfilters import slugify

        if settings.SLUG_URLS:
            return ('knowledge_thread', [self.id, slugify(self.title)])
        else:
            return ('knowledge_thread_no_slug', [self.id])

Example 11

Project: djKarma Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        print "getting file absolute URL"
        print self.id, self.course, self.school
        #print "\t", self.id, self.title, self.school.slug, self.course.slug
        if self.school is None or self.course is None:
            print "using the file and pk based absolute url"
            # This code path is run on initial upload before course exists
            return ('file', [str(self.pk)])
        else:
            return ('nurl_file', [str(self.school.slug), str(self.course.slug), str(self.pk)])

Example 12

Project: django-feedme Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        """
        Feed permalink
        :return:
        """
        return ('feedme-feed-list-by-feed', (), {'feed_id': self.id})

Example 13

Project: django-calendartools Source File: modelbase.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        return ('occurrence-detail', [], {
            'slug':   self.event.slug,
            'pk':     self.pk
        })

Example 14

Project: django-blogs Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        if self.blog:
            return ('blog_post_detail', None, {
                'blog_slug': self.blog.slug,
                'slug': self.slug,
            })
        else:
            return ('blog_user_post_detail', None, {
                'username': self.author.username,
                'slug': self.slug,
            })

Example 15

Project: mezzanine-recipes Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        url_name = "blog_post_detail"
        kwargs = {"slug": "%s/%s" % (settings.ARTICLES_SLUG, self.slug)}
        if settings.BLOG_URLS_USE_DATE:
            url_name = "blog_post_detail_date"
            month = str(self.publish_date.month)
            if len(month) == 1:
                month = "0" + month
            day = str(self.publish_date.day)
            if len(day) == 1:
                day = "0" + day
            kwargs.update({
                "day": day,
                "month": month,
                "year": self.publish_date.year,
                })
        return (url_name, (), kwargs)

Example 16

Project: django-video Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        return ('videostream_video_detail', (), { 
            'year': self.publish_date.strftime("%Y"),
            'month': self.publish_date.strftime("%b"),
            'day': self.publish_date.strftime("%d"), 
            'slug': self.slug 
        })

Example 17

Project: django-sophie Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        c = { 
                'entry_slug': self.slug
            }
        if multiblog_enabled:
            c.update({'blog_slug': self.blog.slug})
        return ('sophie_entry_details_url', (), c)

Example 18

Project: towel Source File: modelview.py
    def __init__(self, model, **kwargs):
        self.model = model
        for key, value in kwargs.items():
            if not hasattr(self, key):
                raise TypeError('%s() received an invalid keyword %r' % (
                    self.__class__.__name__, key))
            setattr(self, key, value)

        if not hasattr(self.model, 'get_absolute_url'):
            # Add a simple primary key based URL to the model if it does not
            # have one yet
            self.model.get_absolute_url = models.permalink(
                lambda self: (
                    '%s_%s_detail' % app_model_label(self),
                    (self.pk,),
                    {}))

Example 19

Project: job-runner Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        return ('job_runner:job_run', (), {
            'project_id': self.job.job_template.project.pk,
            'job_id': self.job.pk,
            'run_id': self.pk,
        })

Example 20

Project: django-shortim Source File: models.py
    @models.permalink
    def get_absolute_url(self):
        if not self.id and self.is_local_url():
            return self.url

        code = SequenceMapper.from_decimal(self.id)
        return ('shortim_preview', (), {'code':code})

Example 21

Project: patchwork Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        return ('patchwork.views.bundle.bundle', (), {
            'username': self.owner.username,
            'bundlename': self.name,
        })

Example 22

Project: django-agenda Source File: models.py
Function: get_absolute_url
    @models.permalink                                               
    def get_absolute_url(self):
        return ('agenda-detail', (), {
                  'year'  : self.event_date.year, 
                  'month' : self.event_date.month, 
                  'day'   : self.event_date.day, 
                  'slug'  : self.slug })

Example 23

Project: gnotty Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        kwargs = {
            "year": self.message_time.year,
            "month": self.message_time.month,
            "day": self.message_time.day,
        }
        return ("gnotty_day", (), kwargs)

Example 24

Project: 2buntu-blog Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        return ('categories:view', (), {
            'id': self.id,
            'slug': slugify(self.name),
        })

Example 25

Project: django-scribbler Source File: models.py
Function: get_save_url
    @models.permalink
    def get_save_url(self):
        if self.pk:
            return ('edit-scribble', (), {'scribble_id': self.pk})
        else:
            return ('create-scribble', (), {})

Example 26

Project: feincms Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        """
        Return the absolute URL of this page.
        """
        # result url never begins or ends with a slash
        url = self._cached_url.strip('/')
        if url:
            return ('feincms_handler', (url,), {})
        return ('feincms_home', (), {})

Example 27

Project: django-blog-zinnia Source File: author.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        """
        Builds and returns the author's URL based on his username.
        """
        return ('zinnia:author_detail', [self.get_username()])

Example 28

Project: teerace Source File: models.py
Function: get_absolute_url
	@models.permalink
	def get_absolute_url(self):
		return (
			'blog.views.entry_detail',
			(),
			{'entry_id': self.id, 'slug': self.slug},
		)

Example 29

Project: ocf Source File: models.py
    @models.permalink
    def get_agg_update_url(self, aggregate):
        "Returns URL to update an aggregate's info related to the project"
        return ("project_update_agg", (), {
            "proj_id": self.id,
            "agg_id": aggregate.id})

Example 30

Project: tendenci Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        from tendenci.apps.profiles.utils import clean_username
        cleaned_username = clean_username(self.user.username)
        if cleaned_username != self.user.username:
            self.user.username = cleaned_username
            self.user.save()
        return ('profile', [self.user.username])

Example 31

Project: Lyra Source File: models.py
    @models.permalink
    def get_week_link(self):
        year, week, weekday = self.start.isocalendar()
        return ("%s:browse_week" % self.namespace, 
                (), 
                {"year": year, "week": week})

Example 32

Project: django-bible Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        """
        Returns the absolute url
        """
        return ('book_detail', [self.slug,])

Example 33

Project: django-diplomacy Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        return ('diplomacy_turn_detail', (), {
            'slug': self.game.slug,
            'season': self.season,
            'year': str(self.year),})

Example 34

Project: snowy Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        if self.slug == "":
            return ('note_detail_no_slug', (), {
                'note_id': self.id,
                'username': self.author.username,
            })
        else:
            return ('note_detail', (), {
                'note_id': self.id,
                'username': self.author.username,
                'slug': self.slug,
            })

Example 35

Project: django-ostinato Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        if self.publish_date:
            return ("blog_entry_detail", [], {
                'year': self.publish_date.year,
                'month': self.publish_date.strftime('%m'),
                'day': self.publish_date.strftime('%d'),
                'slug': self.slug,
            })
        else:
            return ("blog_entry_preview", [self.id], {})

Example 36

Project: django-sophie Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        c = {}
        if multiblog_enabled:
            c.update({ 'blog_slug': self.slug })
        return ('sophie_blog_index_url', (), c)

Example 37

Project: lithium Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        return ('blog.post_detail', None, {
            'year': self.pub_date.strftime("%Y"),
            'month': self.pub_date.strftime("%b").lower(),
            'day': self.pub_date.strftime("%d"),
            'slug': self.slug})

Example 38

Project: mezzanine-recipes Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        url_name = "blog_post_detail"
        kwargs = {"slug": "%s/%s" % (settings.RECIPES_SLUG, self.slug)}
        if settings.BLOG_URLS_USE_DATE:
            url_name = "blog_post_detail_date"
            month = str(self.publish_date.month)
            if len(month) == 1:
                month = "0" + month
            day = str(self.publish_date.day)
            if len(day) == 1:
                day = "0" + day
            kwargs.update({
                "day": day,
                "month": month,
                "year": self.publish_date.year,
                })
        return (url_name, (), kwargs)

Example 39

Project: django-rcal Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self, display='single'):
        if display == 'week':
            week = self.start.isocalendar()[1]
            return 'rcal.cal', ('week', self.start.year, week), {}
        else:
            return 'rcal.event', (self.pk,), {}

Example 40

Project: storybase Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        """Calculate the canonical URL for a Help item"""
        if self.slug:
            return ('help_detail', [self.slug])

        return ('help_detail', [self.help_id])

Example 41

Project: mozilla-ignite Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        kwargs = {
            'entry_id': self.slug,
            'phase': self.submission.phase_slug,
            }
        return ('entry_show', [], kwargs)

Example 42

Project: django-cbv-inspector Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        return ('module-detail', (), {
            'package': self.project_version.project.name,
            'version': self.project_version.version_number,
            'module': self.name,
        })

Example 43

Project: source Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        '''shortcut for linking to Guide when GuideArticle is in context'''
        return ('guide_detail', (), {
            'slug': self.guide.slug
        })

Example 44

Project: django-bmf Source File: configuration.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        return ('djangobmf:configuration', (), {
            "app_label": self.app_label,
            "name": self.field_name,
        })

Example 45

Project: wwwhisper Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        """Constructs URL of the permission resource."""
        return ('wwwhisper_allowed_user', (),
                {'location_uuid' : self.http_location.uuid,
                 'user_uuid': self.user.uuid})

Example 46

Project: django-cbv-inspector Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        return ('version-detail', (), {
            'package': self.project.name,
            'version': self.version_number,
        })

Example 47

Project: pari Source File: article.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        name = "article-detail"
        if self.is_topic:
            name = "topic-detail"
        return name, (), {"slug": self.slug}

Example 48

Project: tendenci Source File: models.py
    @models.permalink
    def get_discount_url(self):
        from tendenci.apps.discounts.models import Discount
        if self.discount_code:
            try:
                discount = Discount.objects.get(discount_code=self.discount_code)
                return ('discount.detail', [discount.id])
            except Discount.DoesNotExist:
                return ''
        return ''

Example 49

Project: django-staff Source File: models.py
Function: get_absolute_url
    @models.permalink
    def get_absolute_url(self):
        """
        The URL
        """
        return ('staff_staffmember_detail', [self.slug])

Example 50

Project: django-blog-zinnia Source File: entry.py
    @models.permalink
    def get_absolute_url(self):
        """
        Builds and returns the entry's URL based on
        the slug and the creation date.
        """
        publication_date = self.publication_date
        if timezone.is_aware(publication_date):
            publication_date = timezone.localtime(publication_date)
        return ('zinnia:entry_detail', (), {
            'year': publication_date.strftime('%Y'),
            'month': publication_date.strftime('%m'),
            'day': publication_date.strftime('%d'),
            'slug': self.slug})
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3 Page 4