Exemplo n.º 1
0
def user_contact(request, user_id):
    nav_selected = "users"
    user = request.user if request.user.id is user_id else get_object_or_404(User, id=user_id)

    if request.user <> user and user.get_profile().is_profile_private:
        return forbidden(request,
                         _("Sorry, but you do not have permissions to contact this user."))

    from discussions.models import Discussion as GenericDiscussion
    from discussions.forms import DiscussionCreateForm

    if request.method == "POST":
        disc_form = DiscussionCreateForm(request.user, request.POST)
        if disc_form.is_valid():
            disc = GenericDiscussion.objects.create(
                subject=disc_form.cleaned_data['subject'],
                body=disc_form.cleaned_data['body'],
                parent_id=None,
                user=request.user, 
                content_object=user,
                is_public=False,
                disallow_replies=True,
                reply_count=0,
                contact_admin=True,
            )
            messages.success(
                request, "Your message has been sent to %s" % user.get_full_name())
            return redirect(user)
    else:
        disc_form = DiscussionCreateForm(request.user)
    return render_to_response("rah/user_contact.html",
                              locals(), 
                              context_instance=RequestContext(request)) 
Exemplo n.º 2
0
def challenge_contact_admins(request, challenge_id):
    challenge = get_object_or_404(Challenge, id=challenge_id)
    from discussions.models import Discussion as GenericDiscussion
    from discussions.forms import DiscussionCreateForm

    if request.method == "POST":
        disc_form = DiscussionCreateForm(request.user, request.POST)
        if disc_form.is_valid():
            disc = GenericDiscussion.objects.create(
                subject="Message to campaign organizers: %s" % disc_form.cleaned_data['subject'],
                body=disc_form.cleaned_data['body'],
                parent_id=None,
                user=request.user, 
                content_object=challenge,
                is_public=False,
                disallow_replies=True,
                reply_count=0,
                contact_admin=True,
            )
            messages.success(request, "Your message has been sent to the campaign organizers")
            return redirect(challenge)
    else:
        disc_form = DiscussionCreateForm(request.user)
    return render_to_response("challenges/challenge_disc_contact_admins.html",
                              locals(), 
                              context_instance=RequestContext(request)) 
Exemplo n.º 3
0
def group_contact_admins(request, group_slug):
    group = get_object_or_404(Group, slug=group_slug)
    from discussions.models import Discussion as GenericDiscussion
    from discussions.forms import DiscussionCreateForm as GenericDiscussionCreateForm
    if request.method == "POST":
        disc_form = GenericDiscussionCreateForm(request.user, request.POST)
        if disc_form.is_valid():
            disc = GenericDiscussion.objects.create(
                subject="Message to group leaders: %s" % disc_form.cleaned_data['subject'],
                body=disc_form.cleaned_data['body'],
                parent_id=None,
                user=request.user, 
                content_object=group,
                is_public=False,
                disallow_replies=True,
                reply_count=0,
                contact_admin=True,
            )
            messages.success(request, _("Your message has been sent to the group leaders"))
            return redirect(group)
    else:
        disc_form = GenericDiscussionCreateForm(request.user)
    return render_to_response("groups/group_disc_contact_admins.html",
                              locals(), 
                              context_instance=RequestContext(request)) 
Exemplo n.º 4
0
def challenges_disc_create(request, challenge_id):
    nav_selected = "challenges"
    challenge = get_object_or_404(Challenge, id=challenge_id)

    if not challenge.has_manager_privileges(request.user):
        return forbidden(request, _('You do not have permissions'))
        
    from discussions.models import Discussion as GenericDiscussion
    from discussions.forms import DiscussionCreateForm

    if request.method == "POST":
        disc_form = DiscussionCreateForm(request.user, request.POST)
        if disc_form.is_valid():
            disc = GenericDiscussion.objects.create(
                subject=disc_form.cleaned_data['subject'],
                body=disc_form.cleaned_data['body'],
                parent_id=None,
                user=request.user,
                content_object=challenge,
                reply_count=0,
                is_public=False,
                disallow_replies=True)
            messages.success(request, "Your message has been sent to the campaign's supporters.")
            return redirect(challenge)
    else:
        disc_form = DiscussionCreateForm(request.user)

    return render_to_response("challenges/challenge_disc_create.html", 
                              locals(), 
                              context_instance=RequestContext(request))