Exemplo n.º 1
0
    def add_event_role_invite(email, role_name, event_id):
        """
        Save an event role invite to database and return accept and decline links.
        :param email: Email for the invite
        :param role_name: Role name for the invite
        :param event_id: Event id
        """
        role = Role.query.filter_by(name=role_name).first()

        event = Event.query.get(event_id)
        role_invite = RoleInvite(email=email.lower(),
                                 event=event,
                                 role=role,
                                 create_time=datetime.now())

        hash = random.getrandbits(128)
        role_invite.hash = '%032x' % hash

        save_to_db(role_invite, "Role Invite saved")

        accept_link = url_for('events.user_role_invite',
                              event_id=event_id,
                              hash=role_invite.hash)
        decline_link = url_for('events.user_role_invite_decline',
                               event_id=event_id,
                               hash=role_invite.hash)

        return accept_link, decline_link
Exemplo n.º 2
0
    def add_event_role_invite(email, role_name, event_id):
        """
        Save an event role invite to database and return accept and decline links.
        :param email: Email for the invite
        :param role_name: Role name for the invite
        :param event_id: Event id
        """
        role = Role.query.filter_by(name=role_name).first()

        event = Event.query.get(event_id)
        role_invite = RoleInvite(email=email.lower(),
                                 event=event,
                                 role=role,
                                 create_time=datetime.now())

        hash = random.getrandbits(128)
        role_invite.hash = '%032x' % hash

        save_to_db(role_invite, "Role Invite saved")

        accept_link = url_for('events.user_role_invite',
                              event_id=event_id,
                              hash=role_invite.hash)
        decline_link = url_for('events.user_role_invite_decline',
                               event_id=event_id,
                               hash=role_invite.hash)

        return accept_link, decline_link
Exemplo n.º 3
0
    def after_create_object(self, event, data, view_kwargs):
        """
        after create method to save roles for users and add the user as an accepted role(owner and organizer)
        :param event:
        :param data:
        :param view_kwargs:
        :return:
        """
        user = User.query.filter_by(id=view_kwargs['user_id']).first()
        role = Role.query.filter_by(name=OWNER).first()
        uer = UsersEventsRoles(user=user, event=event, role=role)
        save_to_db(uer, 'Event Saved')
        role_invite = RoleInvite(
            email=user.email,
            role_name=role.title_name,
            event=event,
            role=role,
            status='accepted',
        )
        save_to_db(role_invite, 'Owner Role Invite Added')

        # create custom forms for compulsory fields of attendee form.
        create_custom_forms_for_attendees(event)

        if event.state == 'published' and event.schedule_published_on:
            start_export_tasks(event)

        if data.get('original_image_url'):
            start_image_resizing_tasks(event, data['original_image_url'])
Exemplo n.º 4
0
    def after_create_object(self, event, data, view_kwargs):
        """
        after create method to save roles for users and add the user as an accepted role(organizer)
        :param event:
        :param data:
        :param view_kwargs:
        :return:
        """
        role = Role.query.filter_by(name=ORGANIZER).first()
        user = User.query.filter_by(id=view_kwargs['user_id']).first()
        uer = UsersEventsRoles(user, event, role)
        save_to_db(uer, 'Event Saved')
        role_invite = RoleInvite(user.email,
                                 role.title_name,
                                 event.id,
                                 role.id,
                                 datetime.now(pytz.utc),
                                 status='accepted')
        save_to_db(role_invite, 'Organiser Role Invite Added')

        # create custom forms for compulsory fields of attendee form.
        create_custom_forms_for_attendees(event)

        if event.state == 'published' and event.schedule_published_on:
            start_export_tasks(event)