Exemple #1
0
    def get_context_data(self, **kwargs):
        try:
            tag = TagsTool(
                projects=[self.object],
                priority=True,
            )[self.kwargs["tag"]].get()
        except IndexError:
            raise Http404

        if is_ajax(self.request):
            return dict(
                project=self.object,
                locales=list(tag.iter_locales()),
                tag=tag,
            )

        return dict(project=self.object, tag=tag)
Exemple #2
0
def get_slug(request):
    """Convert project name to slug."""
    log.debug("Convert project name to slug.")

    if not request.user.has_perm("base.can_manage_project"):
        log.error("Insufficient privileges.")
        return HttpResponse("error")

    if not is_ajax(request):
        log.error("Non-AJAX request")
        return HttpResponse("error")

    try:
        name = request.GET["name"]
    except MultiValueDictKeyError as e:
        log.error(str(e))
        return HttpResponse("error")

    log.debug("Name: " + name)

    slug = slugify(name)
    log.debug("Slug: " + slug)
    return HttpResponse(slug)
Exemple #3
0
 def get(self, request, *args, **kwargs):
     if is_ajax(request):
         return self.get_AJAX(request, *args, **kwargs)
     return super().get(request, *args, **kwargs)
Exemple #4
0
 def get(self, request, *args, **kwargs):
     if is_ajax(request):
         return self.get_AJAX(request, *args, **kwargs)
     return super(ProjectTagView, self).get(request, *args, **kwargs)