def create_task(): if not request.json or not 'title' in request.json: abort(400) task = Tasks(title=request.json['title'], description=request.json.get('description', ''), done=False) db.session.add(task) db.session.commit() return jsonify({'task': task.get_json()})
def updatetask(sno, project): if request.method == 'POST': title = request.form['title'] todo = Tasks.query.filter_by(sno=sno).first() todo.title = title Tasks.add_todo(todo) return redirect(url_for('tasks', project=project)) else: todo = Tasks.query.filter_by(sno=sno).first() return render_template('updatetask.html', todo=todo, project=project)
def newTask(): form = AddForm() if form.validate_on_submit(): task = Tasks(task=form.taskName.data, rating=form.taskImportance.data, dueDate=form.taskDueDate.data, taskTime=form.taskTime.data, id=current_user.id) task.set_priority() priorities.put((0 - task.get_priority(), (form.taskName.data, form.taskDueDate.data))) db.session.add(task) db.session.commit() flash('Task Added') return redirect(url_for('index')) return render_template('newTask.html', form=form)
def add_tasks_individuals(): if current_user.username == 'Admin': if request.method == 'POST': task_title = request.form['title'] task_notes = request.form['sidenotes'] task_for = request.form['user'] task_modules = request.form['set'] task_due_date = request.form['duedate'] new_task = Tasks(title=task_title, side_notes=task_notes, task_for=task_for, task_set=task_modules, task_completed_by_date=task_due_date) db.session.add(new_task) db.session.commit() return redirect('/add_tasks_individuals') else: all_tasks = Tasks.query.all() all_sets = Set.query.all() all_users = User.query.all() return render_template('add_tasks_individuals.html', tasks=all_tasks, sets=all_sets, users=all_users) else: return render_template('accessdenied.html')
def add_task(): form = EditTaskForm(request.form) if form.validate(): task = Tasks(name=request.form['task_name'], list_id=request.form['task_id']) db.session.add(task) db.session.commit() task.priority = task.id db.session.commit() return jsonify({ 'add_task_response_status': 'success', 'task_id': task.id, 'task_priority': task.priority, 'task_name': task.name }) else: return jsonify(form.errors)
def tasks(project): if request.method == 'POST': title = request.form['title'] todo = Tasks(title=title, complete=False, project=project) Tasks.add_todo(todos=todo) return redirect(url_for('tasks', project=project)) else: exists = Tasks.check_tasks(title=Dashboard.title, project=project) if exists: incomplete = Tasks.query.filter_by(complete=False, project=project).all() complete = Tasks.query.filter_by(complete=True, project=project).all() return render_template('task.html', project=project, incomplete=incomplete, complete=complete) else: abort(404)
def createTask(): if not request.json: abort(400) task = Tasks(title=request.json['title'], description=request.json.get('description', ""), scheduledDateTime=dateutil.parser.parse( request.json.get('scheduledDateTime', ""))) db.session.add(task) db.session.commit() return jsonify({'task': [make_public_task(task)]}), 201
def test_db_modal_read(session): """test db reads""" mentor = Mentors(mentor_name='test123mentor', mentor_email='*****@*****.**') mentee1 = Mentees(mentee_email='test123mentee.com') mentee2 = Mentees(mentee_email='test456mentee.com') mentor.mentee.append(mentee1) mentor.mentee.append(mentee2) session.add_all([mentor]) session.commit() task1 = Tasks(task='task 1', mentee_id=mentee1.id) task2 = Tasks(task='task 2', mentee_id=mentee2.id) session.add_all([task1, task2]) session.commit() mentors_var = Mentors.query.all() # one row in mentors table assert len(mentors_var) == 1 mentees_var = Mentees.query.all() # two row in mentees table assert (len(mentees_var)) == 2 mentor_to_check = mentors_var[0] assert mentor_to_check.mentor_name == 'test123mentor' and mentor_to_check.id > 0 assert len(mentor_to_check.mentee) == 2 assert mentor_to_check.mentee[0].mentee_email == 'test123mentee.com' \ and mentor_to_check.mentee[1].mentee_email == 'test456mentee.com' tasks_var = Tasks.query.all() assert len(tasks_var) == 2 for task in tasks_var: assert task.mentee_id > 0
def add_task(): print(request.args.get('title')) print(request.args.get('data')) title = request.args.get('title') data = request.args.get('data') priority = request.args.get('priority') user_id = request.args.get('userId') task = Tasks(title=title, data=data, priority=priority, userId=user_id) db.session.add(task) db.session.commit() return "Data Added"
def task_add(site): # Функция постановки задачи status = False try: status = requests.get(site, timeout=10).status_code except: pass if status: t = Tasks(address=site, timestamp=datetime.now(), task_status=TaskStatus.NOT_STARTED, http_status=status) else: t = Tasks(address=site, timestamp=datetime.now(), task_status=TaskStatus.NOT_STARTED, http_status=0) db.session.add(t) db.session.commit() task_do.delay(t.id, checked_word)
def addtask(): Taskform = TaskForm() if Taskform.is_submitted(): dt = Taskform.taskdate.data if dt < datetime.date(datetime.today()): return jsonify({'Error' : 'Can not add task for past' }) task = Tasks(user = current_user,text = Taskform.text.data, date = dt,category = Taskform.category.data) db.session.add(task) db.session.commit() return jsonify({'Success' : 'Task Added to your calender','id' : task.id }) return jsonify({'Error' : 'Something Went Wrong, Try Again!','id' : task.id })
def test_send_mail_driver(session): """to test this function, it is sufficient to verify that right number of emails are staged for sending""" mentor1 = Mentors(mentor_name='test1mentor', mentor_email='*****@*****.**') mentor2 = Mentors(mentor_name='test2mentor', mentor_email='*****@*****.**') mentor3 = Mentors(mentor_name='test3mentor', mentor_email='*****@*****.**') mentee1 = Mentees(mentee_email='test123mentee.com') mentee2 = Mentees(mentee_email='test456mentee.com') mentor1.mentee.append(mentee1) mentor2.mentee.append(mentee2) mentor3.mentee.append(mentee1) mentor3.mentee.append(mentee2) session.add_all([mentor1, mentor2, mentor3]) session.commit() task1 = Tasks(task='task 1', mentee_id=mentee1.id) task2 = Tasks(task='task 2', mentee_id=mentee2.id) task3 = Tasks(task='task 3', mentee_id=mentee2.id) session.add_all([task1, task2, task3]) session.commit() email_count = send_email_driver( is_test=True) # set is_test=True to not send an actual email # mentor1 - 1 # mentor2 - 1 # mentor3 - 2 # total emails to send - 4 assert email_count == 4
def home(): print(session['user']) id_user = session['user']['_id'] tasks = list() db_tasks = Tasks.by_team_leader(id_user) for task in db_tasks: data_task = { 'managers': task.managers, 'date': task.date_task, 'id_tasks': task.id_tasks } tasks.append(data_task) return render_template("home_team_leader.html", tasks=tasks)
def tasks(): db_tasks: Tasks = Tasks.by_all() tasks = list() # Recolectar todas las tareas for task in db_tasks: format_task = { '_id': task.id_task, 'team_leader': task.id_team_leader, 'managers': task.managers, 'date': task.date_task } tasks.append(format_task) return render_template('tasks_admin.html', tasks=tasks, form=CreateTask())
def test_db_modal_create(session): """test db create""" mentor = Mentors(mentor_name='test123mentor', mentor_email='*****@*****.**') mentee = Mentees(mentee_email='test123mentee.com') mentor.mentee.append(mentee) session.add_all([mentor]) session.commit() task = Tasks(task='this is a test task', mentee_id=mentee.id) session.add(task) session.commit() assert mentor and mentee and task in session
def add_tasks(): form = CreateTask() # Obtener datos del formulario team_leader = int(form.team_leader.data) managers = str(form.manager.data).split(';') date = form.date.data # Crear modelo de las tareas a guardar id_team_leader = Users.by_username(team_leader) for manager in managers: manager = int(manager) task: Tasks = Tasks(manager, date, id_team_leader.id_users) # Guardar tarea task.save() flash('Se agrego la tarea', 'alert-success') return redirect(url_for('admin.tasks'))
def search(): if request.method == 'POST': title = request.form['Search'] todos = Tasks.find_task(title=title) exist = todos is not None if exist: found_list = True return render_template('dashboard.html', todos=todos, found_list=found_list) else: found_list = False return render_template('dashboard.html', todos=todos, found_list=found_list) else: todos = Dashboard.query.filter_by(title=title).first() return render_template('dashboard.html', todos=todos, found_list=found_list)
def get(self, name): return Tasks.getConnectorTasks(name)
def get(self, name, id): return Tasks.getConnectorTasksStatus(name, id)
def add_task_image(url): t = Tasks(task_type=1, url=url, status='added') db.session.add(t) db.session.commit() return jsonify(str(t)), 201
def delete_task(id: uuid.UUID): Tasks.delete(id) return redirect(url_for('home'))
def incomplete(sno, project): todo = Tasks.query.filter_by(sno=sno).first() todo.complete = False Tasks.task_completed(todo) return redirect(url_for('tasks', project=project))
def post(self, name, id): return Tasks.postConnectorTaskRestart(name, id)
def remove(sno): todo_list = Dashboard.query.filter_by(sno=sno).first() Tasks.remove_task(todo_list=todo_list) return redirect(url_for('dashboard'))
def delete(sno, project): todo = Tasks.query.filter_by(sno=sno).first() Tasks.remove_task(todo) return redirect(url_for('tasks', project=project))
def delete_task(id: uuid.UUID): task: Tasks = Tasks.by_id(id) task.delete() flash('Se elimino la tarea', 'alert-success') return redirect(url_for('admin.tasks'))
def test_task_date(self): t = Tasks(task_name='Idont know unittest',date=datetime.utcnow()) self.assertFalse(t.date_time_now())
def post(self): task = Tasks.from_json(request.json) task.author = g.user db.session.add(task) db.session.commit() return task.to_json()