예제 #1
0
    def create_single_event(cls, form, creator):
        """Creates a non-recurring Mongoengine and Google Calendar event from
        form data.

        :param form: The WTForms form.
        :type form: :class:`CreateEventForm` or a subclass.
        :param creator: The user that is currently logged in.
        :type creator: :class:`~app.models.User`

        :raises: :class:`GoogleCalendarAPIError` and it's subclasses

        :returns: Response from the Google Calendar API.
        :rtype: dict
        """

        # Generate the event and date data
        event_and_date_data = DataBuilder.event_and_date_data_from_form(
            form, creator=creator)
        event_and_date_data = cls._remove_none_fields(event_and_date_data)

        event = Event(**event_and_date_data)
        event.save()

        # Return the Google Calendar response
        return e.gcal_client().create_event(event)
예제 #2
0
파일: events.py 프로젝트: alanhdu/eventum
    def create_single_event(cls, form, creator):
        """Creates a non-recurring Mongoengine and Google Calendar event from
        form data.

        :param form: The WTForms form.
        :type form: :class:`CreateEventForm` or a subclass.
        :param creator: The user that is currently logged in.
        :type creator: :class:`~app.models.User`

        :raises: :class:`GoogleCalendarAPIError` and it's subclasses

        :returns: Response from the Google Calendar API.
        :rtype: dict
        """

        # Generate the event and date data
        event_and_date_data = DataBuilder.event_and_date_data_from_form(
            form,
            creator=creator
        )
        event_and_date_data = cls._remove_none_fields(event_and_date_data)

        event = Event(**event_and_date_data)
        event.save()

        # Return the Google Calendar response
        return e.gcal_client().create_event(event)
예제 #3
0
    def _make_event(cls, e_data, d_data):
        """Create a new :class:`Event` object and save it to Mongoengine.

        The event is created by unpacking non-None fields of ``e_data`` and
        ``d_data`` in the constructor for :class:`Event`.

        :param dict e_data: The event data for this event.
        :param dict d_data: The date data for this event.
        """
        params = cls._remove_none_fields(dict(e_data.items() + d_data.items()))
        event = Event(**params)
        event.save()
        return event
예제 #4
0
파일: events.py 프로젝트: alanhdu/eventum
    def _make_event(cls, e_data, d_data):
        """Create a new :class:`Event` object and save it to Mongoengine.

        The event is created by unpacking non-None fields of ``e_data`` and
        ``d_data`` in the constructor for :class:`Event`.

        :param dict e_data: The event data for this event.
        :param dict d_data: The date data for this event.
        """
        params = cls._remove_none_fields(dict(e_data.items() + d_data.items()))
        event = Event(**params)
        event.save()
        return event