Esempio n. 1
0
def add_note():
    """
    Renders the VMS teacher notes page and note history

    _OR_

    Creates a new lesson note

    if the note form is valid, the session adds the note to the note table
    """

    if not request.form:
        teacher = crud.get_teacher_by_id(session['teacher_id'])
        teacher_notes = teacher.notes

        return render_template('teacher-notes.html',
                               teacher=teacher,
                               teacher_notes=teacher_notes)

    note_teacher_id = (session['teacher_id'])
    student_id = request.form.get('note_student_name')
    note_date = request.form.get('note_date')
    note_time = request.form.get('note_time')
    note_content = request.form.get('note_content')

    # Combine date and time to parse provided objects into a datetime object
    note_created_at = datetime.strptime(note_date + ' ' + note_time,
                                        '%Y-%m-%d %H:%M')

    note = crud.create_note(note_teacher_id, student_id, note_created_at,
                            note_content)

    return jsonify({'status': 'ok', 'note_date': note.note_created_at})
Esempio n. 2
0
def return_new_note():
    """Saves new note to DB, notifies users by text and returns to page in JSON."""

    itinerary_id = session['TRIP']
    trip_name = helper.get_itinerary_name(itinerary_id)
    email = session['EMAIL']
    user_id = session['ID']
    author = session['NAME']
    comment = request.form['comment']
    date = request.form['date']
    if date == '':
        date = None
    crud.create_note(itinerary_id, user_id, comment, date)
    helper.send_itinerary_text_update(itinerary_id, email, trip_name, author)
    json_data = {'author': author, 'comment': comment, 'day': date}

    return json.dumps(json_data, cls=helper.DateTimeEncoder)
Esempio n. 3
0
def create_job_application():
    """Create a job application """

    user = crud.get_user_by_email(session['email'])
    user_id = user.user_id

    company_name = request.form.get('company_name')
    job_title = request.form.get('job_title')
    deadline = request.form.get('deadline')
    job_listing_url = request.form.get('company_name')
    listing_date = request.form.get('application_listed')
    salary = request.form.get('salary')
    application_state = request.form.get('application_state')
    state = request.form.get('state')
    city = request.form.get('city')
    note_category = request.form.get('note_category')
    note_title = request.form.get('note_title')
    note_text = request.form.get('note_text')

    formatted_listing_date = datetime.strptime(listing_date, "%Y-%m-%dT%H:%M")
    formatted_deadline = datetime.strptime(deadline, "%Y-%m-%dT%H:%M")

    job_detail = crud.create_job_detail(company_name, job_title,
                                        formatted_deadline, job_listing_url,
                                        state, city, formatted_listing_date,
                                        salary)

    job_id = crud.get_last_job_id()
    application_date_submitted = datetime.now()

    job_applied = crud.create_job_applied(user_id, job_id,
                                          application_date_submitted)

    job_applied_id = crud.get_last_job_applied_id()
    note_date_created = datetime.now()

    note = crud.create_note(job_applied_id, user_id, note_title, note_text,
                            note_category, note_date_created)

    created_at = datetime.now()

    application_progress = crud.create_application_progress(
        application_state, job_applied_id, created_at)

    return redirect('/view-job-application')
Esempio n. 4
0
def add_note():
    """Creates a new lesson note

    if the note form is valid, the session adds the note to the note table"""

    note_teacher_id = (session['teacher_id'])
    note_student_name = request.form.get('note_student_name')

    # Consider combining the 2 into one field
    note_date = request.form.get('note_date')
    note_time = request.form.get('note_time')

    note_content = request.form.get('note_content')

    # Combine the 2! – will parse provided objects into a datetime object
    note_created_at = datetime.strptime(note_date + ' ' + note_time,
                                        '%m/%d/%Y %H:%M %p')

    # Create your note
    note = crud.create_note(note_teacher_id, note_student_name,
                            note_created_at, note_content)

    return jsonify({'status': 'ok', 'note_date': note.note_date})
Esempio n. 5
0
def handle_note(data):
    """Receive emitted note data, creates a new note, & emit to others in the room"""
    body = data['note']
    room = data['room']
    x_pos = data['x_pos']
    y_pos = data['y_pos']
    user_id = session[request.sid]
    print(f"Note: {body} Room: {room} User: {user_id} X: {x_pos} Y: {y_pos}")
    # print(f"NAME {crud.get_user_by_id(user_id).fname}")

    user = crud.get_user_by_id(user_id)
    fname = user.fname
    lname = user.lname

    created_at = datetime.datetime.utcnow()
    date_as_int = int(time.mktime(created_at.timetuple())) * 1000

    note_info = crud.create_note(user_id, room, created_at, body, x_pos, y_pos,
                                 fname, lname)
    color = note_info['color']
    note = note_info['note']

    note_json = {
        'note_id': note.note_id,
        'user_id': user_id,
        'doc_id': room,
        'created_at': date_as_int,
        'body': body,
        'x_pos': x_pos,
        'y_pos': y_pos,
        'fname': fname,
        'lname': lname,
        'color': color
    }

    io.emit('note', note_json, room=room)
Esempio n. 6
0
def get_job_details(job_id):
    session['job_id'] = job_id
    """ Display extended job details"""
    print("job_id:", job_id)
    user = crud.get_user_by_email(session['email'])
    user_id = user.user_id
    print("user_id:", user_id)
    job_detail = crud.get_user_job_detail(user_id)
    job_applied_id = crud.get_job_applied_by_job_id(job_id)
    dictionary_jobs = {}
    for job in job_detail:
        print("job:", job)
        if job.job_id == int(job_id):
            print("entered if")
            dictionary_jobs['company_name'] = job.company_name,
            dictionary_jobs['job_title'] = job.job_title,
            dictionary_jobs['application_deadline'] = job.application_deadline,
            dictionary_jobs['job_listing_url'] = job.job_listing_url,
            dictionary_jobs['state'] = job.state,
            dictionary_jobs['city'] = job.city,
            dictionary_jobs['salary'] = job.salary,
            dictionary_jobs['application_listed'] = job.application_listed,
            dictionary_jobs[
                'app_state'] = crud.get_application_state_by_applied(
                    job.job_completed_applications[0].job_applied_id
                ).application_state

    notes_list = crud.all_note_by_job_applied_id(job_applied_id)

    note_dictionary = {}

    for index, note in enumerate(notes_list):
        note_dictionary[index] = {}
        note_dictionary[index]['note_title'] = note.note_title,
        note_dictionary[index]['note_text'] = note.note_text

    note_job_description = crud.all_jd_by_job_applied_id(job_applied_id)
    print(note_job_description)
    note_jd = {}

    if note_job_description != None:
        note_jd[1] = {}
        note_jd[1]['note_title'] = note_job_description.note_title,
        note_jd[1]['note_text'] = note_job_description.note_text
    note_recruit = crud.all_recruiter_by_job_applied_id(job_applied_id)
    note_recruiter = {}
    for index, note in enumerate(note_recruit):
        note_recruiter[index] = {}
        note_recruiter[index]['note_title'] = note.note_title,
        note_recruiter[index]['note_text'] = note.note_text

    # changes
    note_resumes = crud.all_resume_by_job_applied_id(job_applied_id)
    note_resume = {}
    for index, note in enumerate(note_resumes):
        note_resume[index] = {}
        note_resume[index]['note_title'] = note.note_title,
        note_resume[index]['note_text'] = note.note_text

    note_followups = crud.all_followup_by_job_applied_id(job_applied_id)
    note_followup = {}

    for index, note in enumerate(note_followups):
        note_followup[index] = {}
        note_followup[index]['note_title'] = note.note_title,
        note_followup[index]['note_text'] = note.note_text

    note_interviews = crud.all_interview_by_job_applied_id(job_applied_id)
    note_interview_question = {}
    for index, note in enumerate(note_interviews):
        note_interview_question[index] = {}
        note_interview_question[index]['note_category'] = note.note_category,
        note_interview_question[index]['note_title'] = note.note_title,
        note_interview_question[index]['note_text'] = note.note_text

    created_at = datetime.now()
    note_date_created = datetime.now()
    application_state = request.form.get('application_state')
    note_category = request.form.get('note_category')
    note_title = request.form.get('note_title')
    note_text = request.form.get('note_text')

    if application_state:
        application_progress = crud.create_application_progress(
            application_state, job_applied_id, created_at)
        template = f'/view-job-application/{job_id}'
        return redirect(template)
    if note_category:
        note = crud.create_note(job_applied_id, user_id, note_title, note_text,
                                note_category, note_date_created)
        template = f'/view-job-application/{job_id}'
        return redirect(template)

    return render_template('view-application-details.html',
                           dictionary_jobs=dictionary_jobs,
                           note_dictionary=note_dictionary,
                           note_jd=note_jd,
                           note_recruiter=note_recruiter,
                           note_resume=note_resume,
                           note_followup=note_followup,
                           note_interview_question=note_interview_question)
account_in_db = []
for account in account_data:
    email, password = (account['email'], account['password'])
    login_id = choice(login_in_db).id

    account_db = crud.create_account(email, password, login_id)
    account_in_db.append(account_db)

lists_in_db = []
for newlist in list_data:
    name = (newlist['name'])
    user_id = choice(users_in_db).id
    list_db = crud.create_list(name, user_id)
    lists_in_db.append(list_db)

entries_in_db = []
for entry in entry_data:
    user_text = (entry['user_text'])
    newlist_id = choice(lists_in_db).id

    entry_db = crud.create_entry(user_text, newlist_id)
    entries_in_db.append(entry_db)

notes_in_db = []
for note in note_data:
    note_text = (note['note_text'])
    user_id = choice(users_in_db).id

    note_db = crud.create_note(note_text, user_id)
    entries_in_db.append(note_db)
Esempio n. 8
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')
Esempio n. 9
0
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!')
crud.create_note(3, 7, 'I want to go wine tasting!', '2020-12-02')
Esempio n. 10
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)
Esempio n. 11
0
        application_date_submitted = date2
        job_applied = crud.create_job_applied(user_id, job_id,
                                              application_date_submitted)

        #create job application progress
        app_state = choice([
            "applied", "phone interview", "onsite interview", "rejected",
            "offer"
        ])
        job_applied_id = user + 1
        created_at = date1
        application_progress = crud.create_application_progress(
            app_state, job_applied_id, created_at)

        #create upto 5 notes per user

        job_applied_id = job + (5 * user) + 1
        user_id = user + 1
        note_category = choice([
            "Job Description", "Follow-up", "Note",
            "Interview Question Behavioral",
            "Interview Question Informational", "Interview Question Technical",
            "Recruiter Contact", "Resume"
        ])
        note_title = f" {note_category} {job}"
        note_text = f" This is Note {note_category} of {company_name}."
        note_date_created = date1

        note = crud.create_note(job_applied_id, user_id, note_title, note_text,
                                note_category, note_date_created)
Esempio n. 12
0
    def test_create_note(self):
        """Tests creation of a note in the databse"""

        n = crud.create_note(1, 1, 'test note')
        self.assertIsNotNone(n.note_id)