示例#1
0
def system_edit(request, system_name):
    try:
        system = System.objects.get(name=system_name)
    except System.DoesNotExist:
        raise Http404

    no_changes = False

    try:
        NameField.existing_ok_name = system.name
        if request.method == 'POST':
            form = SystemForm(request.POST)

            if form.is_valid():
                if (form.cleaned_data['name'] == system.name and
                        form.cleaned_data['owner_email'] == system.owner_email
                        and form.cleaned_data['operating_system']
                        == system.operating_system
                        and form.cleaned_data['graphics'] == system.graphics
                        and form.cleaned_data['processor'] == system.processor
                        and form.cleaned_data['notes'] == system.notes):

                    no_changes = True
                else:
                    edit = _do_edit(system, form)
                    return render_to_response(
                        'pages/system_edit_submitted.html', {
                            'page': 'edit_ok',
                            'page_title': "Edit Submitted",
                            'settings': settings,
                            'system': system
                        })
        else:
            form = SystemForm({
                'name': system.name,
                'owner_email': system.owner_email,
                'operating_system': system.operating_system,
                'graphics': system.graphics,
                'processor': system.processor,
                'notes': system.notes
            })

        return render_to_response(
            'pages/system_edit.html', {
                'page': 'edit',
                'page_title': "Edit System",
                'settings': settings,
                'no_changes': no_changes,
                'form': form,
                'form_action': 'system/%d/edit' % system.id,
                'form_submit': "Submit",
                'system': system
            })
    finally:
        NameField.existing_ok_name = None
 def show_system_form(self):
     self.timer.stop()
     self.window.close()
     self.window = SystemForm(self.experiment)
     self.window.back.connect(self.show_participant_form)
     self.window.show_task.connect(self.show_task_form)
     self.timer.setTime(self.time_limit_minutes, self.time_limit_seconds)
     self.window.addTimer(self.timer)
     self.timer.hide()
     self.window.show()
示例#3
0
def register(request):
    if request.method == 'POST':
        form = SystemForm(request.POST)
        if form.is_valid():
            edit = _do_register(form)
            return render_to_response(
                'pages/system_registered.html', {
                    'page': 'system_registered',
                    'page_title': "System Registered",
                    'settings': settings,
                    'edit': edit
                })

    else:
        form = SystemForm()
    return render_to_response(
        'pages/register.html', {
            'page': 'register',
            'page_title': "Register",
            'settings': settings,
            'form': form,
            'form_action': 'register',
            'form_submit': "Register"
        })