コード例 #1
0
    def submitFormsPost(self, request, params, context, entity):
        form = request.POST.get('form')

        if not (request.file_uploads and form):
            # no file uploaded
            logging.error("No file_uploads valid form value")
            return http.HttpResponseRedirect(
                gci_redirects.getSubmitFormsRedirect(entity, params))

        # TODO(SRabbelier): handle multiple file uploads
        upload = request.file_uploads[0]

        if form == 'consent':
            entity.consent_form = upload
        elif form == 'consent_two':
            entity.consent_form_two = upload
        elif form == 'student_id':
            entity.student_id_form = upload
        else:
            logging.warning("Invalid value for form '%s'" % form)

        entity.put()

        return http.HttpResponseRedirect(
            gci_redirects.getSubmitFormsRedirect(entity, params))
コード例 #2
0
ファイル: student.py プロジェクト: SRabbelier/Melange
    def submitFormsGet(self, request, params, template, context, entity):
        if lists.isJsonRequest(request):
            url = blobstore.create_upload_url(gci_redirects.getSubmitFormsRedirect(entity, params))
            return responses.jsonResponse(request, url)

        def setForm(param_name, blob_info):
            add_form, edit_form = params[param_name]

            if blob_info:
                form = edit_form(
                    initial={
                        "name": '<a href="%(url)s">%(name)s</a>'
                        % {
                            "name": blob_info.filename,
                            "url": redirects.getDownloadBlobRedirectWithGet(
                                blob_info, params, scope_path=entity.key().id_or_name(), type=param_name
                            ),
                        },
                        "size": defaultfilters.filesizeformat(blob_info.size),
                        "uploaded": blob_info.creation.strftime(self.DATETIME_FORMAT),
                    }
                )
            else:
                form = add_form()

            context[param_name] = form

        setForm("consent_form_upload_form", entity.consent_form)
        setForm("consent_form_two_upload_form", entity.consent_form_two)
        setForm("student_id_form_upload_form", entity.student_id_form)

        return responses.respond(request, template, context)
コード例 #3
0
ファイル: student.py プロジェクト: SRabbelier/Melange
    def submitFormsPost(self, request, params, context, entity):
        form = request.POST.get("form")

        if not (request.file_uploads and form):
            # no file uploaded
            logging.error("No file_uploads valid form value")
            return http.HttpResponseRedirect(gci_redirects.getSubmitFormsRedirect(entity, params))

        # TODO(SRabbelier): handle multiple file uploads
        upload = request.file_uploads[0]

        if form == "consent":
            entity.consent_form = upload
        elif form == "consent_two":
            entity.consent_form_two = upload
        elif form == "student_id":
            entity.student_id_form = upload
        else:
            logging.warning("Invalid value for form '%s'" % form)

        entity.put()

        return http.HttpResponseRedirect(gci_redirects.getSubmitFormsRedirect(entity, params))
コード例 #4
0
    def _getStudentEntries(self, gci_program_entity, student_entity, params,
                           id, user, prefix):
        """Returns a list with menu items for students in a specific program.
    """

        items = []

        timeline_entity = gci_program_entity.timeline

        # this check is done because of the GCI student registration
        # specification mentioned in previous method, a user can have
        # a task and hence task listed without being a student
        if student_entity:
            items += super(View,
                           self)._getStudentEntries(gci_program_entity,
                                                    student_entity, params, id,
                                                    user, prefix)
            if timeline_helper.isActivePeriod(timeline_entity, 'program'):
                items += [(gci_redirects.getSubmitFormsRedirect(
                    student_entity, {'url_name': 'gci/student'}),
                           "Submit Forms", 'any_access')]
        else:
            # add a sidebar entry for the user to register as student if not
            # since he has completed one task
            filter = {
                'user': user,
                'program': gci_program_entity,
                'status': 'AwaitingRegistration'
            }
            if gci_task_logic.logic.getForFields(filter, unique=True):
                if timeline_helper.isActivePeriod(timeline_entity,
                                                  'student_signup'):
                    # this user does not have a role yet for this program
                    items += [(redirects.getStudentApplyRedirect(
                        gci_program_entity, {'url_name': 'gci/student'}),
                               "Register as a Student", 'any_access')]

        return items
コード例 #5
0
    def submitFormsGet(self, request, params, template, context, entity):
        if lists.isJsonRequest(request):
            url = blobstore.create_upload_url(
                gci_redirects.getSubmitFormsRedirect(entity, params))
            return responses.jsonResponse(request, url)

        def setForm(param_name, blob_info):
            add_form, edit_form = params[param_name]

            if blob_info:
                form = edit_form(
                    initial={
                        'name':
                        '<a href="%(url)s">%(name)s</a>' % {
                            'name':
                            blob_info.filename,
                            'url':
                            redirects.getDownloadBlobRedirectWithGet(
                                blob_info,
                                params,
                                scope_path=entity.key().id_or_name(),
                                type=param_name)
                        },
                        'size':
                        defaultfilters.filesizeformat(blob_info.size),
                        'uploaded':
                        blob_info.creation.strftime(self.DATETIME_FORMAT),
                    })
            else:
                form = add_form()

            context[param_name] = form

        setForm('consent_form_upload_form', entity.consent_form)
        setForm('consent_form_two_upload_form', entity.consent_form_two)
        setForm('student_id_form_upload_form', entity.student_id_form)

        return responses.respond(request, template, context)
コード例 #6
0
ファイル: program.py プロジェクト: SRabbelier/Melange
  def _getStudentEntries(self, gci_program_entity, student_entity,
                         params, id, user, prefix):
    """Returns a list with menu items for students in a specific program.
    """

    items = []

    timeline_entity = gci_program_entity.timeline

    # this check is done because of the GCI student registration
    # specification mentioned in previous method, a user can have
    # a task and hence task listed without being a student
    if student_entity:
      items += super(View, self)._getStudentEntries(
          gci_program_entity, student_entity, params, id, user, prefix)
      if timeline_helper.isActivePeriod(timeline_entity, 'program'):
        items += [
            (gci_redirects.getSubmitFormsRedirect(
                student_entity, {'url_name': 'gci/student'}),
             "Submit Forms", 'any_access')
        ]
    else:
      # add a sidebar entry for the user to register as student if not
      # since he has completed one task
      filter = {
          'user': user,
          'program': gci_program_entity,
          'status': 'AwaitingRegistration'
          }
      if gci_task_logic.logic.getForFields(filter, unique=True):
        if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'):
          # this user does not have a role yet for this program
          items += [(redirects.getStudentApplyRedirect(
              gci_program_entity, {'url_name': 'gci/student'}),
              "Register as a Student", 'any_access')]

    return items