Beispiel #1
0
def create_req(request):
    if 'create' in request.POST:
        properties = get_properties()
        if 'Site' in properties:
            url_root = properties['Site']
        else:
            url_root = request.META['SERVER_NAME']

        create_data(url_root)

    return HttpResponseRedirect('.')
Beispiel #2
0
def create_req(request):
	if 'create' in request.POST:
		properties = get_properties()
		if 'Site' in properties:
			url_root = properties['Site']
		else:
			url_root = request.META['SERVER_NAME']

		create_data(url_root)

	return HttpResponseRedirect('.')
Beispiel #3
0
def delete_data():
	properties = get_properties()

	delete_user(properties['DemoDoctor'])

	for first_name, last_name, email, ccr, reason, ccrs in PATIENTS:
		users = User.objects.filter(first_name = first_name,
					    last_name = last_name,
					    email = email)

		for user in users:
			delete_user(user.mcid)

	sql_execute("DELETE FROM mcproperties WHERE property='acDemoDoctor'")
Beispiel #4
0
def delete_data():
    properties = get_properties()

    delete_user(properties['DemoDoctor'])

    for first_name, last_name, email, ccr, reason, ccrs in PATIENTS:
        users = User.objects.filter(first_name=first_name,
                                    last_name=last_name,
                                    email=email)

        for user in users:
            delete_user(user.mcid)

    sql_execute("DELETE FROM mcproperties WHERE property='acDemoDoctor'")
Beispiel #5
0
def index_req(request):
	properties = get_properties()

	context = default_context(request)

	if 'DemoDoctor' in properties:
		patients = []
		for first_name, last_name, email, ccr, reason, ccrs in PATIENTS:
			patients += User.objects.filter(first_name = first_name,
							last_name = last_name,
							email = email)

		context['mcid'] = properties['DemoDoctor']
		context['doctor'] = User.objects.get(mcid = context['mcid'])
		context['patients'] = patients

	return render_to_response('demos/index.html', context)
Beispiel #6
0
def index_req(request):
    properties = get_properties()

    context = default_context(request)

    if 'DemoDoctor' in properties:
        patients = []
        for first_name, last_name, email, ccr, reason, ccrs in PATIENTS:
            patients += User.objects.filter(first_name=first_name,
                                            last_name=last_name,
                                            email=email)

        context['mcid'] = properties['DemoDoctor']
        context['doctor'] = User.objects.get(mcid=context['mcid'])
        context['patients'] = patients

    return render_to_response('demos/index.html', context)
Beispiel #7
0
def createbucket_req(request):
    if request.POST:
        form = CreateBucketForm(request.POST)

        if form.is_valid():
            a = get_properties()
            s3.create_bucket(form.clean_data["bucket_name"], key_id=a["S3Key_ID"], secret=a["S3Secret"])

            if "add" in request.POST:
                url = "createbucket"
            else:
                url = "buckets"

            return HttpResponseRedirect(url)
    else:
        form = CreateBucketForm()

    return render_to_response("backups/createbucket.html", default_context(request, form=form))
Beispiel #8
0
def buckets_req(request):
    a = get_properties()

    if "bucket" in request.GET and request.GET["bucket"]:
        a["S3Bucket"] = request.GET["bucket"]

    result = s3.list_all_my_buckets(key_id=a["S3Key_ID"], secret=a["S3Secret"])

    buckets = result.Buckets.Bucket
    if not isinstance(buckets, list):
        buckets = [buckets]

    return wizard(
        request,
        BucketForm,
        "backups/wiz_2buckets.html",
        initial=a,
        prev="keys",
        next="encryption",
        context=dict(buckets=buckets, owner=result.Owner),
    )
Beispiel #9
0
def s3_keys():
    a = get_properties()
    return dict(key_id=a["S3Key_ID"], secret=a["S3Secret"])
Beispiel #10
0
def password_req(request):
    mcid = normalize_mcid(request.REQUEST['mcid'])

    mcuser = get_object_or_404(User, mcid=mcid)

    decoded_skey = mcuser.enc_skey and mcuser.enc_skey.decode('base64')

    ts = datetime.fromtimestamp(mcuser.ccrlogupdatetime)

    skey_form = None

    if 'skey' in request.POST:
        skey_form = SKeyForm(request.POST)

        if skey_form.is_valid():
            curr = skey.get(skey_form.clean_data['skey'])
            next = skey.step(curr)

            if next == decoded_skey:
                mcuser.email = skey_form.clean_data['email']
                mcuser.set_password(skey_form.clean_data['newpw'])
                mcuser.enc_skey = curr.encode('base64').strip()

                mcuser.save()

                properties = get_properties()
                properties['user'] = mcuser
                properties['newpw'] = skey_form.clean_data['newpw']

                email_user_template(
                    request, mcuser,
                    'Your {{ ApplianceName }} email and password has been reset',
                    'email/new_email.txt', properties)

                return HttpResponseRedirect('user?mcid=' + mcid)

            skey_form.errors.setdefault('skey', []).append('S/Key mismatch')

        pw_form = PasswordForm(initial=dict(newpw=request.POST['newpw']))
    elif 'newpw' in request.POST:
        pw_form = PasswordForm(request.POST)

        if pw_form.is_valid():
            mcuser.set_password(pw_form.clean_data['newpw'])
            mcuser.save()

            properties = get_properties()
            properties['user'] = mcuser
            properties['newpw'] = pw_form.clean_data['newpw']

            email_user_template(
                request, mcuser,
                'Your {{ ApplianceName }} password has been reset',
                'email/new_password.txt', properties)

            return HttpResponseRedirect('user?mcid=' + mcid)

        if decoded_skey:
            skey_form = SKeyForm(
                initial=dict(email=mcuser.email, newpw=request.POST['newpw']))
    else:
        newpw = random_password()
        initial = dict(newpw=newpw, email=mcuser.email)
        pw_form = PasswordForm(initial=initial)

        if decoded_skey:
            skey_form = SKeyForm(initial=initial)

    return render_to_response(
        'users/password.html',
        default_context(request,
                        mcuser=mcuser,
                        ccrlogupdatetime=ts,
                        pw_form=pw_form,
                        skey_form=skey_form))
Beispiel #11
0
def password_req(request):
    mcid = normalize_mcid(request.REQUEST["mcid"])

    mcuser = get_object_or_404(User, mcid=mcid)

    decoded_skey = mcuser.enc_skey and mcuser.enc_skey.decode("base64")

    ts = datetime.fromtimestamp(mcuser.ccrlogupdatetime)

    skey_form = None

    if "skey" in request.POST:
        skey_form = SKeyForm(request.POST)

        if skey_form.is_valid():
            curr = skey.get(skey_form.clean_data["skey"])
            next = skey.step(curr)

            if next == decoded_skey:
                mcuser.email = skey_form.clean_data["email"]
                mcuser.set_password(skey_form.clean_data["newpw"])
                mcuser.enc_skey = curr.encode("base64").strip()

                mcuser.save()

                properties = get_properties()
                properties["user"] = mcuser
                properties["newpw"] = skey_form.clean_data["newpw"]

                email_user_template(
                    request,
                    mcuser,
                    "Your {{ ApplianceName }} email and password has been reset",
                    "email/new_email.txt",
                    properties,
                )

                return HttpResponseRedirect("user?mcid=" + mcid)

            skey_form.errors.setdefault("skey", []).append("S/Key mismatch")

        pw_form = PasswordForm(initial=dict(newpw=request.POST["newpw"]))
    elif "newpw" in request.POST:
        pw_form = PasswordForm(request.POST)

        if pw_form.is_valid():
            mcuser.set_password(pw_form.clean_data["newpw"])
            mcuser.save()

            properties = get_properties()
            properties["user"] = mcuser
            properties["newpw"] = pw_form.clean_data["newpw"]

            email_user_template(
                request,
                mcuser,
                "Your {{ ApplianceName }} password has been reset",
                "email/new_password.txt",
                properties,
            )

            return HttpResponseRedirect("user?mcid=" + mcid)

        if decoded_skey:
            skey_form = SKeyForm(initial=dict(email=mcuser.email, newpw=request.POST["newpw"]))
    else:
        newpw = random_password()
        initial = dict(newpw=newpw, email=mcuser.email)
        pw_form = PasswordForm(initial=initial)

        if decoded_skey:
            skey_form = SKeyForm(initial=initial)

    return render_to_response(
        "users/password.html",
        default_context(request, mcuser=mcuser, ccrlogupdatetime=ts, pw_form=pw_form, skey_form=skey_form),
    )