def report_edit(request, report_id): report = get_object_or_404(Report, id=report_id) if request.method == "POST": src = get_request_paramter(request, 'src') parser = PatchParser(src) parser.parser() title = parser.get_title() desc = parser.get_description() emails = parser.get_email_list() diff = parser.get_diff() if title is None or len(title) == 0: logevent("EDIT: report %s, ERROR: no title specified" % report_id) return HttpResponse('EDIT ERROR: no report title specified') if desc is None or len(desc) == 0: logevent("EDIT: report %s, ERROR: no desc specified" % report_id) return HttpResponse('EDIT ERROR: no report desc specified') if emails is None or len(emails) == 0: logevent("EDIT: report %s, ERROR: no emails specified" % report_id) return HttpResponse('EDIT ERROR: no report emails specified') if diff is None or len(diff) == 0: logevent("EDIT: report %s, ERROR: no diff specified" % report_id) return HttpResponse('EDIT ERROR: no report diff specified') register_module_name(report.file, report.module, parser.get_module_name()) report.title = parser.get_title_full() report.desc = desc report.emails = emails report.module = parser.get_module_name() if report.diff != diff: report.build = 0 report.diff = diff report.status = STATUS_PATCHED report.content = src report.save() logevent("EDIT: report %s, SUCCEED" % report_id, True) return HttpResponse('EDIT SUCCEED') else: context = RequestContext(request) context['report'] = report return render_to_response("report/reportedit.html", context)
def patcheditsave(request, patch_id): src = get_request_paramter(request, 'src') parser = PatchParser(src) parser.parser() if len(parser.get_title()) == 0: logevent("EDIT: patch %s, ERROR: no title specified" % patch_id) return HttpResponse('EDIT ERROR: no patch title specified') if len(parser.get_description()) == 0: logevent("EDIT: patch %s, ERROR: no desc specified" % patch_id) return HttpResponse('EDIT ERROR: no patch desc specified') if len(parser.get_email_list()) == 0: logevent("EDIT: patch %s, ERROR: no emails specified" % patch_id) return HttpResponse('EDIT ERROR: no patch emails specified') if len(parser.get_diff()) == 0: logevent("EDIT: patch %s, ERROR: no diff specified" % patch_id) return HttpResponse('EDIT ERROR: no patch diff specified') patch = Patch.objects.filter(id=patch_id) if len(patch) == 0: logevent("EDIT: patch %s, ERROR: id does not exists") return HttpResponse('EDIT ERROR: patch id %s does not exists' % patch_id) register_module_name(patch[0].file, patch[0].module, parser.get_module_name()) patch[0].title = parser.get_title_full() patch[0].desc = parser.get_description() patch[0].emails = parser.get_email_list() patch[0].module = parser.get_module_name() if patch[0].diff != parser.get_diff(): patch[0].diff = parser.get_diff() patch[0].build = 0 patch[0].status = STATUS_NEW patch[0].content = src patch[0].save() logevent("EDIT: patch %s, SUCCEED" % patch_id, True) return HttpResponse('EDIT SUCCEED')
def patcheditsave(request, patch_id): src = get_request_paramter(request, 'src') parser = PatchParser(src) parser.parser() if len(parser.get_title()) == 0: logevent("EDIT: patch %s, ERROR: no title specified" % patch_id) return HttpResponse('EDIT ERROR: no patch title specified') if len(parser.get_description()) == 0: logevent("EDIT: patch %s, ERROR: no desc specified" % patch_id) return HttpResponse('EDIT ERROR: no patch desc specified') if len(parser.get_email_list()) == 0: logevent("EDIT: patch %s, ERROR: no emails specified" % patch_id) return HttpResponse('EDIT ERROR: no patch emails specified') if len(parser.get_diff()) == 0: logevent("EDIT: patch %s, ERROR: no diff specified" % patch_id) return HttpResponse('EDIT ERROR: no patch diff specified') patch = Patch.objects.filter(id = patch_id) if len(patch) == 0: logevent("EDIT: patch %s, ERROR: id does not exists") return HttpResponse('EDIT ERROR: patch id %s does not exists' % patch_id) register_module_name(patch[0].file, patch[0].module, parser.get_module_name()) patch[0].title = parser.get_title_full() patch[0].desc = parser.get_description() patch[0].emails = parser.get_email_list() patch[0].module = parser.get_module_name() if patch[0].diff != parser.get_diff(): patch[0].diff = parser.get_diff() patch[0].build = 0 patch[0].status = STATUS_NEW patch[0].content = src patch[0].save() logevent("EDIT: patch %s, SUCCEED" % patch_id, True) return HttpResponse('EDIT SUCCEED')