Exemplo n.º 1
0
    def action_updatelink(self):
        link_format = self.param('linkfmt')

        if link_format:
            link_format = link_format.strip()
            g_blog.link_format = link_format
            g_blog.save()
            for entry in Entry.all():
                vals = {
                'year': entry.date.year,
                'month': str(entry.date.month).zfill(2),
                'day': entry.date.day,
                'postname': entry.slug,
                'post_id': entry.post_id,
                }

                if entry.slug:
                    newlink = link_format % vals
                else:
                    newlink = '?p=%(post_id)s' % vals

                if entry.link != newlink:
                    entry.link = newlink
                    entry.put()
            self.write('"ok"')
        else:
            self.write('"Please input url format."')
Exemplo n.º 2
0
    def get(self):
        lang_code = self.param('language')
        next = self.param('next')
        if not next and os.environ.has_key('HTTP_REFERER'):
            next = os.environ['HTTP_REFERER']
        if not next:
            next = '/'
        from django.utils.translation import check_for_language, activate, to_locale, get_language

        if lang_code and check_for_language(lang_code):
            g_blog.language = lang_code

            activate(lang_code)
            g_blog.save()
        self.redirect(next)