Ejemplo n.º 1
0
    def _copySessionToForm(self, sess):
        """Copy relevant fields from Session to SessionForm."""

        sf = SessionForm()
        for field in sf.all_fields():
            if hasattr(sess, field.name):
                if field.name == 'date':
                    sf.date = str(sess.date)
                elif field.name == 'timeStart':
                    sf.timeStart = str(sess.timeStart)
                elif field.name == 'timeEnd':
                    sf.timeEnd = str(sess.timeEnd)
                elif field.name == 'duration':
                    sf.timeEnd = str(sess.timeEnd)
                elif field.name == 'typeOfSession':
                    try:
                        setattr(
                            sf, field.name,
                            getattr(SessionType, getattr(sess, field.name)))
                    except AttributeError:
                        setattr(sf, field.name,
                                getattr(SessionType, 'NOT_SPECIFIED'))
                else:
                    setattr(sf, field.name, getattr(sess, field.name))
        sf.websafeKey = sess.key.urlsafe()
        sf.check_initialized()

        return sf
Ejemplo n.º 2
0
    def _copySessionToForm(self, session):
        """Copies the given Session object to a SessionForm object."""

        sessionForm = SessionForm()

        sessionForm.name = session.name
        sessionForm.speaker = session.speaker
        sessionForm.date = str(session.date)
        sessionForm.startTime = str(session.startTime)
        sessionForm.duration = session.duration
        sessionForm.typeOfSession = session.typeOfSession
        sessionForm.highlights = session.highlights
        sessionForm.websafeKey = session.key.urlsafe()

        return sessionForm
Ejemplo n.º 3
0
 def _copySessionToForm(self, session):
     """Copy fields from Session to SessionForm."""
     session_form = SessionForm()
     for field in session_form.all_fields():
         try:
             if field.name == 'startTime':
                 session_form.startTime = str(session.startTime)
             elif field.name == 'date':
                 session_form.date = str(session.date)
             elif hasattr(session, field.name):
                 setattr(session_form, field.name, getattr(session, field.name))
             elif field.name == "sessionSafeKey":
                 setattr(session_form, field.name, session.key.urlsafe())
         except AttributeError:
             raise endpoints.BadRequestException("Error, check the input fields.")
     session_form.check_initialized()
     return session_form
Ejemplo n.º 4
0
 def _copySessionToForm(self, session):
     """Copy fields from Session to SessionForm."""
     session_form = SessionForm()
     for field in session_form.all_fields():
         try:
             if field.name == 'startTime':
                 session_form.startTime = str(session.startTime)
             elif field.name == 'date':
                 session_form.date = str(session.date)
             elif hasattr(session, field.name):
                 setattr(session_form, field.name,
                         getattr(session, field.name))
             elif field.name == "sessionSafeKey":
                 setattr(session_form, field.name, session.key.urlsafe())
         except AttributeError:
             raise endpoints.BadRequestException(
                 "Error, check the input fields.")
     session_form.check_initialized()
     return session_form
Ejemplo n.º 5
0
    def _copySessionToForm(self, session):
        """Copy relevant fields from Session to SessionForm"""

        # create a new entity first
        sf = SessionForm()

        # convert Session properties to SessionForm fields
        sf.name = session.name
        sf.highlights = session.highlights
        sf.speakerKeys = session.speakerKeys
        sf.duration = session.duration
        sf.typeOfSession = getattr(SessionTypes, session.typeOfSession)
        sf.date = str(session.date)
        sf.startTime = int('%s%s' % (str(session.startTime)[:2], str(session.startTime)[3:5]))
        sf.websafeKey = session.key.urlsafe()

        # check and return
        sf.check_initialized()
        return sf
Ejemplo n.º 6
0
    def _copySessionToForm(self, session):
        """Copy relevant fields from Session to SessionForm"""

        # create a new entity first
        sf = SessionForm()

        # convert Session properties to SessionForm fields
        sf.name = session.name
        sf.highlights = session.highlights
        sf.speakerKeys = session.speakerKeys
        sf.duration = session.duration
        sf.typeOfSession = getattr(SessionTypes, session.typeOfSession)
        sf.date = str(session.date)
        sf.startTime = int(
            '%s%s' % (str(session.startTime)[:2], str(session.startTime)[3:5]))
        sf.websafeKey = session.key.urlsafe()

        # check and return
        sf.check_initialized()
        return sf