Пример #1
0
def post_event():
    global current_event
    global current_user
    current_event = read_event()
    if not current_user:
        add_output("You have to login first to post events. \n")
    else:
        result = EventController.add_event(current_user, current_event)
        if result == Errors.DUPLICATE.name:
            current_event.eid = None
            add_output("The same event already exists. \n")
        elif result == Errors.FAILURE.name:
            current_event.eid = None
            return_failure()
        add_output('Event #' + str(result) + ' has been posted. \n')
        current_event.eid = result

        result = EventController.host_event(current_user, current_event)
        if result == Errors.DUPLICATE.name:
            current_event.eid = None
            add_output("You have already hosted this event. \n")
        elif result == Errors.FAILURE.name:
            current_event.eid = None
            return_failure()
        add_output("You are the host of event " + str(current_event.eid) +
                   " now. \n")
        current_event.hosts = current_user.uid
        current_user.host_events.append(current_event.eid)
        print('User #' + current_event.hosts + ' posted event #' +
              str(current_event.eid) + '. \n')
        EventController.print_event(current_event)
    return
Пример #2
0
    def test_host_event(self):
        UserController.add_user(self.user_1)
        user_2 = UserController.retrieve_user('email', 'email_1')

        event_id = EventController.add_event(self.event_1)
        self.event_1.eventid = event_id

        self.assertIsNotNone(EventController.host_event(user_2, self.event_1))

        UserController.delete_user('nickname_1', 'email_1')
Пример #3
0
def post_event():
    global current_event
    global current_user
    current_event = read_event()
    if not current_user:
        add_output("You have to login first! \n")
    else:
        result = EventController.post_event(current_user, current_event)
        if result == Errors.DUPLICATE.name:
            add_output("A same event already exists! \n")
        elif result == Errors.FAILURE.name:
            return_failure()
        current_event.eid = result
        result = EventController.host_event(current_user, current_event)
        if result == Errors.DUPLICATE.name:
            add_output("A same event already exists! \n")
        elif result == Errors.FAILURE.name:
            return_failure()
    return
Пример #4
0
def post_event(data):
    event = EventModel(0, data['title'], data['tags'], data['description'],
                       data['image'], data['hosts'], [], data['event_date'],
                       data['state'], data['address'], data['register_period'])

    EventController.print_event(event)
    result = EventController.add_event(event)
    if result == Errors.DUPLICATE.name:
        event.eid = None
        return Errors.DUPLICATE.name, None
    elif result == Errors.FAILURE.name:
        event.eid = None
        return Errors.FAILURE.name, None
    print('Event #' + str(result) + ' has been posted. \n')
    event.eid = result

    result = EventController.host_event(event.hosts, event)
    if result == Errors.DUPLICATE.name:
        current_event.eid = None
        print("You have already hosted this event. \n")
        return Errors.DUPLICATE.name
    elif result == Errors.FAILURE.name:
        current_event.eid = None
        return Errors.FAILURE.name

    EventController.print_event(event)
    data = {
        'eid': event.eid,
        'title': event.title,
        'tags': event.tags,
        'description': event.description,
        'hosts': event.hosts,
        'event_date': event.event_date,
        'state': event.location,
        'address': event.address,
        'image': event.image,
        'register_period': event.register_period,
        'expire_date': event.expire_date
    }
    return 'OK', data