def delete(self, fgroup_uuid): """ Deletes a field group, including the fields it contains """ mif = ManageInputField() gfields = InputField.objects\ .filter(fgroup_uuid=fgroup_uuid) for gfield in gfields: # use the manage input field object delete method mif.delete(gfield.uuid) # now finally delete the fields in this field group gfields = InputField.objects\ .filter(fgroup_uuid=fgroup_uuid)\ .delete() # now delete the field group itself inp_obj = self.get_field_group(fgroup_uuid) if inp_obj is not False: ok = True label = inp_obj.label note = 'Deleted Field Group: "' + label + '" (' + fgroup_uuid + ')' inp_obj.delete() else: ok = False label = fgroup_uuid + ' not found' note = label self.response = {'action': 'delete-input-field-group', 'ok': ok, 'change': {'uuid': fgroup_uuid, 'label': label, 'note': note}} return self.response
def delete(self, fgroup_uuid): """ Deletes a field group, including the fields it contains """ mif = ManageInputField() gfields = InputField.objects\ .filter(fgroup_uuid=fgroup_uuid) for gfield in gfields: # use the manage input field object delete method mif.delete(gfield.uuid) # now finally delete the fields in this field group gfields = InputField.objects\ .filter(fgroup_uuid=fgroup_uuid)\ .delete() # now delete the field group itself inp_obj = self.get_field_group(fgroup_uuid) if inp_obj is not False: ok = True label = inp_obj.label note = 'Deleted Field Group: "' + label + '" (' + fgroup_uuid + ')' inp_obj.delete() else: ok = False label = fgroup_uuid + ' not found' note = label self.response = { 'action': 'delete-input-field-group', 'ok': ok, 'change': { 'uuid': fgroup_uuid, 'label': label, 'note': note } } return self.response
def delete_field(request, field_uuid): """ Delete a field group for a given InputProfile """ mif = ManageInputField() inp_obj = mif.get_field(field_uuid) if inp_obj is not False: if request.method == 'POST': # now check to see if the we have edit permissions proj_inp = ProjectInputs(inp_obj.project_uuid, request) if proj_inp.edit_permitted or request.user.is_superuser: result = mif.delete(field_uuid) json_output = json.dumps(result, indent=4, ensure_ascii=False) return HttpResponse(json_output, content_type='application/json; charset=utf8') else: json_output = json.dumps({'error': 'edit permission required'}, indent=4, ensure_ascii=False) return HttpResponse(json_output, content_type='application/json; charset=utf8', status=401) else: return HttpResponseForbidden else: raise Http404
def delete_field(request, field_uuid): """ Delete a field group for a given InputProfile """ mif = ManageInputField() inp_obj = mif.get_field(field_uuid) if inp_obj is not False: if request.method == 'POST': # now check to see if the we have edit permissions proj_inp = ProjectInputs(inp_obj.project_uuid, request) if proj_inp.edit_permitted or request.user.is_superuser: result = mif.delete(field_uuid) json_output = json.dumps(result, indent=4, ensure_ascii=False) return HttpResponse( json_output, content_type='application/json; charset=utf8') else: json_output = json.dumps({'error': 'edit permission required'}, indent=4, ensure_ascii=False) return HttpResponse( json_output, content_type='application/json; charset=utf8', status=401) else: return HttpResponseForbidden else: raise Http404