Ejemplo n.º 1
0
def initiative_create(request):
    if request.method == "POST":
        form = GroupForm(request.POST, request.FILES)
        if form.is_valid():
            group = form.save(commit=False)
            group.profile_type = 'ini'
            group.save()
            form.save_m2m()
            group.join(request.user, role="manager")
            # Create the collection corresponding to this initiative
            collection = Collection()
            collection.name = group.title
            collection.slug = group.slug
            collection.group = group
            collection.save()
            return HttpResponseRedirect(
                reverse(
                    "initiative_detail",
                    args=[
                        group.slug]))
    else:
        form = GroupForm(initial={'profile_type': 'ini'})

    if request.user.is_superuser:
        return render_to_response("groups/group_create.html", {
            "form": form,
            }, context_instance=RequestContext(request))
    else:
        return HttpResponse(status=403)
Ejemplo n.º 2
0
def initiative_create(request):
    if request.method == "POST":
        form = GroupForm(request.POST, request.FILES)
        if form.is_valid():
            group = form.save(commit=False)
            group.profile_type = 'ini'
            group.save()
            form.save_m2m()
            group.join(request.user, role="manager")
            # Create the collection corresponding to this initiative
            collection = Collection()
            collection.name = group.title
            collection.slug = group.slug
            collection.group = group
            collection.save()
            return HttpResponseRedirect(
                reverse(
                    "initiative_detail",
                    args=[
                        group.slug]))
    else:
        form = GroupForm(initial={'profile_type': 'ini'})

    if request.user.is_superuser:
        return render_to_response("groups/group_create.html", {
            "form": form,
            }, context_instance=RequestContext(request))
    else:
        return HttpResponse(status=403)
Ejemplo n.º 3
0
def initiative_members_add(request, slug):
    group = get_object_or_404(GroupProfile, slug=slug)

    if not group.user_is_role(request.user, role="manager"):
        return HttpResponseForbidden()

    form = GroupMemberForm(request.POST)

    if form.is_valid():
        role = form.cleaned_data["role"]
        for user in form.cleaned_data["user_identifiers"]:
            group.join(user, role=role)

    return redirect("initiative_detail", slug=group.slug)
Ejemplo n.º 4
0
def initiative_members_add(request, slug):
    group = get_object_or_404(GroupProfile, slug=slug)

    if not group.user_is_role(request.user, role="manager"):
        return HttpResponseForbidden()

    form = GroupMemberForm(request.POST)

    if form.is_valid():
        role = form.cleaned_data["role"]
        for user in form.cleaned_data["user_identifiers"]:
            group.join(user, role=role)

    return redirect("initiative_detail", slug=group.slug)
Ejemplo n.º 5
0
def unlock_chord(self, group, callback, interval=1, max_retries=None):
    if group.ready():
        return maybe_signature(callback).delay(group.join())
    raise self.retry(countdown=interval, max_retries=max_retries)