def _showEditRecordList(self, request, params, page_name, **kwargs): """Returns a list containing GradingRecords that can be edited. For args see base.View.public(). """ survey_group_logic = params['logic'] record_logic = survey_group_logic.getRecordLogic() try: survey_group = survey_group_logic.getFromKeyFieldsOr404(kwargs) except out_of_band.Error, error: return responses.errorResponse( error, request, template=params['error_public'])
def viewRecords(self, request, access_type, page_name=None, params=None, **kwargs): """View which shows all collected records for a given GradingSurveyGroup. For args see base.View.public(). """ from google.appengine.api.labs import taskqueue from soc.logic import lists as lists_logic survey_group_logic = params['logic'] record_logic = survey_group_logic.getRecordLogic() try: entity = survey_group_logic.getFromKeyFieldsOr404(kwargs) except out_of_band.Error, error: return responses.errorResponse( error, request, template=params['error_public'])
def editRecord(self, request, access_type, page_name=None, params=None, **kwargs): """View in which a GradingRecord can be edited. For args see base.View.public(). """ survey_group_logic = params['logic'] record_logic = survey_group_logic.getRecordLogic() get_dict = request.GET record_id = get_dict.get('id') if not (record_id and record_id.isdigit()): # no valid record_id specified showing the list of GradingRecords return self._showEditRecordList(request, params, page_name, **kwargs) # retrieve the wanted GradingRecord try: record_entity = record_logic.getFromIDOr404(int(record_id)) except out_of_band.Error, error: return responses.errorResponse( error, request, template=params['error_public'])
def __init__(self, params=None): """Defines the fields and methods required for the base View class to provide the user with list, public, create, edit and delete views. Params: params: a dict with params for this View """ rights = access.Checker(params) rights['create'] = ['checkIsHostForProgramInScope'] rights['edit'] = ['checkIsHostForProgramInScope'] rights['delete'] = ['checkIsDeveloper'] rights['show'] = ['checkIsHostForProgramInScope'] rights['list'] = ['checkIsDeveloper'] rights['records'] = ['checkIsHostForProgramInScope'] rights['edit_record'] = ['checkIsHostForProgramInScope'] new_params = {} new_params['logic'] = survey_group_logic new_params['rights'] = rights new_params['name'] = "Grading Survey Group" new_params['sidebar_grouping'] = "Surveys" new_params['scope_view'] = program_view new_params['scope_redirect'] = redirects.getCreateRedirect new_params['no_admin'] = True new_params['no_create_with_key_fields'] = True new_params['create_extra_dynaproperties'] = { 'grading_survey': djangoforms.ModelChoiceField( GradingProjectSurvey, required=True), 'student_survey': djangoforms.ModelChoiceField(ProjectSurvey, required=False), } new_params['extra_dynaexclude'] = ['link_id', 'scope', 'scope_path', 'last_update_started', 'last_update_complete'] new_params['edit_extra_dynaproperties'] = { 'link_id': forms.CharField(widget=forms.HiddenInput), } patterns = [ (r'^%(url_name)s/(?P<access_type>records)/%(key_fields)s$', 'soc.views.models.%(module_name)s.view_records', 'Overview of GradingRecords'), (r'^%(url_name)s/(?P<access_type>edit_record)/%(key_fields)s$', 'soc.views.models.%(module_name)s.edit_record', 'Edit a GradingRecord'), ] new_params['extra_django_patterns'] = patterns new_params['view_records_template'] = 'soc/grading_survey_group/records.html' new_params['records_heading_template'] = 'soc/grading_record/list/heading.html' new_params['records_row_template'] = 'soc/grading_record/list/row.html' new_params['record_edit_template'] = 'soc/grading_record/edit.html' # create the form that will be used to edit a GradingRecord record_logic = survey_group_logic.getRecordLogic() record_edit_form = dynaform.newDynaForm( dynabase=soc.views.helper.forms.BaseForm, dynamodel=record_logic.getModel(), dynaexclude=['grading_survey_group', 'mentor_record', 'student_record', 'project'], ) new_params['record_edit_form'] = record_edit_form params = dicts.merge(params, new_params) super(View, self).__init__(params=params)