Ejemplo n.º 1
0
def edit_subgroup(request, group_id, membership_id):
    group = get_object_or_404(Releaser, is_group=True, id=group_id)
    membership = get_object_or_404(Membership, group=group, id=membership_id)
    if request.method == 'POST':
        form = GroupSubgroupForm(request.POST)
        if form.is_valid():
            member = form.cleaned_data['subgroup_nick'].commit().releaser
            if not group.member_memberships.exclude(id=membership_id).filter(
                    member=member).count():
                membership.member = member
                membership.is_current = form.cleaned_data['is_current']
                membership.save()
                group.updated_at = datetime.datetime.now()
                group.save()
                form.log_edit(request.user, member, group)
            return HttpResponseRedirect(group.get_absolute_edit_url() +
                                        "?editing=subgroups")
    else:
        form = GroupSubgroupForm(
            initial={
                'subgroup_nick': membership.member.primary_nick,
                'is_current': membership.is_current,
            })
    return render(request, 'groups/edit_subgroup.html', {
        'group': group,
        'membership': membership,
        'form': form,
    })
Ejemplo n.º 2
0
def edit_subgroup(request, group_id, membership_id):
	group = get_object_or_404(Releaser, is_group=True, id=group_id)
	membership = get_object_or_404(Membership, group=group, id=membership_id)
	if request.method == 'POST':
		form = GroupSubgroupForm(request.POST)
		if form.is_valid():
			member = form.cleaned_data['subgroup_nick'].commit().releaser
			if not group.member_memberships.exclude(id=membership_id).filter(member=member).count():
				membership.member = member
				membership.is_current = form.cleaned_data['is_current']
				membership.save()
				group.updated_at = datetime.datetime.now()
				group.save()
				form.log_edit(request.user, member, group)
			return HttpResponseRedirect(group.get_absolute_edit_url() + "?editing=subgroups")
	else:
		form = GroupSubgroupForm(initial={
			'subgroup_nick': membership.member.primary_nick,
			'is_current': membership.is_current,
		})
	return render(request, 'groups/edit_subgroup.html', {
		'group': group,
		'membership': membership,
		'form': form,
	})
Ejemplo n.º 3
0
def add_subgroup(request, group_id):
    group = get_object_or_404(Releaser, is_group=True, id=group_id)
    if request.method == 'POST':
        form = GroupSubgroupForm(request.POST)
        if form.is_valid():
            member = form.cleaned_data['subgroup_nick'].commit().releaser
            if not group.member_memberships.filter(member=member).count():
                membership = Membership(
                    member=member,
                    group=group,
                    is_current=form.cleaned_data['is_current'])
                membership.save()
                group.updated_at = datetime.datetime.now()
                group.save()
                description = u"Added %s as a subgroup of %s" % (member.name,
                                                                 group.name)
                Edit.objects.create(action_type='add_subgroup',
                                    focus=member,
                                    focus2=group,
                                    description=description,
                                    user=request.user)
            return HttpResponseRedirect(group.get_absolute_edit_url() +
                                        "?editing=subgroups")
    else:
        form = GroupSubgroupForm()
    return render(request, 'groups/add_subgroup.html', {
        'group': group,
        'form': form,
    })
Ejemplo n.º 4
0
def add_subgroup(request, group_id):
	group = get_object_or_404(Releaser, is_group=True, id=group_id)
	if request.method == 'POST':
		form = GroupSubgroupForm(request.POST)
		if form.is_valid():
			member = form.cleaned_data['subgroup_nick'].commit().releaser
			if not group.member_memberships.filter(member=member).count():
				membership = Membership(
					member=member,
					group=group,
					is_current=form.cleaned_data['is_current'])
				membership.save()
				group.updated_at = datetime.datetime.now()
				group.save()
				description = u"Added %s as a subgroup of %s" % (member.name, group.name)
				Edit.objects.create(action_type='add_subgroup', focus=member, focus2=group,
					description=description, user=request.user)
			return HttpResponseRedirect(group.get_absolute_edit_url() + "?editing=subgroups")
	else:
		form = GroupSubgroupForm()
	return render(request, 'groups/add_subgroup.html', {
		'group': group,
		'form': form,
	})