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)
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])
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)
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)
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)
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))
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'))
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'))
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())
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)
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
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)
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"}
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)
def get_event(game_id: str, name: str): return Event.get(game_id, name)
def handle_current_events(): return Event.get_current_events()
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,
def game_events(fixture_id): events = Event.events_fixture_id(fixture_id) return jsonify({"fixtures": events})
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')))
def index(): events = Event.select() return render_template('events/index.html', events=events)