def scheme_form(user_id): email = session['email'] if email is not None: if request.method == 'GET': user = User.get_by_id(user_id) return render_template('add_scheme.html', user=user) else: user = User.get_by_id(user_id) scheme_group_name = request.form['schemegroupname'] scheme_name = request.form['schemename'] work_group_name = request.form['workgroupname'] work_type = request.form['worktype'] scheme = Scheme(scheme_group_name=scheme_group_name, scheme_name=scheme_name, work_group_name=work_group_name, work_type=work_type) scheme.save_to_mongo() if user.designation == 'HQ Staff': return render_template('application_added.html', scheme=scheme, user=user) else: return render_template('application_added_blocks.html', scheme=scheme, user=user) else: return render_template('login_fail.html')
def user_blogs(user_id): if user_id is not None: user = User.get_by_id(user_id) else: user = User.get_by_email(session['email']) blogs = user.get_blogs() return render_template("user_blogs.html", blogs=blogs)
def work_form(user_id): email = session['email'] if email is not None: if request.method == 'GET': user = User.get_by_id(user_id) return render_template('add_work.html', user=user) else: user = User.get_by_id(user_id) amount = request.form['amount'] block = request.form['Blocks'] panchayat = request.form['panchayat'] habitation = request.form['habitation'] total_stages = int(request.form['totalstages']) start_date = request.form['startdate'] end_date = request.form['enddate'] work_name = request.form['workname'] scheme_group_name = request.form['schemegroupname'] scheme_name = request.form['schemename'] work_group_name = request.form['workgroupname'] work_type = request.form['worktype'] work_id_custom = request.form['workIdCustom'] user_id = user_id user_name = user.username work = Work(amount=amount, block=block, scheme_group_name=scheme_group_name, scheme_name=scheme_name, work_group_name=work_group_name, work_type=work_type, panchayat=panchayat, habitation=habitation, total_stages=total_stages, start_date=start_date, user_id=user_id, user_name=user_name, work_status="Open", work_name=work_name, end_date=end_date, work_id_custom=work_id_custom) work.save_to_mongo() print(total_stages) for i in range(int(total_stages)): print(total_stages) stage_name_string = "sn" + str(i) stage_amount_string = "sa" + str(i) stage_order_id_string = "soi" + str(i) stage_start_date_string = "ssd" + str(i) stage_end_date_string = "sed" + str(i) stage_name = request.form[stage_name_string] stage_amount = request.form[stage_amount_string] stage_order_id = request.form[stage_order_id_string] stage_start_date = request.form[stage_start_date_string] stage_end_date = request.form[stage_end_date_string] work_id = work.work_id application = Stage(stage_name=stage_name, start_date=stage_start_date, end_date=stage_end_date, amount=stage_amount, total_stages=total_stages, work_name=work_name, user_name=user_name, user_id=user_id, stage_order_id=stage_order_id, work_id=work_id) application.save_to_mongo() if user.designation == 'HQ Staff': return render_template('application_added.html', work=work, user=user) else: return render_template('application_added_blocks.html', work=work, user=user) else: return render_template('login_fail.html')