@treeio_login_required
@handle_response_format
def report_group(request, report_id, field_name, response_format='html'):
 t = get_object_or_404(Report, pk=report_id)
 if (not request.user.profile.has_permission(t, mode='w')):
  return user_denied(request, message="You don't have access to this Report")
 model = loads(t.model)
 thisfield = model.get_field(field_name)
 if (thisfield.groupby == 1):
  thisfield.groupby = 0
 else:
  for field in model.fields:
   field.groupby = 0
  field = model.get_field(field_name)
  field.groupby = 1
 t.model = dumps(model)
 t.save()
 return report_edit(request, report_id=report_id, response_format=response_format)

@ treeio_login_required @ handle_response_format def report_group ( request , report_id , field_name , response_format = 'html' ) : t = get_object_or_404 ( Report , pk = report_id ) if ( not request . user . profile . has_permission ( t , mode = 'w' ) ) : return user_denied ( request , message = "You don't have access to this Report" ) model = loads ( t . model ) thisfield = model . get_field ( field_name ) if ( thisfield . groupby == 1 ) : thisfield . groupby = 0 else : for field in model . fields : field . groupby = 0 field = model . get_field ( field_name ) field . groupby = 1 t . model = dumps ( model ) t . save ( ) return report_edit ( request , report_id = report_id , response_format = response_format )
view to group by a given field in a report .