def details_department(request, department_id): department = DepartmentService.find_one(department_id) subjects = department.asignatura_set.all() template_name = "department/details.html" template_data = {"department": department, "subjects": subjects} return render_to_response(template_name, template_data, context_instance=RequestContext(request))
def details_department(request, department_id): department = DepartmentService.find_one(department_id) subjects = department.asignatura_set.all() template_name = 'department/details.html' template_data = {'department': department, 'subjects': subjects} return render_to_response(template_name, template_data, context_instance=RequestContext(request))
def edit_department(request, department_id): data_form = {} data_template = {} if request.POST: form = DepartmentEditForm(request.POST) try: if department_id: assert department_id == form.cleaned_data['id'] except AssertionError: messages.error(request, _("Action failed, try again!")) return HttpResponseRedirect('/admin/department/lis') if form.is_valid(): department = DepartmentService.reconstruct_and_save(form) messages.success(request, _("Action completed successfully")) redirect = '/admin/department/details/' + str(department.id) return HttpResponseRedirect(redirect) else: if department_id: department = DepartmentService.find_one(department_id) data_form = DepartmentService.get_form_data(department) form = DepartmentEditForm(initial=data_form) if department_id: data_template['create'] = False data_template['cancel'] = '/admin/department/details/' + str( department_id) else: data_template['create'] = True data_template['form'] = form data_template['action'] = '/admin/department/edit/' template_name = 'department/edit.html' return render_to_response(template_name, data_template, context_instance=RequestContext(request))
def edit_department(request, department_id): data_form = {} data_template = {} if request.POST: form = DepartmentEditForm(request.POST) try: if department_id: assert department_id == form.cleaned_data["id"] except AssertionError: messages.error(request, _("Action failed, try again!")) return HttpResponseRedirect("/admin/department/lis") if form.is_valid(): department = DepartmentService.reconstruct_and_save(form) messages.success(request, _("Action completed successfully")) redirect = "/admin/department/details/" + str(department.id) return HttpResponseRedirect(redirect) else: if department_id: department = DepartmentService.find_one(department_id) data_form = DepartmentService.get_form_data(department) form = DepartmentEditForm(initial=data_form) if department_id: data_template["create"] = False data_template["cancel"] = "/admin/department/details/" + str(department_id) else: data_template["create"] = True data_template["form"] = form data_template["action"] = "/admin/department/edit/" template_name = "department/edit.html" return render_to_response(template_name, data_template, context_instance=RequestContext(request))