Example #1
0
def create_room(request):

    context = {}
    request_context = RequestContext(request, processors=[global_context])

    if request.method == 'POST' and request.user.is_authenticated():
        form = GroupCreationForm(request.POST)
        context['form'] = form

        if form.is_valid():
            group_exists = WatchRoom.objects.filter(
                name__iexact=form.cleaned_data['name']).exists()

            if not group_exists:
                group = WatchRoom()
                group.name = form.cleaned_data['name']
                group.description = form.cleaned_data['description']
                group.created_by = request.user

                group.save()
                context['group'] = group

                context['message'] = "Group created successfully."
                return render_to_response('add_room.html',
                                          context,
                                          context_instance=request_context)

            else:  # group exists
                context['message'] = 'Room name already exists'
                return render_to_response('add_room.html',
                                          context,
                                          context_instance=request_context)

        else:
            context['message'] = "Room name cannot be blank"
            return render_to_response('add_room.html',
                                      context,
                                      context_instance=request_context)

    else:
        form = GroupCreationForm()
        context['form'] = form

        return render_to_response('add_room.html',
                                  context,
                                  context_instance=request_context)
Example #2
0
def create_group(request, user):

    context = {}

    if request.method == 'POST' and request.user.is_authenticated():
        form = GroupCreationForm(request.POST)
        context['form'] = form

        if form.is_valid():
            group_exists = WatchRoom.objects.filter(name=name).exists()

            if not group_exists:
                group = WatchRoom()
                group.name = form.cleaned_data['name']
                group.description = form.cleaned_data['description']
                group.users = 'users'
                created_by = user

                group.save()
                context['group'] = group

                context['valid'] = "Group created successfully."
                return render(request, 'add_group.html', context)

            else:
                context[
                    'message'] = "Sorry, you must be a registered user to create a group."
                return 'failed'

        else:
            context[
                'valid'] = "Group not created. Either you're the idiot or we are."

    else:
        form = GroupCreationForm()
        context['form'] = form

        return render(request, 'add_group.html', context)
Example #3
0
def create_room(request):

    context = {}
    request_context = RequestContext(request, processors=[global_context])

    if request.method == 'POST' and request.user.is_authenticated():
        form = GroupCreationForm(request.POST)
        context['form'] = form

        if form.is_valid():
            group_exists = WatchRoom.objects.filter(name__iexact=form.cleaned_data['name']).exists()

            if not group_exists:
                group = WatchRoom()
                group.name = form.cleaned_data['name']
                group.description = form.cleaned_data['description']
                group.created_by = request.user

                group.save()
                context['group'] = group

                context['message'] = "Group created successfully."
                return render_to_response('add_room.html', context, context_instance=request_context)

            else: # group exists
                context['message'] = 'Room name already exists'
                return render_to_response('add_room.html', context, context_instance=request_context)

        else:
            context['message'] = "Room name cannot be blank"
            return render_to_response('add_room.html', context, context_instance=request_context)

    else:
        form = GroupCreationForm()
        context['form'] = form

        return render_to_response('add_room.html', context, context_instance=request_context)
Example #4
0
def create_group(request, user):

    context = {}

    if request.method == 'POST' and request.user.is_authenticated():
        form = GroupCreationForm(request.POST)
        context['form'] = form

        if form.is_valid():
            group_exists = WatchRoom.objects.filter(name=name).exists()

            if not group_exists:
                group = WatchRoom()
                group.name = form.cleaned_data['name']
                group.description = form.cleaned_data['description']
                group.users = 'users'
                created_by = user

                group.save()
                context['group'] = group

                context['valid'] = "Group created successfully."
                return render(request, 'add_group.html', context)

            else:
                context['message'] = "Sorry, you must be a registered user to create a group."
                return 'failed'
        
        else:
            context['valid'] = "Group not created. Either you're the idiot or we are."

    else:
        form = GroupCreationForm()
        context['form'] = form

        return render(request, 'add_group.html', context)