Пример #1
0
def edit_req(request):
    id = request.REQUEST['id'].strip()
    object = IdentityProvider.objects.get(id=id)

    if request.POST:
        form = IDPForm(request.POST)

        if form.is_valid():
            object.source_id = form.clean_data['source_id']
            object.name = form.clean_data['name']
            object.domain = form.clean_data['domain']
            object.logouturl = form.clean_data['logouturl']
            object.website = form.clean_data['website']
            object.format = form.clean_data['format']

            object.save()

            if 'logo' in request.FILES:
                update_logo(object.id, request.FILES['logo'])

            return submit_redirect(request, object)
    else:
        form = IDPForm(initial=object.__dict__)

    return render_to_response(
        'idps/edit.html', default_context(request, form=form, object=object))
Пример #2
0
def add_req(request):
    if request.POST:
        request.POST.update(request.FILES)

        form = IDPForm(request.POST)

        if form.is_valid():

            object = IdentityProvider()
            object.source_id = form.clean_data['source_id']
            object.name = form.clean_data['name']
            object.domain = form.clean_data['domain']
            object.logouturl = form.clean_data['logouturl']
            object.website = form.clean_data['website']
            object.format = form.clean_data['format']

            object.save()

            if 'logo' in request.FILES:
                update_logo(object.id, request.FILES['logo'])

            return submit_redirect(request, object)
    else:
        form = IDPForm()

    return render_to_response('idps/add.html',
                              default_context(request, form=form))
Пример #3
0
def edit_req(request):
    id = int(request.REQUEST['id'].strip())

    group = Group.objects.get(groupinstanceid = id)

    if request.POST:
	form = EditForm(request.POST)

	if form.is_valid():
	    group.name = form.clean_data['name']
	    group.adminUrl = form.clean_data['adminUrl']
	    group.memberUrl = form.clean_data['memberUrl']
	    group.worklist_limit = form.clean_data['worklist_limit']
	    group.save()

	    return submit_redirect(request, group,
				   create_redirect='wiz_create',
				   edit_redirect='edit?id=%(groupinstanceid)d')
    else:
	form = EditForm(initial = group.__dict__)

    return render_to_response('groups/edit.html',
			      default_context(request,
				              group=group,
				              form=form))
Пример #4
0
def create_req(request):
    """Form for registering a new user.
    """
    if request.POST:
        form = CreateForm(request.POST)
    else:
        form = CreateForm()

    if form.is_valid():
        if form.clean_data['pw1'] != form.clean_data['pw2']:
            form.errors['pw2'] = ["Must match password above"]
        else:
            try:
                user = User.objects.create_user(form.clean_data['username'],
                                                form.clean_data['email'],
                                                form.clean_data['pw1'])
            except:
                form.errors['username'] = ["Username already exists"]
            else:
                user.first_name = form.clean_data['first_name']
                user.last_name = form.clean_data['last_name']
                user.is_staff = True
                user.save()

                return submit_redirect(request, user,
                                       edit_redirect = 'edit?id=%(id)s')

    return render_to_response('admins/create.html',
			      default_context(request, form=form))
Пример #5
0
def edit_req(request):
    id = request.REQUEST['id'].strip()
    object = IdentityProvider.objects.get(id=id)
    
    if request.POST:
        form = IDPForm(request.POST)

        if form.is_valid():
            object.source_id = form.clean_data['source_id']
            object.name = form.clean_data['name']
            object.domain = form.clean_data['domain']
            object.logouturl = form.clean_data['logouturl']
            object.website = form.clean_data['website']
            object.format = form.clean_data['format']

            object.save()

            if 'logo' in request.FILES:
                update_logo(object.id, request.FILES['logo'])

            return submit_redirect(request, object)
    else:
        form = IDPForm(initial = object.__dict__)

    return render_to_response('idps/edit.html',
                              default_context(request, form=form,
                                              object=object))
Пример #6
0
def add_req(request):
    if request.POST:
        request.POST.update(request.FILES)

        form = IDPForm(request.POST)

        if form.is_valid():

            object = IdentityProvider()
            object.source_id = form.clean_data['source_id']
            object.name = form.clean_data['name']
            object.domain = form.clean_data['domain']
            object.logouturl = form.clean_data['logouturl']
            object.website = form.clean_data['website']
            object.format = form.clean_data['format']

            object.save()

            if 'logo' in request.FILES:
                update_logo(object.id, request.FILES['logo'])

            return submit_redirect(request, object)
    else:
        form = IDPForm()

    return render_to_response('idps/add.html',
                              default_context(request, form=form))
Пример #7
0
def create_req(request):
    """Form for registering a new user.
    """
    if request.POST:
        mcid = normalize_mcid(request.POST['mcid'])

        form = CreateForm(request.POST)

        if form.is_valid():
            object = User()
            object.mcid = mcid
            object.updatetime = 0
            object.ccrlogupdatetime = 0
            object.acctype = 'SPONSORED'

            object.first_name = form.clean_data['first_name']
            object.last_name = form.clean_data['last_name']
            object.enable_simtrak = False
            object.enable_dod = False
            object.save()

            return submit_redirect(request,
                                   object,
                                   save_redirect='user?mcid=%(mcid)s',
                                   edit_redirect='edit?mcid=%(mcid)s')
    else:
        mcid = mcid_generator.next_mcid_str()
        form = CreateForm()

    return render_to_response('users/create.html',
                              default_context(request, form=form, mcid=mcid))
Пример #8
0
def addgroup_req(request):
    mcid = normalize_mcid(request.REQUEST['mcid'])
    user = User.objects.get(mcid=mcid)

    if request.POST:
        form = GroupForm(request.POST)

        if form.is_valid():
            g = create_group(form.clean_data['name'],
                             normalize_mcid(form.clean_data['accid']),
                             'https://' + request.META['SERVER_NAME'])

            g.save()

            return submit_redirect(
                request,
                g,
                create_redirect='addgroup?mcid=%s' % mcid,
                edit_redirect='../groups/edit?id=%(groupinstanceid)s',
                save_redirect='groups?mcid=%s' % mcid)

    else:
        form = GroupForm(initial=dict(accid=pretty_mcid(mcid)))

    return render_to_response('users/addgroup.html',
                              default_context(request, mcuser=user, form=form))
Пример #9
0
def addgroup_req(request):
    mcid = normalize_mcid(request.REQUEST["mcid"])
    user = User.objects.get(mcid=mcid)

    if request.POST:
        form = GroupForm(request.POST)

        if form.is_valid():
            g = create_group(
                form.clean_data["name"],
                normalize_mcid(form.clean_data["accid"]),
                "https://" + request.META["SERVER_NAME"],
            )

            g.save()

            return submit_redirect(
                request,
                g,
                create_redirect="addgroup?mcid=%s" % mcid,
                edit_redirect="../groups/edit?id=%(groupinstanceid)s",
                save_redirect="groups?mcid=%s" % mcid,
            )

    else:
        form = GroupForm(initial=dict(accid=pretty_mcid(mcid)))

    return render_to_response("users/addgroup.html", default_context(request, mcuser=user, form=form))
Пример #10
0
def create_req(request):
    """Form for registering a new user.
    """
    if request.POST:
        mcid = normalize_mcid(request.POST["mcid"])

        form = CreateForm(request.POST)

        if form.is_valid():
            object = User()
            object.mcid = mcid
            object.updatetime = 0
            object.ccrlogupdatetime = 0
            object.acctype = "SPONSORED"

            object.first_name = form.clean_data["first_name"]
            object.last_name = form.clean_data["last_name"]
            object.enable_simtrak = False
            object.enable_dod = False
            object.save()

            return submit_redirect(
                request, object, save_redirect="user?mcid=%(mcid)s", edit_redirect="edit?mcid=%(mcid)s"
            )
    else:
        mcid = mcid_generator.next_mcid_str()
        form = CreateForm()

    return render_to_response("users/create.html", default_context(request, form=form, mcid=mcid))
Пример #11
0
def edit_req(request):
    mcid = normalize_mcid(request.REQUEST["mcid"])
    user = User.objects.get(mcid=mcid)

    if request.POST:
        form = UserForm(request.POST)

        if form.is_valid() and save_user(user, form):
            return submit_redirect(request, user, edit_redirect="edit?mcid=%(mcid)s")
    else:
        form = UserForm(initial=user.__dict__)

    return render_to_response("users/edit.html", default_context(request, form=form, mcuser=user))
Пример #12
0
def edit_req(request):
    mcid = normalize_mcid(request.REQUEST['mcid'])
    user = User.objects.get(mcid=mcid)

    if request.POST:
        form = UserForm(request.POST)

        if form.is_valid() and save_user(user, form):
            return submit_redirect(request,
                                   user,
                                   edit_redirect='edit?mcid=%(mcid)s')
    else:
        form = UserForm(initial=user.__dict__)

    return render_to_response('users/edit.html',
                              default_context(request, form=form, mcuser=user))
Пример #13
0
def edit_req(request):
    id = int(request.REQUEST['id'].strip())

    object = Appliance.objects.get(id = id)

    if request.POST:
        form = ApplianceForm(request.POST)

        if form.is_valid():
            # object.name = form.clean_data['name']
            object.url = form.clean_data['url']
            object.email = form.clean_data['email']
            object.appliance_type = form.clean_data['appliance_type']

            object.save()

            return submit_redirect(request, object)
    else:
        form = ApplianceForm(initial = object.__dict__)

    return render_to_response('appliances/edit.html',
                              default_context(request, form=form,
                                              object=object))
Пример #14
0
def edit_req(request):
    id = request.REQUEST['id']
    object = User.objects.get(id = id)

    if request.POST:
        form = EditForm(request.POST)

        if not form.is_valid():
            pass
        elif form.clean_data['pw1'] != form.clean_data['pw2']:
            form.errors['pw2'] = ['Must match password above']
        else:

            object.username = form.clean_data['username']
            object.is_staff = True
            object.is_active = form.clean_data['is_active']
            object.first_name = form.clean_data['first_name']
            object.last_name = form.clean_data['last_name']
            object.email = form.clean_data['email']
            
            if form.clean_data['pw1']:
                object.set_password(form.clean_data['pw1'])

            try:
                object.save()
            except:
                form.errors['username'] = ['Username already exists']
            else:
                return submit_redirect(request, object,
                                       edit_redirect = 'edit?id=%(id)s')

    else:
        form = EditForm(initial = object.__dict__)

    return render_to_response('admins/edit.html',
			      default_context(request, form=form,
					      object=object))
Пример #15
0
def edit_req(request):
    id = int(request.REQUEST['id'].strip())

    group = Group.objects.get(groupinstanceid=id)

    if request.POST:
        form = EditForm(request.POST)

        if form.is_valid():
            group.name = form.clean_data['name']
            group.adminUrl = form.clean_data['adminUrl']
            group.memberUrl = form.clean_data['memberUrl']
            group.worklist_limit = form.clean_data['worklist_limit']
            group.save()

            return submit_redirect(request,
                                   group,
                                   create_redirect='wiz_create',
                                   edit_redirect='edit?id=%(groupinstanceid)d')
    else:
        form = EditForm(initial=group.__dict__)

    return render_to_response('groups/edit.html',
                              default_context(request, group=group, form=form))