Exemple #1
0
def project_detail(request, slug, template_name="loupe/project_detail.html"):
    """
    Displays the corkboards for the given porject 'slug'
    to the user

    expects a slug and expects the user has access to the parent project
    """

    project = get_object_or_404(Project, slug=slug, members=request.user)
    if not request.user.is_staff:
        if request.user != project.members:
            request.user.message_set.create(message=_("You are trying to access a project you don't have permission to view!"))
            return HttpResponseRedirect(reverse('dashboard'))
     
    corkboards = Corkboard.objects.filter(project=project)
    form = CorkboardForm()
    
    if request.method == "POST":
        form = CorkboardForm(request.user, request.POST)
        if form.is_valid():
            corkboard = form.save(commit=False)
            corkboard.user = request.user
            corkboard.project = project
            corkboard.save()
            request.user.message_set.create(message=_("Successfully created corkboard '%s'") % corkboard.title)
                
            return HttpResponseRedirect(reverse('corkboard_detail', args=(corkboard.slug,)))
        
    return render_to_response(template_name, {
        "project": project,
        "form": form,
        "corkboards": corkboards,
    }, context_instance=RequestContext(request))
def project_detail(request, slug, template_name="loupe/project_detail.html"):
    """
    Displays the corkboards for the given porject 'slug'
    to the user

    expects a slug and expects the user has access to the parent project
    """

    if not request.user.is_staff:
        project = get_object_or_404(Project, slug=slug, members=request.user)
    else:
        project = get_object_or_404(Project, slug=slug)

    corkboards = Corkboard.objects.filter(project=project)
    form = CorkboardForm()

    if request.method == "POST":
        form = CorkboardForm(request.user, request.POST)
        if form.is_valid():
            corkboard = form.save(commit=False)
            corkboard.user = request.user
            corkboard.project = project
            corkboard.save()
            request.user.message_set.create(message=_("Successfully created corkboard '%s'") % corkboard.title)

            if notification:
                notification.send_now(
                    project.members.all(),
                    "corkboard_new_corkboard",
                    {"user": request.user, "corkboard": corkboard, "corkboard_url": corkboard.get_absolute_url},
                )

            return HttpResponseRedirect(reverse("corkboard_detail", args=(corkboard.slug,)))

    return render_to_response(
        template_name,
        {"project": project, "form": form, "corkboards": corkboards},
        context_instance=RequestContext(request),
    )
Exemple #3
0
def project_detail(request, slug, template_name="loupe/project_detail.html"):
    """
    Displays the corkboards for the given porject 'slug'
    to the user

    expects a slug and expects the user has access to the parent project
    """

    if not request.user.is_staff:
        project = get_object_or_404(Project, slug=slug, members=request.user)
    else:
        project = get_object_or_404(Project, slug=slug)

    corkboards = Corkboard.objects.filter(project=project)
    form = CorkboardForm()

    if request.method == "POST":
        form = CorkboardForm(request.user, request.POST)
        if form.is_valid():
            corkboard = form.save(commit=False)
            corkboard.user = request.user
            corkboard.project = project
            corkboard.save()
            request.user.message_set.create(
                message=_("Successfully created corkboard '%s'") %
                corkboard.title)

            if notification:
                notification.send_now(
                    project.members.all(), "corkboard_new_corkboard", {
                        "user": request.user,
                        "corkboard": corkboard,
                        "corkboard_url": corkboard.get_absolute_url
                    })

            return HttpResponseRedirect(
                reverse('corkboard_detail', args=(corkboard.slug, )))

    return render_to_response(template_name, {
        "project": project,
        "form": form,
        "corkboards": corkboards,
    },
                              context_instance=RequestContext(request))