예제 #1
0
def reschedule_event(user_id):
    """
    Call functions to change event date
    """

    choice = None
    temp_event_list = []

    for event in Event.events:
        if event.__class__.__name__ == "PrivateMentoring" and event.user_id == user_id:
            temp_event_list.append(event)

    head = "Chose option:"
    exit_msg = "Exit event reschedule"

    view.print_menu(head, temp_event_list, exit_msg)

    choice = view.get_choice()
    choice = int(choice) - 1

    if choice == -1:
        pass
    elif choice >= len(temp_event_list):
        view.print_msg("No such event!\n")
    else:

        view.print_msg("Enter new event date")
        new_date = view.get_event_date()

        new_date = validate_date(new_date)

        if new_date is not None:
            Event.change_date(temp_event_list[choice], new_date)
예제 #2
0
def cancel_event(user_id):
    """
    Call functions to cancel event

    Examples:
        "st" are two first signs of student id
    """

    choice = None
    temp_event_list = []

    for event in Event.events:
        if event.user_id == user_id or event.user_id[0:2] == "st":
            temp_event_list.append(event)

    head = "Chose option:"
    exit_msg = "Exit event cancelation"

    view.print_menu(head, temp_event_list, exit_msg)
    choice = view.get_choice()
    choice = int(choice) - 1

    if choice == -1:
        pass
    elif choice >= len(temp_event_list):
        view.print_msg("No such event!\n")
    else:
        Event.del_event(temp_event_list[choice])
예제 #3
0
def reschedule_event(user_id):
    """
    Call functions to change event date

    Examples:
        "st" are two first signs of student id
    """

    choice = None
    temp_event_list = []

    for event in Event.events:
        if event.user_id == user_id or event.user_id[0:2] == "st":
            temp_event_list.append(event)

    head = "Chose option:"
    exit_msg = "Exit event reschedule"

    view.print_menu(head, temp_event_list, exit_msg)
    choice = view.get_choice()
    choice = int(choice) - 1

    if choice == -1:
        pass
    elif choice >= len(temp_event_list):
        view.print_msg("No such event!\n")
    else:

        view.print_msg("Enter new event date")
        new_date = view.get_event_date()

        new_date = validate_date(new_date)

        if new_date is not None:
            Event.change_date(temp_event_list[choice], new_date)
예제 #4
0
    def __init__(self, date, user_id):
        """
        Construct Checkpoint object

        Args:
            date (:obj: `date`): date of checkpoint
        """

        super().__init__(date)
        self.user_id = user_id

        Event.add_event(self)
예제 #5
0
def index_events():
    events = Event.select()
    event_list = []
    for event in events:
        event = model_to_dict(event)
        event_list.append(event)
    return jsonify(event_list)
예제 #6
0
def delete(id):
    event = Event.get_or_none(Event.id == id)
    if event.delete_instance():
        return redirect(url_for('events.index'))
    else:
        flash('Sorry but the deletion could not be executed', 'danger')
        return redirect(url_for(request.referrer))
예제 #7
0
def select():
    # get a name of the pic
    card_idx = int(next(request.form.keys()).rstrip('.x'))
    game = get_game()
    game.revealed.append(card_idx)
    Event(card_idx, game.id)
    game.save()
    return redirect(url_for('play'))
예제 #8
0
def create():
    location = request.form.get('location')
    date = request.form.get('date')
    time = request.form.get('time')
    event_name = request.form.get('event_name')
    description = request.form.get('description')
    establishment_id = request.form.get('establishment_id')

    events = Event(location=location, date=date, time=time, event_name=event_name,
                   description=description, establishment_id=establishment_id)

    try:
        events.save()
        flash('Event registered successfully', 'success')
        return redirect(url_for('events.index'))

    except:
        flash('Error creating event', 'danger')
        return redirect(url_for('events.new'))
예제 #9
0
def display_all_students_evets(user_id):
    """
    Call function to print all students and user Events object
    and all Checkpoint objects

    Examples:
        "st" are two first signs of student id
    """

    view.print_all_events(Event.get_events())
예제 #10
0
    def __init__(self, date, goal, preffered_mentor, user_id):
        """
        Construct PrivateMentoring object

        Args:
            date (:obj: `date`): date of checkpoint
            goal (string): gaol of private mentoring
            preffered_mentor (string): preffered mentor to private mentoring sesion
        """

        super().__init__(date)
        self.user_id = user_id

        self.preffered_mentor = None
        self.goal = None

        self.set_goal(goal)
        self.set_preffered_mentor(preffered_mentor)

        Event.add_event(self)
예제 #11
0
 def __init__(self, data):
     for key in data.keys():
         setattr(self, key, data[key])
     if data['lastEvent']:
         setattr(self, 'lastEvent', Event(data['lastEvent']))
     if data['parameters']:
         setattr(self, 'parameters',
                 [Parameter(parameter) for parameter in data['parameters']])
     if data.get('serviceType'):
         setattr(self, 'serviceType', serviceType(data['serviceType']))
     if data.get('ackTime'):
         self.isAcknowledged = True
     else:
         self.isAcknowledged = False
예제 #12
0
def long_polling():
    game = get_game()
    if game is None:
        return redirect(url_for('main'))

    player = get_user(game)
    print(f'Event is requested by {player.name}')
    while True:
        event = Event.get(game.id, player.name)
        if event is not None:
            event['url'] = url_for('main')
            print(f'Event {event} is requested by {player.name}')
            return jsonify(event)
        time.sleep(1)
예제 #13
0
  def post(self):

    payload = request.get_data()

    json_data = json.loads(payload)

    event = Event(
      json_data.get("id"),
      json_data.get("userid"),
      json_data.get("noun"),
      datetime.datetime.now(),
      json_data.get("latlong"),
      json_data.get("verb"),
      json_data.get("timespent"),
      json_data.get("properties")
    )

    xx = event.save()

    RulesEngine().execute(json_data)

    xx = json.dumps(event, cls=AlchemyEncoder)

    return {"response": json.loads(xx), "status": "success"}
예제 #14
0
def display_user_evets(user_id):
    """
    Call function to print all user private mentoring
    and checkpoints Events objects to user

    Examples:
        "mt" are two first signs of mentor id
    """

    user_events = []

    events = Event.get_events()
    for event in events:
        if event.user_id == user_id or event.__class__.__name__ == "Checkpoint":
            user_events.append(event)

    view.print_all_events(user_events)
예제 #15
0
def get_event(game_id: str, name: str):
    return Event.get(game_id, name)
예제 #16
0
def handle_current_events():
    return Event.get_current_events()
예제 #17
0
    Category(category="community"),
    Category(category="fashion"),
    Category(category="film"),
    Category(category="hobbies"),
    Category(category="government"),
    Category(category="science"),
]

list_events = [
    Event(
        name="Tupac Live at the Apollo!!",
        date="21st June",
        start_time="2pm",
        duration="1 day",
        description=
        "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
        target_age=30,
        expected_attendees=20000,
        location="Dubai",
        image=
        "https://images.unsplash.com/photo-1492684223066-81342ee5ff30?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80",
        user_id=1,
        category=list_categories),
    Event(
        name="Beyonce Live in Concert",
        date="21st June",
        start_time="2pm",
        duration="1 day",
        description=
        "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
        target_age=50,
        expected_attendees=40000,
예제 #18
0
def game_events(fixture_id):
    events = Event.events_fixture_id(fixture_id)
    return jsonify({"fixtures": events})
예제 #19
0
파일: utils.py 프로젝트: SNHenderson/plm18
 def build_event(event):
     # Remove the "name" of the event since it's unused
     event.pop("name")
     e = {key: parse(value) for key, value in event.items()}
     return Event(lambda: evaluate(e.get('trigger')),
                  lambda: do_event(e.get('action')))
예제 #20
0
def index():
    events = Event.select()
    return render_template('events/index.html', events=events)