Ejemplo n.º 1
0
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()})
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
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)
Ejemplo n.º 4
0
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')
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
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)
Ejemplo n.º 7
0
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
Ejemplo n.º 8
0
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
Ejemplo n.º 9
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"
Ejemplo n.º 10
0
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)
Ejemplo n.º 11
0
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 })
Ejemplo n.º 12
0
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
Ejemplo n.º 13
0
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)
Ejemplo n.º 14
0
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())
Ejemplo n.º 15
0
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
Ejemplo n.º 16
0
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'))
Ejemplo n.º 17
0
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)
Ejemplo n.º 18
0
 def get(self, name):
     return Tasks.getConnectorTasks(name)
Ejemplo n.º 19
0
 def get(self, name, id):
     return Tasks.getConnectorTasksStatus(name, id)
Ejemplo n.º 20
0
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
Ejemplo n.º 21
0
def delete_task(id: uuid.UUID):
    Tasks.delete(id)
    return redirect(url_for('home'))
Ejemplo n.º 22
0
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))
Ejemplo n.º 23
0
 def post(self, name, id):
     return Tasks.postConnectorTaskRestart(name, id)
Ejemplo n.º 24
0
def remove(sno):
    todo_list = Dashboard.query.filter_by(sno=sno).first()
    Tasks.remove_task(todo_list=todo_list)
    return redirect(url_for('dashboard'))
Ejemplo n.º 25
0
def delete(sno, project):
    todo = Tasks.query.filter_by(sno=sno).first()
    Tasks.remove_task(todo)
    return redirect(url_for('tasks', project=project))
Ejemplo n.º 26
0
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'))
Ejemplo n.º 27
0
	def test_task_date(self):
		t = Tasks(task_name='Idont know unittest',date=datetime.utcnow())
		self.assertFalse(t.date_time_now())
Ejemplo n.º 28
0
 def post(self):
     task = Tasks.from_json(request.json)
     task.author = g.user
     db.session.add(task)
     db.session.commit()
     return task.to_json()