Beispiel #1
0
def private_access_create(request, topic_id):
    topic_private = TopicPrivate.objects.for_create_or_404(topic_id, request.user)
    form = TopicPrivateInviteForm(topic=topic_private.topic, data=request.POST)

    if form.is_valid():
        topic_private_access_pre_create.send(sender=topic_private.__class__,
                                             topic=topic_private.topic,
                                             user=form.cleaned_data['user'])
        form.save()
    else:
        messages.error(request, utils.render_form_errors(form))

    return redirect(request.POST.get('next', topic_private.get_absolute_url()))
Beispiel #2
0
def private_join(request, topic_id):
    # This is for topic creators who left their own topics and want to join again
    topic = get_object_or_404(Topic, pk=topic_id, user=request.user, category_id=settings.ST_TOPIC_PRIVATE_CATEGORY_PK)

    if request.method == 'POST':
        form = TopicPrivateJoinForm(topic=topic, user=request.user, data=request.POST)

        if form.is_valid():
            topic_private_access_pre_create.send(sender=TopicPrivate, topic=topic, user=request.user)
            form.save()

            return redirect(request.POST.get('next', topic.get_absolute_url()))
    else:
        form = TopicPrivateJoinForm()

    return render(request, 'foro/topic_private/private_join.html', {'topic': topic, 'form': form, })