コード例 #1
0
ファイル: views.py プロジェクト: TDispatch/london-articles
def create(request):
    if request.method == 'POST':
        post = Post(name=request.POST['name'], 
                    author=request.user, site=request.site)
        post.save()
        return HttpResponseRedirect(
                reverse("post_view", kwargs={'slug': post['slug']}))
    return HttpResponseRedirect(reverse("post_list"))
コード例 #2
0
def create(request):
    if request.method == 'POST':
        post = Post(name=request.POST['name'],
                    author=request.user,
                    site=request.site)
        post.save()
        return HttpResponseRedirect(
            reverse("post_view", kwargs={'slug': post['slug']}))
    return HttpResponseRedirect(reverse("post_list"))
コード例 #3
0
ファイル: forms.py プロジェクト: avelino/votacao_paredao_bbb
    def http_post(self, *args, **kwargs):
        if not self.user:
            return HttpResponseRedirect(reverse(self.url_invalid, service=self.request.service))

        if self.is_valid():
            self.user["password"] = self.cleaned_data["new_password"]
            self.user["reset_password_token"] = None
            self.user.save()

            return HttpResponseRedirect(reverse(self.url_finished, service=self.request.service))
コード例 #4
0
 def _tag_script_url(self, tags, caller):
     hsh = None
     if len(tags) > 40:
         full_path = tags
         tags = hashlib.sha1(tags).hexdigest()
         hsh, new = HashForTags.query().get_or_create(hash=tags, defaults={"full_path": full_path})
     return reverse("script_tags_inc", kwargs={"tags": tags, "inc": hsh["last_inc"] or 0 if hsh else 0})
コード例 #5
0
 def _tag_script_tags(self, tags, caller):
     hsh = None
     if len(tags) > 40:
         full_path = tags
         tags = hashlib.sha1(tags).hexdigest()
         hsh, new = HashForTags.query().get_or_create(hash=tags, defaults={"full_path": full_path})
     url = reverse("script_tags_inc", kwargs={"tags": tags, "inc": hsh["last_inc"] or 0 if hsh else 0})
     return '<script src="%s" rel="%s" charset="utf-8"></script>' % (url, tags)
コード例 #6
0
 def _tag_style_tags(self, tags, caller):
     hsh = None
     if len(tags) > 40:
         full_path = tags
         tags = hashlib.sha1(tags).hexdigest()
         hsh, new = HashForTags.query().get_or_create(hash=tags, defaults={"full_path": full_path})
     url = reverse("style_tags_inc", kwargs={"tags": tags, "inc": hsh["last_inc"] or 0 if hsh else 0})
     return '<link href="%s" rel="stylesheet"/>' % url
コード例 #7
0
ファイル: views.py プロジェクト: TDispatch/london-articles
def publish(request, slug):
    if request.method == 'POST':
        post = get_object_or_404(request.site['posts'], slug=slug)
        action = request.POST['action']
        if action == 'publish':
            post['is_draft'] = False
        elif action == 'unpublish':
            post['is_draft'] = True
        post.save()
    return HttpResponseRedirect(reverse("post_view", kwargs={'slug': post['slug']}))
コード例 #8
0
def publish(request, slug):
    if request.method == 'POST':
        post = get_object_or_404(request.site['posts'], slug=slug)
        action = request.POST['action']
        if action == 'publish':
            post['is_draft'] = False
        elif action == 'unpublish':
            post['is_draft'] = True
        post.save()
    return HttpResponseRedirect(
        reverse("post_view", kwargs={'slug': post['slug']}))
コード例 #9
0
ファイル: views.py プロジェクト: avelino/votacao_paredao_bbb
def redirect_to(request, url, permanent=False):
    """
    Generic view for redirection. The argument "url" supports a url name, a view path or a usual URL.
    """
    try:
        url = reverse(url)
    except (NoReverseMatch, SyntaxError):
        pass

    if permanent:
        return HttpResponsePermanentRedirect(url)
    else:
        return HttpResponseRedirect(url)
コード例 #10
0
ファイル: forms.py プロジェクト: avelino/votacao_paredao_bbb
    def http_post(self, *args, **kwargs):
        if self.is_valid():
            # Generates a token
            token = self.token_generator.make_token(self.user)
            self.user["reset_password_token"] = token
            self.user.save()

            # URLs
            url_sent = reverse(self.url_sent, service=self.request.service)
            url_confirmation = reverse(self.url_confirmation, kwargs={"token": token}, service=self.request.service)

            # Sends an e-mail message with the token for password reset
            send_token = import_anything(app_settings.PASSWORD_RESET_SEND_TOKEN)
            send_token(
                site=self.request.site,
                user=self.user,
                token=token,
                url_sent=url_sent,
                url_confirmation=url_confirmation,
                mail_template=self.mail_template,
            )

            return HttpResponseRedirect(url_sent)
        return {}
コード例 #11
0
ファイル: models.py プロジェクト: TDispatch/london-pages
 def get_url(self):
     kwargs = {}
     collections = Collection.query().filter(site=self['site'], items__contains=str(self['pk']))
     if collections.count():
         kwargs = collections[0].get_slugs() # TODO: what to do if page belongs to more than 1 collection?
     kwargs['slug'] = self['slug']
     
     try:
         from routes import dynamic_url_patterns
         url_patterns = dynamic_url_patterns[self['site']['name']] if self['site']['name'] in dynamic_url_patterns else []
     except ImportError:
         url_patterns = []
     
     try:
         return reverse('pages_views_category_view', kwargs=kwargs, dynamic_url_patterns=url_patterns)
     except:
         return '/%s/' % self['slug']
コード例 #12
0
ファイル: models.py プロジェクト: tomershagrir/london-pages
    def get_url(self):
        kwargs = {}
        collections = Collection.query().filter(site=self['site'],
                                                items__contains=str(
                                                    self['pk']))
        if collections.count():
            kwargs = collections[0].get_slugs(
            )  # TODO: what to do if page belongs to more than 1 collection?
        kwargs['slug'] = self['slug']

        try:
            from routes import dynamic_url_patterns
            url_patterns = dynamic_url_patterns[self['site']['name']] if self[
                'site']['name'] in dynamic_url_patterns else []
        except ImportError:
            url_patterns = []

        try:
            return reverse('pages_views_category_view',
                           kwargs=kwargs,
                           dynamic_url_patterns=url_patterns)
        except:
            return '/%s/' % self['slug']
コード例 #13
0
 def get_url(self):
     return reverse("post_view", kwargs={'slug': self['slug']})
コード例 #14
0
ファイル: forms.py プロジェクト: avelino/votacao_paredao_bbb
 def http_get(self, *args, **kwargs):
     if not self.user:
         return HttpResponseRedirect(reverse(self.url_invalid, service=self.request.service))
コード例 #15
0
 def _tag_url(self, name, caller):
     return reverse(name)
コード例 #16
0
def delete(request, slug):
    if request.method == 'POST':
        post = get_object_or_404(request.site['posts'], slug=slug)
        post.delete()
    return HttpResponseRedirect(reverse("post_list"))
コード例 #17
0
ファイル: views.py プロジェクト: avelino/votacao_paredao_bbb
 def http_post(self):
     if self.is_valid():
         return HttpResponseRedirect(reverse('result'))
コード例 #18
0
ファイル: models.py プロジェクト: TDispatch/london-articles
 def get_url(self):
     return reverse("post_view", kwargs={"slug": self["slug"]})
コード例 #19
0
ファイル: views.py プロジェクト: TDispatch/london-articles
def delete(request, slug):
    if request.method == 'POST':
        post = get_object_or_404(request.site['posts'], slug=slug)
        post.delete()
    return HttpResponseRedirect(reverse("post_list"))