def test_smart_url(self): self.assertEquals(reverse('blog.post_create'), smart_url("@blog.post_create")) self.assertEquals(reverse('blog.post_update', args=[self.post.id]), smart_url("[email protected]_update", self.post.id)) self.assertEquals(reverse('blog.post_create'), smart_url("/blog/post/create/")) self.assertEquals(reverse('blog.post_update', args=[self.post.id]), smart_url("/blog/post/update/%d/", self.post.id))
def test_smart_url(self): self.assertEquals(reverse("blog.post_create"), smart_url("@blog.post_create")) self.assertEquals( reverse("blog.post_update", args=[self.post.id]), smart_url("[email protected]_update", self.post.id) ) self.assertEquals(reverse("blog.post_create"), smart_url("/blog/post/create/")) self.assertEquals( reverse("blog.post_update", args=[self.post.id]), smart_url("/blog/post/update/%d/", self.post.id) )
def pre_process(self, request, *args, **kwargs): group = self.get_object() triggers = group.trigger_set.filter(is_archived=False) if triggers.count() > 0: trigger_list = ', '.join([trigger.__unicode__() for trigger in triggers]) messages.error(self.request, _("You cannot remove this group while it has active triggers (%s)" % trigger_list)) return HttpResponseRedirect(smart_url(self.cancel_url, group)) return super(ContactGroupCRUDL.Delete, self).pre_process(request, *args, **kwargs)
def format_point(pollrun): point = {'y': data.get(pollrun.pk, 0)} if url_name: url = smart_url(url_name, pollrun) if params: url = "{}?{}".format(url, urlencode(params)) point['url'] = url return point
def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) context["source"] = self.source context["source_url"] = smart_url(self.source_url, self.source) return context