Пример #1
0
  def exportSerialized(self, request, access_type, page_name=None,
                       params=None, **kwargs):
    """Exports Surveys in JSON format.

    For args see base.View.public().
    """

    survey_logic = params['logic']

    try:
      sur = survey_logic.getFromKeyFieldsOr404(kwargs)
    except out_of_band.Error, error:
      return responses.errorResponse(
          error, request, template=params['error_public'])
Пример #2
0
  def take(self, request, access_type, page_name=None,
           params=None, **kwargs):
    """View for taking a Survey.

    For Args see base.View().public().
    """

    survey_logic = params['logic']

    try:
      entity = survey_logic.getFromKeyFieldsOr404(kwargs)
    except out_of_band.Error, error:
      return responses.errorResponse(
          error, request, template=params['error_public'])
Пример #3
0
  def viewRecord(self, request, access_type, page_name=None,
                 params=None, **kwargs):
    """View that allows the user to see the contents of a single SurveyRecord.

    For params see base.View.public()
    """

    survey_logic = params['logic']
    record_logic = survey_logic.getRecordLogic()

    try:
      survey_entity = survey_logic.getFromKeyFieldsOr404(kwargs)
    except out_of_band.Error, error:
      return responses.errorResponse(
          error, request, template=params['error_public'])
Пример #4
0
  def viewResults(self, request, access_type, page_name=None,
                  params=None, **kwargs):
    """View that lists all SurveyRecords which are of interest to the user.

    For params see base.View.public().
    """

    # TODO: this view could also contain statistics for the Survey

    survey_logic = params['logic']
    record_logic = survey_logic.getRecordLogic()

    try:
      entity = survey_logic.getFromKeyFieldsOr404(kwargs)
    except out_of_band.Error, error:
      return responses.errorResponse(
          error, request, template=params['error_public'])
Пример #5
0
    def exportSerialized(self,
                         request,
                         access_type,
                         page_name=None,
                         params=None,
                         **kwargs):
        """Exports Surveys in JSON format.

    For args see base.View.public().
    """

        survey_logic = params['logic']

        try:
            sur = survey_logic.getFromKeyFieldsOr404(kwargs)
        except out_of_band.Error, error:
            return responses.errorResponse(error,
                                           request,
                                           template=params['error_public'])
Пример #6
0
    def take(self,
             request,
             access_type,
             page_name=None,
             params=None,
             **kwargs):
        """View for taking a Survey.

    For Args see base.View().public().
    """

        survey_logic = params['logic']

        try:
            entity = survey_logic.getFromKeyFieldsOr404(kwargs)
        except out_of_band.Error, error:
            return responses.errorResponse(error,
                                           request,
                                           template=params['error_public'])
Пример #7
0
  def getContextEntity(self, request, page_name, params, kwargs):
    context = responses.getUniversalContext(request)
    responses.useJavaScript(context, params['js_uses_all'])
    context['page_name'] = page_name
    entity = None

    # TODO(ajaksu): there has to be a better way in this universe to get these
    kwargs['prefix'] = 'program'
    kwargs['link_id'] = request.path.split('/')[-1]
    kwargs['scope_path'] = '/'.join(request.path.split('/')[4:-1])

    entity = survey_logic.getFromKeyFieldsOr404(kwargs)

    if not self._public(request, entity, context):
      error = out_of_band.Error('')
      error = responses.errorResponse(
          error, request, template=params['error_public'], context=context)
      return error, None

    return entity, context
Пример #8
0
    def viewRecord(self,
                   request,
                   access_type,
                   page_name=None,
                   params=None,
                   **kwargs):
        """View that allows the user to see the contents of a single SurveyRecord.

    For params see base.View.public()
    """

        survey_logic = params['logic']
        record_logic = survey_logic.getRecordLogic()

        try:
            survey_entity = survey_logic.getFromKeyFieldsOr404(kwargs)
        except out_of_band.Error, error:
            return responses.errorResponse(error,
                                           request,
                                           template=params['error_public'])
Пример #9
0
    def viewResults(self,
                    request,
                    access_type,
                    page_name=None,
                    params=None,
                    **kwargs):
        """View that lists all SurveyRecords which are of interest to the user.

    For params see base.View.public().
    """

        # TODO: this view could also contain statistics for the Survey

        survey_logic = params['logic']
        record_logic = survey_logic.getRecordLogic()

        try:
            entity = survey_logic.getFromKeyFieldsOr404(kwargs)
        except out_of_band.Error, error:
            return responses.errorResponse(error,
                                           request,
                                           template=params['error_public'])