def create_note(teacher_id, student_id, note_created_at, note_content): """Creates a new teacher note record""" # Allows querying of student by full name # instead of querying by hybrid attribute # student_id = db.session.query(Student.student_id)\ # .filter( # func.concat( # Student.student_fname, # ' ', # Student.student_lname # ) == note_student_name # ).first() # Only allow if student id exists # if not student_id: # return None note = Note(teacher_id=teacher_id, student_id=student_id, note_created_at=note_created_at, note_content=note_content) db.session.add(note) db.session.commit() return note
def create_note_reply(user_id, doc_id, created_at, body, parent_id, fname, lname): """Reply to a note.""" # figure out x and y pos # tz = pytz.timezone('America/Los_Angeles') # created_at = datetime.now(tz) color_check = check_prev_note_color(user_id, doc_id) if color_check: color = color_check else: color = '#C2D6C4' note = Note( user_id=user_id, doc_id=doc_id, parent_id=parent_id, created_at=created_at, body=body, # x_pos = x_pos, # y_pos = y_pos, fname=fname, lname=lname, color=color) db.session.add(note) db.session.commit() return {'note': note, 'color': color}
def index(): if request.method == 'POST': form = NoteForm(request.form) if form.validate(): note = Note(unique_word_count=count_unique_word(form.text.data), short_description=form.text.data[:60], text=form.text.data) db.session.add(note) db.session.commit() flash('Заметка №({}) успешно добавлена'.format(note.id), 'success') return redirect(url_for('index')) else: flash('Пожалуйста заполните форму', 'warning') return redirect(url_for('index')) if request.method == 'GET': form = NoteForm() return render_template('index.html', title='Add Note', form=form, active_note_add=True)
def newNote(): if request.method == "POST": json = request.get_json() newNote = Note(json["sourceCode"], json["owner"], json["course_belonged"]) db.session.add(newNote) db.session.commit() return jsonify({"status": "OK"})
def test_chord(self): a = Note(100, 15, 250) b = Note(100, 11, 250) c = Note(100, 18, 250) score = Score([a, b, c]) for i in [40, 99, 101, 349, 350, 351, 450]: self.assertEquals(0, len(score.starts_at(i))) self.assertEquals(3, len(score.starts_at(100))) for i in [40, 99, 100, 101, 349, 351, 450]: self.assertEquals(0, len(score.ends_at(i))) self.assertEquals(3, len(score.ends_at(350))) for i in [50, 99, 350, 351, 450]: self.assertEquals(0, len(score.sounding_at(i))) for i in [100, 101, 349]: self.assertEquals(3, len(score.sounding_at(i)))
def store_notes(note_content, match_id, group_id): """ Store grouped notes per match """ note = Note(note_content=note_content, match_id=match_id, group_id=group_id) db.session.add(note) db.session.commit()
def setUp(self): """ Create a validator and add one note to it. Note(delay=100, height=15, duration=100) """ self.the_note = Note(delay=100, height=15, duration=100) score = Score([self.the_note]) self.validator = Validator(score, margin=10) self.validator.add_reference_note(self.the_note)
def add_note(): title = request.json['title'] description = request.json['description'] user_id = request.json['user_id'] new_note = Note(title, description, user_id) db.session.add(new_note) db.session.commit() return note_schema.jsonify(new_note)
def create_note(itinerary_id, user_id, comment, day=None): """Create and return a new note.""" note = Note(itinerary_id=itinerary_id, user_id=user_id, comment=comment, day=day) db.session.add(note) db.session.commit() return note
def test_interval(self): a = Note(100, 15, 200) b = Note(200, 11, 200) c = Note(300, 18, 200) score = Score([a, b, c]) for i in [40, 99, 101, 199, 201, 299, 301, 400, 500]: self.assertEquals(0, len(score.starts_at(i))) for i in [100, 200, 300]: self.assertEquals(1, len(score.starts_at(i))) for i in [40, 99, 100, 101, 200, 201, 299, 301, 499]: self.assertEquals(0, len(score.ends_at(i))) for i in [300, 400, 500]: self.assertEquals(1, len(score.ends_at(i))) for i in [50, 99, 500]: self.assertEquals(0, len(score.sounding_at(i))) for i in [100, 101, 199, 400, 499]: self.assertEquals(1, len(score.sounding_at(i))) for i in [200, 201, 299, 300, 301, 399]: self.assertEquals(2, len(score.sounding_at(i)))
def add_note(): if not request.is_json: return BadRequest('Missing JSON request') user_email = request.json.get('email') title = request.json.get('title') note_text = request.json.get('text') user = User.objects(email=user_email).first() if user is None: raise BadRequest("Not Found") note = Note(title=title, text=note_text, user=user.id) note.save() return jsonify(note=note.serialize)
def create_note(job_applied_id, user_id, note_title, note_text, note_category, note_date_created): """create and return note """ note = Note(job_applied_id=job_applied_id, user_id=user_id, note_title=note_title, note_text=note_text, note_category=note_category, note_date_created=note_date_created) db.session.add(note) db.session.commit() return note
def get(self): # req_json = json.loads(self.request.body) # user_email = req_json[IDENTIFIER_USER_EMAIL] user_email = self.request.get(IDENTIFIER_USER_EMAIL) # apt_name = req_json[IDENTIFIER_APT_NAME] apt_name = self.request.get(IDENTIFIER_APT_NAME) # description = req_json[IDENTIFIER_DESCRIPTION_NAME] description = self.request.get(IDENTIFIER_DESCRIPTION_NAME) apt_lst = Apartment.query(Apartment.apt_name == apt_name).fetch() cur_apt = None for apt in apt_lst: if user_email in apt.user_email_lst: cur_apt = apt if cur_apt == None: response = {} response[ 'error'] = 'the apt: ' + apt_name + ' is not available for user: '******'error'] = 'we dont have notebook for the apt: ' + apt_name return self.respond(**response) cur_note_book = cur_note_book_lst[0] note_id = uuid.uuid4() note = Note(id=str(note_id), description=description, author_email=user_email, notebook_id=cur_note_book_id) cur_note_book.note_id_lst.append(str(note_id)) cur_note_book.put() note.put() self.respond(note_id=str(note_id), notebook_id=cur_note_book_id, status="Success")
def test_single_note(self): a = Note(100, 15, 250) score = Score([a]) for i in [40, 99, 101, 349, 350, 341, 450]: self.assertEquals(0, len(score.starts_at(i))) self.assertEquals(1, len(score.starts_at(100))) for i in [40, 99, 100, 101, 349, 351, 450]: self.assertEquals(0, len(score.ends_at(i))) self.assertEquals(1, len(score.ends_at(350))) for i in [50, 99, 350, 351, 450]: self.assertEquals(0, len(score.sounding_at(i))) for i in [100, 101, 349]: self.assertEquals(1, len(score.sounding_at(i)))
def post(self): """Update database when user added a note.""" if not current_user.is_active: return 'No permission.' key1 = request.form.get('key1') key2 = request.form.get('key2') new_note = Note(key1, key2) db.session.add(new_note) db.session.commit() message = 'Note added succesfully' return 'Note Added.'
def create_note(teacher_id, note_student_name, note_created_at, note_content): """Creates a new teacher note record""" # Allows querying of student by full name – Hopefull this works! student_id = session.query(Student).filter( Student.full_name == note_student_name).first() note = Note(teacher_id=teacher_id, student_id=student_id, note_created_at=note_created_at, note_content=note_content) db.session.add(note) db.session.commit() return note
def make_new_attraction(): """Process new attraction and its notes.""" set_val_attraction_id() set_val_note_id() attraction_name = request.form.get('attraction_name').strip() dest_id = request.form.get('dest_id') note_contents = request.form.getlist('note[]') # list #Get wiki description wiki_content = get_wiki_description(attraction_name) if not wiki_content: wiki_content = None #Add a new attraction to db attraction = Attraction(name=attraction_name, dest_id=dest_id, description=wiki_content) db.session.add(attraction) db.session.commit() #Add notes to db if not note_contents: note_contents = [''] for note_content in note_contents: new_note = Note(content=note_content, attraction_id=attraction.attraction_id) db.session.add(new_note) db.session.commit() attraction_note_info = { 'attraction_id': attraction.attraction_id, 'name': attraction.name, 'notes': [{ 'note_id': note.note_id, 'content': note.content } for note in attraction.notes] } print "##### Developer msg ##### Attraction added:", attraction return jsonify(attraction_note_info)
def add_note(): """User can add short notes to their homepage.""" user_id = session["user_id"] if request.method == "POST": note = request.form["note"] new_note = Note(note=note, user_id=user_id) db.session.add(new_note) db.session.commit() return jsonify({"note_id": new_note.note_id, "note": new_note.note}) else: return redirect(f"/")
def SSVParse(filename, resolution): """ Parse a SSV (?). Resolution must be integer. """ g = open(filename) notes = [] playing = [None] * 128 for line in g: parts = line.split() delay = int(float(parts[0]) * 1000) / resolution * resolution height = int(parts[1]) speed = int(parts[2]) if speed > 0: playing[height] = delay else: if playing[height] is not None: note = Note(playing[height], height, delay - playing[height]) notes.append(note) return Score(notes)
def test_shift(self): a = Note(100, 15, 250) shift = 100 score = Score([copy(a)]) score.shift_all_notes(shift) for i in [140, 199, 201, 449, 450, 451, 550]: self.assertEquals(0, len(score.starts_at(i))) self.assertEquals(1, len(score.starts_at(200))) for i in [140, 199, 200, 201, 449, 451, 550]: self.assertEquals(0, len(score.ends_at(i))) self.assertEquals(1, len(score.ends_at(450))) for i in [150, 199, 450, 451, 550]: self.assertEquals(0, len(score.sounding_at(i))) for i in [200, 201, 449]: self.assertEquals(1, len(score.sounding_at(i))) notes = score.starts_at(200) for n in notes: self.assertEquals(n.delay, a.delay + shift)
# Get yo student my_student = session.query(Student).filter_by(student_email=rec['student_email']).first() # make sure your student exists assert my_student # Check if note already exists: if note_already_exists(my_student.student_id, rec['note_created_at']): continue # Now create your note my_note = Note( teacher_id = my_student.teacher.teacher_id, student_id = my_student.student_id, note_created_at = rec['note_created_at'], note_content = rec['note_content'] ) session.add(my_note) # Now commit (you only need to commit at the end.) session.commit() # ------------------------------------------------------------------------------ # CREATE LOGS log_records = [
def create_note(dog_id, note_date, note): note = Note(dog_id=dog_id, note_date=note_date, note=note) db.session.add(note) db.session.commit() return note