def create_task(): form = CreateTaskForm() if form.validate_on_submit(): new_task = Task(name=form.name.data, description=form.description.data, point=form.point.data, flag=form.flag.data, is_open=form.is_open.data) db.session.add(new_task) db.session.commit() flash('Task created successfully.', category='success') return redirect(url_for('admin')) return render_template('create_task.html', form=form)
def add_new_task(): form = CreateTaskForm(current_status="Open") if form.validate_on_submit(): new_task = Task(task_name=form.taskname.data, task_details=form.taskdescription.data, current_status=form.taskstatus.data, open_date=date.today(), due_date=form.due_date.data, owner=current_user) db.session.add(new_task) db.session.commit() return redirect(url_for("myTasks")) return render_template("newtask.html", form=form, current_user=current_user)
def post(self, request, *args, **kwargs): form = CreateTaskForm(request.POST) if form.is_valid(): new_task = form.save(commit=False) new_task.creator = request.user new_task.created = datetime.now() new_task.progress = 0 new_task.comment_count = 0 new_task.save() messages.info(request, "Your task has been added") return HttpResponseRedirect(reverse('taskdetail', args=[new_task.created.year, new_task.created.month, new_task.created.day, new_task.slug])) return render(request, 'create-task.html', { 'form': form, })
def home_view(request): current_user = request.user message = None activity_feeds = get_activity_feeds(request.user.id) if request.method == 'POST' and 'create-task-btn' in request.POST: create_task_form = CreateTaskForm(data=request.POST) if create_task_form.is_valid(): task_form = create_task_form.save(commit=False) task_form.user_id = request.user.id task_form.save() message = "Task created successfully" task_name = request.POST.get('task_name') update_activity_feeds(request.user.id, task_name, "you created task ") activity_feeds = get_activity_feeds(request.user.id) return render(request, 'home.html', {'username': current_user.username, 'message': message, 'activity_feeds': activity_feeds})
def create_task(): user = g.user form = CreateTaskForm() print 'form:', request.form if form.validate_on_submit(): print 'ok' # Check the task doesn't already exist task = Task(name=form.name.data, start_date=form.start_date.data, end_date=form.end_date.data, info=form.info.data) db.session.add(task) db.session.commit() flash('created task %s' % form.name.data) return redirect(url_for('index')) return render_template('index.html', title='Index', user=user, form=form)
def project(id): flash("test flash") project = Project.query.filter_by(id=id).first() meta = db.metadata.tables.keys() form = CreateTaskForm() g.project = project return render_template('project.html', title=project.name, project=project, meta=meta, form=form)
def index(): flash("test flash") user = g.user projects = Project.query.all() meta = db.metadata.tables.keys() form = CreateTaskForm() return render_template('index.html', title='Index', user=user, projects=projects, meta=meta, form=form)
def create_task(): form = CreateTaskForm() return render_template('create_task.html', form=form)