示例#1
0
def add_new_activity():
    """adds new activity to database."""

    itinerary_id = session['TRIP']
    trip_name = helper.get_itinerary_name(itinerary_id)
    email = session['EMAIL']
    author = session['NAME']
    activity_name = request.form['name']
    address = request.form['address']
    lat_lng = request.form['latlng']
    lat_lng = lat_lng.strip('()').split(', ')
    lat = float(lat_lng[0])
    lng = float(lat_lng[1])
    # lat, lng = float(lat_lng_list) - error.  reassess later
    activity_day = request.form['day']
    if activity_day == '':
        activity_day = None
    activity_time = request.form['time']
    if activity_time == '':
        activity_time = None
    activity_note = request.form['note']
    if activity_note == '':
        activity_note = None
    crud.create_activity(itinerary_id, activity_name, address, 
                        lat, lng, activity_day, activity_time, 
                        activity_note)
    # triggers twilio text for users connected in this trip.
    helper.send_itinerary_text_update(itinerary_id, email, trip_name, author)
    return jsonify('This activity has been added to your trip')
示例#2
0
    def test_create_activity(self):
        """Tests creation of an activity in the database."""

        a = crud.create_activity(
            1, 'Highclere Castle',
            'Highclere Park, Highclere, Newbury RG20 9RN, United Kingdom',
            51.3265934, -1.3628547, '2021-01-04', '13:00')
        self.assertIsNotNone(a.activity_id)
示例#3
0
os.system('dropdb kidactivities')
os.system('createdb kidactivities')

connect_to_db(server.app)
db.create_all()


with open('data/activities.json') as x:
    activity_info = json.loads(x.read())

activity_in_db =[]
for activity in activity_info:
    activity_name, min_cost, max_cost, min_age, max_age, location, effort_rating, keywords, activity_description, timestamp = (activity['activity_name'],activity['min_cost'],activity['max_cost'],activity['min_age'],
    activity['max_age'],activity['location'],activity['effort_rating'],activity['keywords'],activity['activity_description'], activity['timestamp'])
        
    db_activity = crud.create_activity(activity_name, min_cost,max_cost, min_age, max_age, location, effort_rating, keywords, activity_description)

    activity_in_db.append(db_activity)


with open('data/interest_info.json') as f:
    interest_info = json.loads(f.read())

interests_in_db =[]
for interest in interest_info:
    interest_name =(interest['interest_name'])
        
    db_interest = crud.create_interest(interest_name)

    interests_in_db.append(db_interest)
示例#4
0
]

for state in states:
    crud.create_state(state)

#Create Parks
data_value = park_data['data']
data_dict = data_value

all_parks = set()
all_activities = []

for value in data_value:
    parks_list = value['parks']

    db_activity = crud.create_activity(value['name'])
    all_activities.append(db_activity)

    for park in parks_list:

        if park['designation'] == 'National Park':
            park_name, designation, siteURL = (park['fullName'],
                                               park['designation'],
                                               park['url'])

            db_park = crud.create_park(park_name, designation, siteURL)

            crud.create_park_activity(db_activity.activity_id, db_park.park_id)

            if db_park not in all_parks:
                split = park['states'].split(',')
示例#5
0
crud.create_user_itinerary(4, 3)
crud.create_user_itinerary(7, 3)

crud.create_user_itinerary(7, 4)
crud.create_user_itinerary(6, 4)
crud.create_user_itinerary(5, 4)

crud.create_user_itinerary(1, 5)
crud.create_user_itinerary(2, 5)
crud.create_user_itinerary(3, 5)
crud.create_user_itinerary(5, 5)
crud.create_user_itinerary(8, 5)

#create activities for Itinerary

crud.create_activity(1, 'Lyceum Theatre', '21 Wellington St, Covent Garden, London WC2E 7RQ, United Kingdom', 51.511619, -0.1223251, '2021-01-02', '20:00')
crud.create_activity(1, 'Wagamama', '17 Bedford St, Covent Garden, London WC2E 9HP, United Kingdom', 51.5107958, -0.12691, '2021-01-02', '17:00')
crud.create_activity(1, 'National Portrait Gallery', "St. Martin's Pl, Charing Cross, London WC2H 0HE, United Kingdom", 51.5094269, -0.1303103)
crud.create_activity(1, 'Warner Bros. Studio Tour London', 'Studio Tour Dr, Leavesden, Watford WD25 7LR, United Kingdom', 51.6903501, -0.4202619, '2021-01-06', '09:00')
crud.create_activity(1, 'Highclere Castle', 'Highclere Park, Highclere, Newbury RG20 9RN, United Kingdom', 51.3265934, -1.3628547, '2021-01-04', '13:00')
crud.create_activity(1, 'Victoria and Albert Museum', 'Cromwell Rd, Knightsbridge, London SW7 2RL, United Kingdom', 51.4966425, -0.1743687, activity_note="I don't know what day we should do this, but they have a cool fashion exhibit")
crud.create_activity(2, 'Aling-Aling Waterfall', 'Jl. Raya Desa Sambangan, Sambangan, Kec. Sukasada, Kabupaten Buleleng, Bali 81161, Indonesia', -8.2525684, 114.9480604)
crud.create_activity(3, 'Dinner with Friends', '5231 Wendell Lane, Sebastopol, CA, 95472', 38.348009, -122.7702767, '2020-12-4', '17:00')
crud.create_activity(4, 'The Girl and the Goat', '809 W Randolph St, Chicago, IL 60607', 41.884113, -87.6501642)
crud.create_activity(5, 'Eiffel Tower', 'Champ de Mars, 5 Avenue Anatole France, 75007 Paris, France', 48.8583736, 2.2922926, '2021-03-05', '09:00')

#create notes
crud.create_note(1, 1, 'Lets make sure we go to high tea!')
crud.create_note(5, 2, 'I wont eat escargot. Bleck!')
crud.create_note(3, 7, 'I want to go wine tasting!', '2020-12-02')
示例#6
0
def add_activity():
    """Add a new Activity"""

    materials = Material.query.all()
    interests = Interest.query.all()
    time_periods = TimePeriod.query.all()

    if request.method == 'GET':

        return render_template('add_activity.html',
                               materials=materials,
                               interests=interests,
                               time_periods=time_periods)

    if request.method == 'POST':
        activity_name = request.form['activity_name']
        overview = request.form['overview']
        overview_pic = request.form['overview_pic']
        step_1 = request.form['step_1']
        photo_1 = request.form['photo_1']
        step_2 = request.form['step_2']
        photo_2 = request.form['photo_2']
        step_3 = request.form['step_3']
        photo_3 = request.form['photo_3']
        step_4 = request.form['step_4']
        photo_4 = request.form['photo_4']
        step_5 = request.form['step_5']
        photo_5 = request.form['photo_5']
        step_6 = request.form['step_6']
        photo_6 = request.form['photo_6']
        keywords = request.form['keywords']
        location = request.form['location']
        min_cost = request.form['min_cost']
        max_cost = request.form['max_cost']
        min_age = request.form['min_age']
        max_age = request.form['max_age']
        effort_rating = request.form['effort_rating']

        materials = request.form.getlist('materials[]')
        interests = request.form.getlist('interests[]')
        time_periods = request.form.getlist('time_periods[]')

        activity_description = crud.create_activity_description(
            activity_name, overview, overview_pic, step_1, photo_1, step_2,
            photo_2, step_3, photo_3, step_4, photo_4, step_5, photo_5, step_6,
            photo_6)

        activity = crud.create_activity(activity_name, min_age, max_age,
                                        min_cost, max_cost, location,
                                        effort_rating, keywords,
                                        activity_description)
        db.session.add(activity)
        db.session.commit()

        if interests:
            for interest_id in interests:
                if interest_id != None:
                    interest = Interest.query.get(interest_id)
                    activity.interests.append(interest)
                    db.session.commit()

        if materials:
            for material_id in materials:
                if material_id != None:
                    material = Material.query.get(material_id)
                    activity.materials.append(material)
                    db.session.commit()

        if time_periods:
            for time_period_id in time_periods:
                if time_period_id != None:
                    time_period = TimePeriod.query.get(time_period_id)
                    activity.time_periods.append(time_period)
                    db.session.commit()

        db.session.commit()

        flash("Activity added")
        return redirect(url_for('add_activity'))

    else:
        return redirect('/login')
示例#7
0
crud.create_user_itinerary(4, 3)
crud.create_user_itinerary(7, 3)

crud.create_user_itinerary(7, 4)
crud.create_user_itinerary(6, 4)
crud.create_user_itinerary(5, 4)

crud.create_user_itinerary(1, 5)
crud.create_user_itinerary(2, 5)
crud.create_user_itinerary(3, 5)
crud.create_user_itinerary(5, 5)
crud.create_user_itinerary(8, 5)

#create activities for Itinerary

crud.create_activity(1, 'Lyceum Theatre', '21 Wellington St, Covent Garden, London WC2E 7RQ, United Kingdom', 51.511619, -0.1223251, '2021-01-02', '20:00')
crud.create_activity(1, 'Wagamama', '17 Bedford St, Covent Garden, London WC2E 9HP, United Kingdom', 51.5107958, -0.12691, '2021-01-02', '17:00')
crud.create_activity(1, 'National Portrait Gallery', "St. Martin's Pl, Charing Cross, London WC2H 0HE, United Kingdom", 51.5094269, -0.1303103)
# crud.create_activity(1, 'Warner Bros. Studio Tour London', 'Studio Tour Dr, Leavesden, Watford WD25 7LR, United Kingdom', 51.6903501, -0.4202619, '2021-01-06', '09:00')
# crud.create_activity(1, 'Highclere Castle', 'Highclere Park, Highclere, Newbury RG20 9RN, United Kingdom', 51.3265934, -1.3628547, '2021-01-04', '13:00')
crud.create_activity(1, 'Victoria and Albert Museum', 'Cromwell Rd, Knightsbridge, London SW7 2RL, United Kingdom', 51.4966425, -0.1743687, activity_note="I don't know what day we should do this, but they have a cool fashion exhibit")
# crud.create_activity(2, 'Aling-Aling Waterfall', 'Jl. Raya Desa Sambangan, Sambangan, Kec. Sukasada, Kabupaten Buleleng, Bali 81161, Indonesia', -8.2525684, 114.9480604)
# crud.create_activity(3, 'Dinner with Friends', '5231 Wendell Lane, Sebastopol, CA, 95472', 38.348009, -122.7702767, '2020-12-4', '17:00')
# crud.create_activity(4, 'The Girl and the Goat', '809 W Randolph St, Chicago, IL 60607', 41.884113, -87.6501642)
# crud.create_activity(5, 'Eiffel Tower', 'Champ de Mars, 5 Avenue Anatole France, 75007 Paris, France', 48.8583736, 2.2922926, '2021-03-05', '09:00')

#create notes
crud.create_note(1, 1, 'Lets make sure we go to high tea!')
crud.create_note(1, 2, 'Lets have a picnic in Hyde Park', '2021-01-05')
crud.create_note(1, 3, "I don't really want to go to the Castle. I'll find something else to do.", '2021-01-04')
crud.create_note(5, 2, 'I wont eat escargot. Bleck!')
示例#8
0
def dashboard():
    # Create variables for all forms
    meal_form = MealForm()
    mood_form = MoodForm()
    activity_form = ActivityForm()
    training_form = TrainingForm()
    grooming_form = GroomingForm()
    note_form = NoteForm()
    med_form = MedForm()

    # Variables for dog_id, current date, and current time
    dog_id = session['dog_id']

    # Current date and Month to use for filtering Database
    current_date = date.today().strftime("%m/%d/%y")
    current_month = date.today().strftime("%m")

    # Not Ideal but datetime does not offer taking time directly from device being used
    central_time = pytz.timezone('America/Chicago')
    current_time = datetime.now(central_time).strftime("%I:%M")

    # Getting all data to render on dashboard
    dog_info = crud.get_dog_by_dog_id(dog_id)
    all_meals = crud.get_all_meals(dog_id, current_date)
    all_moods = crud.get_all_moods(dog_id, current_date)
    all_activities = crud.get_all_activities(dog_id, current_date)
    all_trainings = crud.get_all_training_sessions(dog_id, current_date)
    all_groomings = crud.get_all_grooming_sessions(dog_id, current_date)
    all_notes = crud.get_all_notes(dog_id, current_date)
    all_meds = crud.get_all_meds(dog_id, current_month)

    # Creating a new meal from form
    if meal_form.validate_on_submit():
        new_meal = crud.create_meal(dog_id, meal_form.meal_type.data,
                                    current_date, current_month, current_time)
        return redirect('/dashboard')

    # Creating a new mood from form
    if mood_form.validate_on_submit():
        new_mood = crud.create_mood(dog_id, mood_form.mood_type.data,
                                    current_date, current_month,
                                    mood_form.mood_note.data)
        return redirect('/dashboard')

    # Creating a new activity from form
    if activity_form.validate_on_submit():
        new_activity = crud.create_activity(
            dog_id, activity_form.activity_type.data, current_date,
            current_month, current_time, activity_form.activity_duration.data,
            activity_form.activity_note.data)
        return redirect('/dashboard')

    # Creating a new training session from form
    if training_form.validate_on_submit():
        new_training = crud.create_training(
            dog_id, training_form.training_type.data, current_date,
            current_month, current_time, training_form.training_duration.data,
            training_form.training_note.data)
        return redirect('/dashboard')

    # Creating a new grooming session from form
    if grooming_form.validate_on_submit():
        new_grooming = crud.create_grooming(dog_id,
                                            grooming_form.grooming_type.data,
                                            current_date, current_month)
        return redirect('/dashboard')

    # Creating a new note from form
    if note_form.validate_on_submit():
        new_note = crud.create_note(dog_id, current_date, note_form.note.data)
        return redirect('/dashboard')

    # Create a new medication from form
    if med_form.validate_on_submit():
        new_med = crud.create_med(dog_id, med_form.med_type.data,
                                  current_month, med_form.med_note.data)
        return redirect('/dashboard')

    return render_template("dashboard.html",
                           meal_form=meal_form,
                           mood_form=mood_form,
                           activity_form=activity_form,
                           training_form=training_form,
                           grooming_form=grooming_form,
                           note_form=note_form,
                           med_form=med_form,
                           all_meals=all_meals,
                           all_moods=all_moods,
                           all_activities=all_activities,
                           all_trainings=all_trainings,
                           all_groomings=all_groomings,
                           all_notes=all_notes,
                           all_meds=all_meds,
                           dog_info=dog_info)
示例#9
0
def create_activity(
    activity: schemas.Activity,
    db: Session = Depends(get_db),
    current_user: schemas.User = Depends(get_current_active_user)):
    return crud.create_activity(db=db, activity=activity)
示例#10
0
os.system('createdb edvid')
model.connect_to_db(server.app, 'postgresql:///edvid', echo=False)
model.db.create_all()

# Load movie data from JSON file
with open('videos.json') as f:
    video_data = json.loads(f.read())

# Create videos, store them in list so we can use them
# to create fake activities
videos_in_db = []

for video in video_data:
    link, title, notes = (video['link'], video['title'], video['notes'])

    db_video = crud.create_video(link, title, notes)
    videos_in_db.append(db_video)

# Create 10 users; each user will link to 3 videos
for n in range(10):
    email = f'user{n}@test.com'  # Voila! A unique email!
    password = '******'

    user = crud.create_user(email, password)

    for x in range(3):
        random_video = choice(videos_in_db)
        #grade = randint(1, 6)
        fake_title = f'activity{x}'
        activity = crud.create_activity(fake_title, user)
        vidact = crud.create_association(random_video, activity)