def new_task(): error = [] form = AddTaskForm(flask.request.form) print(flask.request.form) if flask.request.method == "POST": if form.validate_on_submit(): new_task = Task( form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), "1", flask.session["user_id"] ) db.session.add(new_task) db.session.commit() flask.flash("New entry was successfully posted.") return flask.redirect(flask.url_for("tasks")) else: error.append("There was an error with the task data. Make sure all fields are filled in.") return flask.render_template( "tasks.html", form = form, error = error, open_tasks = open_tasks(), closed_tasks = closed_tasks() )
def new_task(): error = None form = AddTaskForm(request.form) # g.db = connect_db() # name = request.form['name'] # due_date = request.form['due_date'] # priority = request.form['priority'] # if not name or not due_date or not priority: # flash("All fields are required. Please try again!") # return redirect(url_for('tasks')) # else: # g.db.execute("""insert into tasks (name, due_date, priority, status) values (?,?,?,1)""", # [request.form['name'],request.form['due_date'],request.form['priority']]) # g.db.commit() # g.db.close() if request.method == 'POST': if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data,'1', session['user_id'],datetime.utcnow()) db.session.add(new_task) db.session.commit() flash("New entry was successfully posted. Thanks!") else: # flash('All fields are required!') return render_template('tasks.html', form=form, error=error) return render_template('tasks.html', form=form, error=error, open_tasks=open_tasks(), closed_tasks=closed_tasks())
def add_task(): task_id = request.args.get('tid') ori_task = Task.query.filter(Task.id == task_id).first() form = AddTaskForm() if ori_task: form = AddTaskForm(name=ori_task.name, key=ori_task.redis_key, ctime=ori_task.start_time) if request.method == 'POST' and form.validate(): tid = request.values.get('tid') str_key = form.key.data task = Task(form.name.data, str_key, form.ctime.data) if tid: # update tsObj = Task.query.filter(Task.id == tid).first() ori_str_key = tsObj.redis_key rd.delete(ori_str_key) tsObj.redis_key = str_key tsObj.name = form.name.data tsObj.start_time = form.ctime.data db.session.commit() else: db.session.add(task) rd.setex(str_key, 1, task.seconds) return redirect('/') return render_template('add.html', form=form)
def new_task(): error = None form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task( form.name.data, form.due_date.data, form.priority.data, '1', datetime.datetime.utcnow(), session['user_id'] # add user session into the database ) # Add the data in the session when creating new instance # When updating or delete, no need to do session.add db.session.add(new_task) db.session.commit() flash('New entry created!') return redirect(url_for('tasks')) # If the request is GET return render_template( 'tasks.html', form=form, error=error, open_tasks=open_tasks(), closed_tasks=closed_tasks() )
def new_task(): error = None form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task( form.name.data, session['user_id'], form.due_date.data, form.priority.data, '1', datetime.datetime.utcnow() ) db.session.add(new_task) db.session.commit() flash("New entry was successfully posted. Thanks.") return redirect(url_for('tasks')) else: return render_template( 'tasks.html', form=form, error=error, open_tasks=open_tasks(), closed_tasks=closed_tasks() ) else: return render_template( 'tasks.html', form=form, error=error, open_tasks=open_tasks(), closed_tasks=closed_tasks() )
def edit_task(taskid): task = Task.query.filter_by(id=taskid, user_id=current_user.id).first() if not task: return redirect(url_for('index')) categories = Category.query.filter_by(user_id=current_user.id).all() items = [c.name for c in categories] form = AddTaskForm(items) if form.validate_on_submit(): if form.category.data.lower( ) != task.category.name or form.task.data.lower() != task.name: c = Category.query.filter_by( user_id=current_user.id, name=form.category.data.lower()).first() if c: tasks = [task.name for task in c.tasks] if form.task.data.lower() in tasks: flash('Task ' + form.task.data + ' already exists', 'warning') return redirect(url_for('edit_task', taskid=taskid)) task.name = form.task.data.lower() task.category_id = Category.query.filter_by( user_id=current_user.id, name=form.category.data.lower()).first().id task.deadline = datetime.strptime(form.deadline.data, '%Y/%m/%d') task.priority = form.priority.data db.session.commit() flash('Task edited', 'info') return redirect(url_for('index')) return render_template('task.html', title='Edit Task', form=form)
def new_task(): error = None form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task( form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), '1', session['user_id'] ) db.session.add(new_task) db.session.commit() flash('New entry was successfully posted. Thanks') return redirect(url_for('tasks.tasks')) else: open_tasks = db.session.query(Task) \ .filter_by(status='1').order_by(Task.due_date.asc()) closed_tasks = db.session.query(Task) \ .filter_by(status='0').order_by(Task.due_date.asc()) return render_template('tasks.html', form=form, error=error, open_tasks = open_tasks, closed_tasks = closed_tasks)
def add_task(): if 'username' not in session: return redirect('/login') form = AddTaskForm() form.user.choices = [(i.id, i.name) for i in db.session.query(UsersModel)] name = form.name.data desc = form.desc.data priority = form.priority.data user = form.user.data date = form.date.data if form.validate_on_submit(): task = TasksModel(name=name, desc=desc, author=session['user_id'], date=date, priority=priority, user=user) db.session.add(task) db.session.commit() return redirect('/') admin = db.session.query(UsersModel).filter_by( id=session['user_id']).first().admin return render_template('add_tasks.html', username=session['username'], form=form, name='', desc='', admin=admin)
def add_taskid(id): if 'username' not in session: return redirect('/login') form = AddTaskForm() form.user.choices = [(i.id, i.name) for i in db.session.query(UsersModel)] task = db.session.query(TasksModel).filter_by(id=id).first() if task: namey = task.name descy = task.desc else: return redirect('/') name = form.name.data desc = form.desc.data priority = form.priority.data user = form.user.data date = form.date.data if form.validate_on_submit(): task.name = name task.desc = desc task.priority = priority task.date = date task.user = user db.session.commit() return redirect('/') admin = db.session.query(UsersModel).filter_by( id=session['user_id']).first().admin return render_template('add_tasks.html', username=session['username'], form=form, name=namey, desc=descy, admin=admin)
def add(): """g.db = connect_db() name = request.form['name'] due_date = request.form['due_date'] priority = request.form['priority'] if not name or not due_date or not priority: flash("Please fill all the fields") return redirect(url_for('tasks')) else: #g.db.execute("INSERT INTO tasks(name, due_date, priority, status) VALUES(?, ?, ?, 1)",[request.form['name'],request.form['due_date'],request.form['priority']]) #g.db.commit() #g.db.close() flash("Your entry was successfully admitted") return redirect(url_for('tasks'))""" form = AddTaskForm(request.form) if request.method == "POST": if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, "1", session["user_id"]) db.session.add(new_task) db.session.commit() flash("New entry was successfully posted. Thanks.") return redirect(url_for("tasks.tasks")) else: return render_template("tasks.html", form=form, error=error) return render_template("tasks.html", form=form, error=error, open_tasks=open_tasks(), closed_tasks=closed_tasks())
def add(): form = AddTaskForm() if form.validate_on_submit(): db.session.add(Task(title=form.title.data, date=datetime.utcnow())) db.session.commit() flash('Task added to database') return redirect(url_for('index')) return render_template('add.html', form=form)
def new_task(): form = AddTaskForm(request.form) if request.method == "POST": if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, "1") db.session.add(new_task) db.session.commit() flash("New entry was susccessfully posted Thanks.") return redirect(url_for("tasks"))
def new_task(): form = AddTaskForm(request.form) if request.method == "POST": if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, 1) db.session.add(new_task) db.session.commit() flash("New task has been added") return redirect(url_for("tasks"))
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, '1') db.session.add(new_task) db.session.commit() flash('New entry was successfully posted. Thanks') return redirect(url_for('tasks'))
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, '1') db.session.add(new_task) db.session.commit() flash('New entry was successfully posted. Thanks.') return redirect(url_for('tasks'))
def add_task(): form = AddTaskForm() if form.validate_on_submit(): flash(f'Task Successfully Added for {form.taskID.data}!', 'success') task = Task(id=form.taskID.data, taskname=form.taskName.data, taskdesc=form.taskDetails.data) db.session.add(task) db.session.commit() return redirect(url_for('add_task')) return render_template('addTask.html', title='Add Task', form=form)
def add(): add_form = AddTaskForm() if add_form.validate_on_submit(): task = Task(title=add_form.title.data, date=datetime.utcnow()) db.session.add(task) db.session.commit() flash('Task created successfully!') return redirect(url_for('index')) else: return render_template('add.html', form=add_form)
def new_task(): error = None form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), '1', session['user_id']) db.session.add(new_task) db.session.commit() flash('New entry was succesfully posted. Thanks.') return redirect(url_for('tasks')) return render_template('tasks.html', form=form, error=error, open_tasks=open_tasks(), closed_tasks=closed_tasks())
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), '1', '1') db.session.add(new_task) db.session.commit() flash('New entry posted! Do it, Doug!') return redirect(url_for('tasks'))
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, '1') db.session.add(new_task) db.session.commit() flash('Nueva tarea fue agragada con exito') else: flash('Por favor, agregue datos validos') return redirect(url_for('tasks'))
def add_task(request): if request.method == 'POST': form = AddTaskForm(data=request.POST) if form.is_valid(): new_task = form.save(commit=False) new_task.author = request.user new_task.save() return HttpResponseRedirect(new_task.get_absolute_url()) else: form = AddTaskForm() return render_to_response('timetracker/add_task.html', {'form': form}, context_instance = RequestContext(request))
def new_task(): form = AddTaskForm(request.form) if request.method == "POST": if form.validate_on_submit() or True: new_task = Task(name=form.name.data, due_date=form.due_date.data, priority=form.priority.data, status='1', posted_date=datetime.datetime.utcnow(), user_id=session['user_id']) db.session.add(new_task) db.session.commit() return redirect(url_for('tasks'))
def addtask(request): form = AddTaskForm(request.POST) if request.user.is_authenticated(): if form.is_valid(): list = request.user.list_set.filter(listname=form.cleaned_data['list']) if not list: return HttpResponse("list name not found", status=400) newtask = form.save() return HttpResponse(json.dumps([])) else: return HttpResponse("form validation failed" + str(form.errors), status=400) else: return HttpResponse("Url is only available to logged in users", status=401)
def add_task(v_id): form = AddTaskForm() vehicle = Vehicle.query.get(v_id) if form.validate_on_submit(): name = request.form['name'] string_date = request.form['date'] date = datetime.strptime(string_date, '%Y-%m-%d') mileage = request.form['mileage'] task = Task(name=name, date=date, mileage=mileage, vehicle_id=v_id) db.session.add(task) db.session.commit() return redirect(url_for('vehicle_detail', v_id=vehicle.id)) return render_template("add_task.html", vehicle=vehicle, form=form)
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_user = User( form.username.data, form.ip_phone.data, form.ip_phone_type.data, '1' ) db.session.add(new_user) db.session.commit() flash('New entry was successfully posted. Thanks.') return redirect(url_for('tasks'))
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): # something to look into new_task = models.Task( form.name.data, form.due_date.data, form.priority.data, '1' ) db.session.add(new_task) db.session.commit() flash('New Entry Added Successfully') return redirect(url_for('tasks'))
def tasks(request, project_pk=None): completed_task_list = Task.objects.for_user(request.user).filter(completed=True).order_by('-completion_date') pending_task_list = Task.objects.for_user(request.user).filter(completed=False) project_list = Project.objects.for_user(request.user).filter(completed=False) if not project_pk and 'tasks_latest_project_pk' in request.session: #print reverse('view-tasks', int(request.session['tasks_latest_project_pk'])) return HttpResponseRedirect("/tasks/%s/" % request.session['tasks_latest_project_pk']) elif project_pk == 'all': project_pk = None if project_pk: project = get_object_or_404(Project, pk=project_pk) completed_task_list = completed_task_list.filter(project=project) pending_task_list = pending_task_list.filter(project=project) initial = {'project': project.pk} request.session['tasks_latest_project_pk'] = project.pk else: project = None initial = {} TaskListFormSet = modelformset_factory(Task, fields=('completed',), extra=0) if request.POST and 'task_list-INITIAL_FORMS' in request.POST: task_list_formset = TaskListFormSet(request.POST, queryset=pending_task_list, prefix='task_list') if task_list_formset.is_valid(): task_list_formset.save() return HttpResponseRedirect(request.path_info) else: task_list_formset = TaskListFormSet(queryset=pending_task_list, prefix='task_list') if request.POST and 'addtask-task' in request.POST: task_form = AddTaskForm(request.POST, prefix='addtask') if task_form.is_valid(): task = task_form.save() return HttpResponseRedirect(request.path_info) else: task_form = AddTaskForm(prefix='addtask', initial=initial) data = { 'project': project, 'completed_task_list': completed_task_list, 'project_list': project_list, 'task_form': task_form, 'task_list_formset': task_list_formset, } return render_to_response('projectmanager/tasks.html', data)
def new_task(): form = AddTaskForm(request.form) if request.method == "POST": if form.validate_on_submit() or True: new_task = Task( name = form.name.data, due_date = form.due_date.data, priority = form.priority.data, status = '1', posted_date = datetime.datetime.utcnow(), user_id = session['user_id'] ) db.session.add(new_task) db.session.commit() return redirect(url_for('tasks'))
def new_task(): import datetime form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), "1", session['user_id']) db.session.add(new_task) db.session.commit() flash("New entry was successfully posted. Thanks.") return redirect(url_for('tasks')) else: flash("Fields contain unappropriated values") return redirect(url_for('tasks'))
def new_task(): import datetime form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), '1', session['user_id']) db.session.add(new_task) db.session.commit() flash('New entry was successfully posted. Thanks.') else: flash('Invalid Entry. Please try again.') return redirect(url_for('tasks.tasks'))
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, datatime.datatime, utcnow(), '1', session['user_id']) db.session.add(new_task) db.session.commit() flash('New entry was successfully posted.Thanks.') return redirect(url_for('tasks')) else: flash('All fields are required.') return redirect(url_for('tasks')) return render_template('tasks.html', form=form)
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task( form.name.data, form.due_date.data, form.priority.data, '1' ) db.session.add(new_task) db.session.commit() flash('Nueva tarea fue agragada con exito') else: flash('Por favor, agregue datos validos') return redirect(url_for('tasks'))
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): task = Task({ "name": form.name.data, "due_date": form.due_date.data, "priority": form.priority.data, "posted_at": datetime.utcnow(), "user_id": session['user_id'], "status": 1 }) db.session.add(task) db.session.commit() flash("New entry was successfully posted.") return redirect(url_for('tasks'))
def tasks(): open_tasks = db.session.query(Task).filter_by(status='1').order_by(Task.due_date.asc()) closed_tasks = db.session.query(Task).filter_by(status='0').order_by(Task.due_date.asc()) return render_template('tasks.html', open_tasks=open_tasks, closed_tasks=closed_tasks, form=AddTaskForm(request.form))
def tasks(): open_tasks_var = open_tasks() closed_tasks_var = closed_tasks() return render_template('tasks.html', form=AddTaskForm(request.form), open_tasks=open_tasks_var, closed_tasks=closed_tasks_var)
def tasks(): # display some information to the user # using class AddTaskForm created in forms.py (our file) return render_template('tasks.html', form=AddTaskForm(request.form), open_tasks=open_tasks(), closed_tasks=closed_tasks())
def tasks(): """g.db = db_connect() cursor = g.db.execute( 'SELECT name, due_date, priority, task_id from tasks where status = 1 ORDER BY priority') open_tasks = [ dict(name=row[0], due_date=row[1], priority=row[2], task_id=row[3]) for row in cursor.fetchall()]""" open_tasks = db.session.query(Task) \ .filter_by(status=1).order_by(Task.due_date.asc()) """cursor = g.db.execute( 'SELECT name, due_date, priority, task_id from tasks where status = 0') closed_tasks = [ dict(name=row[0], due_date=row[1], priority=row[2], task_id=row[3]) for row in cursor.fetchall()]""" closed_tasks = db.session.query(Task) \ .filter_by(status=0).order_by(Task.due_date.asc()) #g.db.close() return render_template('tasks.html', form=AddTaskForm(request.form), open_tasks=open_tasks, closed_tasks=closed_tasks)
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, '1') db.session.add(new_task) db.session.commit() flash('New task was successfully added.') return redirect(url_for('tasks')) else: flash('All fields are required.') flash(form.validate_on_submit()) return redirect(url_for('tasks')) return redirect(url_for('tasks'))
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task( form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), '1', '1' ) db.session.add(new_task) db.session.commit() flash('New entry posted! Do it, Doug!') return redirect(url_for('tasks'))
def tasks(): g.db = connect_db() cursor = g.db.execute( 'select name, due_date, priority, task_id from tasks where status=1') open_tasks = [ dict(name=row[0], due_date=row[1], priority=row[2], task_id=row[3]) for row in cursor.fetchall() ] cursor = g.db.execute( 'select name, due_date, priority, task_id from tasks where status=0') closed_tasks = [ dict(name=row[0], due_date=row[1], priority=row[2], task_id=row[3]) for row in cursor.fetchall() ] g.db.close() return render_template('tasks.html', form=AddTaskForm(request.form), open_tasks=open_tasks, closed_tasks=closed_tasks)
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task(form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), '1', session["user_id"]) db.session.add(new_task) db.session.commit() flash("New entry was successfully posted, Thanks.") else: flash("Wrong input field, abort posting task.") return redirect(url_for('tasks'))
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task( form.name.data, form.due_date.data, form.priority.data, '1' ) db.session.add(new_task) db.session.commit() flash('Nu entry dun dun dun. Well done.') else: flash('did not validate') return redirect(url_for('tasks'))
def tasks(): g.db = connect_db() cursor = g.db.execute('SELECT name, due_date, priority, task_id FROM tasks WHERE STATUS=1') open_tasks = [dict(name=row[0], due_date=row[1], priority=row[2], task_id=row[3]) for row in cursor.fetchall()] cursor = g.db.execute('SELECT name, due_date, priority, task_id FROM tasks WHERE STATUS=0') closed_tasks = [dict(name=row[0], due_date=row[1], priority=row[2], task_id=row[3]) for row in cursor.fetchall()] return render_template('tasks.html', open_tasks=open_tasks, closed_tasks=closed_tasks, form=AddTaskForm(request.form))
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): print(form.errors) new_task = Task( form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), '1', session['user_id'] ) db.session.add(new_task) db.session.commit() flash('New entry was successfully posted. Thanks.') return redirect(url_for('tasks'))
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task( form.name.data, form.due_date.data, form.priority.data, '1' ) db.session.add(new_task) db.session.commit() flash('Nova tarefa adicionada.') else: flash('Todos os campos sao necessarios') return redirect(url_for('tasks')) return redirect(url_for('tasks'))
def new_task(): form = AddTaskForm(request.form) if request.method == "POST": if form.validate_on_submit(): new_task = Task( form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), '1', session['user_id'] ) db.session.add(new_task) db.session.commit() flash("Entry added successfully") else: flash_errors(form) return redirect(url_for('tasks'))
def new_task(): error = None form = AddTaskForm(request.form) # validate_on_submit takes care that form is submitted only on POST if request.method == 'POST': if form.validate_on_submit(): db.session.add( Task(form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), 1, session['user_id']) ) # Every task is mapped to usr_id 1 temporarily db.session.commit() flash('New task was successfully created.') return redirect(url_for('tasks')) return render_template('tasks.html', form=form, error=error, open_tasks=open_tasks(), closed_tasks=closed_tasks())
def add_task(): form = AddTaskForm() if request.method == "POST": if form.validate() == False: return render_template("addtask.html", form=form) else: max_id = max(d['id'] for d in tasks) max_id = int(max_id) + 1 newtask = { 'id': str(max_id), 'title': str(form.title.data), 'description': str(form.description.data), 'done': str(form.done.data) } tasks.append(newtask) return jsonify({'tasks': tasks}) elif request.method == "GET": return render_template("addtask.html", title="Add new task", form=form)
def tasks(): g.db = connect_db() cursor = g.db.cursor() cursor.execute("SELECT name, due_date, priority, task_id FROM tasks WHERE status=1") open_tasks = [dict(name=row[0], due_date=row[1], priority=row[2], task_id=row[3]) for row in cursor.fetchall()] cursor.execute("SELECT name, due_date, priority, task_id FROM tasks WHERE status=0") closed_tasks = [dict(name=row[0], due_date=row[1], priority=row[2], task_id=row[3]) for row in cursor.fetchall()] g.db.close() return render_template('tasks.html', form=AddTaskForm(request.form), open_tasks=open_tasks, closed_tasks=closed_tasks)\
def edit(task_id): task = Task.query.get(task_id) edit_form = AddTaskForm() if task: if edit_form.validate_on_submit(): task.title = edit_form.title.data task.date = datetime.utcnow() db.session.commit() flash('Task updated successfully!') return redirect(url_for('index')) else: edit_form.title.data = task.title return render_template('edit.html', form=edit_form, task_id=task_id) else: flash('Task not found!') return redirect(url_for('index'))
def new_task(): from datetime import datetime error = None form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task( form.name.data, form.content.data, form.due_date.data, form.priority.data, datetime.utcnow(), '1', session['user_id']) db.session.add(new_task) db.session.commit() flash('New entry was successfully posted. Thanks.') return redirect(url_for('tasks.tasks')) else: return render_template('tasks.html', form=form, error=error)
def new_task(): form = AddTaskForm(request.form) if request.method == "POST": if form.validate_on_submit(): new_task = Task( form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), "1", session["user_id"], ) db.session.add(new_task) db.session.commit() flash("New entry was successfully posted. Thanks.") return redirect(url_for("tasks")) else: flash("All fields are required.") return redirect(url_for("tasks")) return render_template("tasks.html", form=form)
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task( form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), '1', session['user_id'] ) db.session.add(new_task) db.session.commit() flash('New Entry was successfully posted. Thanks.') return redirect(url_for('tasks')) else: flash('All fields are required.') return redirect(url_for('tasks')) return render_template('tasks.html', form=form)
def new_task(): error = None form = AddTaskForm(request.form) if request.method == "POST": if form.validate_on_submit(): new_task = Task( form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), "1", session["user_id"], ) db.session.add(new_task) db.session.commit() flash("New entry was successfully posted. Thanks.") return redirect(url_for("tasks")) # else: # flash('All fieds are required.') # return render_template(url_for('tasks.html', form=form,error=error)) return render_template("tasks.html", form=form, error=error, open_tasks=open_tasks(), closed_tasks=closed_tasks())
def new_task(): form = AddTaskForm(request.form) if request.method == 'POST': if form.validate_on_submit(): new_task = Task( form.TaskName.data, form.TaskDueDate.data, form.TaskPriority.data, datetime.datetime.utcnow(), '1', session['user_id'] ) print(new_task) db.session.add(new_task) db.session.commit() flash('New entry was successfully posted. Thanks.') else: flash('Please use proper Date Format') return redirect(url_for('tasks')) ###### Depricated SQLite3 ############ '''
def new_task(): error = None form = AddTaskForm(flask.request.form) if flask.request.method == "POST": if form.validate_on_submit(): db.session.add( Task( form.name.data, form.due_date.data, form.priority.data, datetime.datetime.utcnow(), flask.session["user_id"], "1", ) ) db.session.commit() flask.flash("New entry was successfully posted. Thanks!") return flask.redirect(flask.url_for("tasks")) else: return flask.render_template("tasks.html", form=form, error=error) return flask.render_template("tasks.html", form=form, error=error)
def new_task(): form = AddTaskForm(request.form) error = None if form.validate_on_submit(): new_task = Task( form.name.data, form.due_date.data, form.priority.data, datetime.datetime.now(), '1', session['user_id'] ) db.session.add(new_task) db.session.commit() flash('New entry was successfully posted. Thanks.') else: return render_template('tasks.html', form = form, error = error, open_tasks = find_open_tasks(), closed_tasks = find_closed_tasks()) return redirect(url_for('tasks'))