Exemplo n.º 1
0
def login_user():

    email = request.form['email']

    password = request.form['password']

    valid = User.valid_login(email, password)

    User.login(email)

    user = User.get_by_email(email)

    if valid:

        if user.designation == 'HQ Staff':

            return render_template('profile_HQ.html', user=user)

        else:

            return render_template('profile_blocks.html', user=user)

    else:

        return render_template('login_fail.html')
Exemplo n.º 2
0
def Overall_Summary():

    email = session['email']

    user = User.get_by_email(email)

    if email is not None:

        if request.method == 'GET':

            return render_template('between_dates_overall.html', user=user)

        else:

            start_date = request.form['startdate']

            end_date = request.form['enddate']

            return render_template('overall_summary_sheet.html',
                                   user=user,
                                   start_date=start_date,
                                   end_date=end_date)

    else:

        return render_template('login_fail.html', user=user)
Exemplo n.º 3
0
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')
Exemplo n.º 4
0
def view_work_by_blocks():

    email = session['email']

    user = User.get_by_email(email)

    if email is not None:

        return render_template('view_work_by_blocks.html', user=user)

    else:

        return render_template('login_fail.html', user=user)
Exemplo n.º 5
0
def Deadline_violation_stages():

    email = session['email']

    user = User.get_by_email(email)

    if email is not None:

        return render_template('deadline_violation_stages_sheet.html',
                               user=user)

    else:

        return render_template('login_fail.html', user=user)
Exemplo n.º 6
0
def register_user():

    email = request.form['email']

    password = request.form['password']

    username = request.form['username']

    designation = request.form['designation']

    block = request.form['block']

    User.register(email, password, username, designation, block)

    user = User.get_by_email(email)

    if user.designation == 'HQ Staff':

        return render_template('profile_HQ.html', user=user)

    else:

        return render_template('profile_blocks.html', user=user)
Exemplo n.º 7
0
def update_scheme(_id):

    email = session['email']

    if email is not None:

        if request.method == 'GET':

            user = User.get_by_email(email)

            return render_template('update_scheme_form.html',
                                   user=user,
                                   _id=_id)

        else:

            user = User.get_by_email(email)

            scheme_group_name = request.form['schemegroupname']

            scheme_name = request.form['schemename']

            work_group_name = request.form['workgroupname']

            work_type = request.form['worktype']

            Scheme.update_scheme(scheme_group_name=scheme_group_name,
                                 scheme_name=scheme_name,
                                 work_group_name=work_group_name,
                                 work_type=work_type,
                                 _id=_id)

            return render_template('application_added.html', user=user)

    else:

        return render_template('login_fail.html')
Exemplo n.º 8
0
def Block_Summary():

    email = session['email']

    user = User.get_by_email(email)

    if email is not None:

        if request.method == 'GET':

            if user.designation == 'HQ Staff':

                return render_template('between_dates_blockwise.html',
                                       user=user)
            else:

                return render_template('between_dates_blockwise_blocks.html',
                                       user=user)

        else:

            start_date = request.form['startdate']

            end_date = request.form['enddate']

            if user.designation == 'HQ Staff':

                block = request.form['block']

                return render_template('blockwise_summary_sheet.html',
                                       user=user,
                                       start_date=start_date,
                                       end_date=end_date,
                                       block=block)

            else:

                block = user.block

                return render_template('blockwise_summary_sheet_blocks.html',
                                       user=user,
                                       start_date=start_date,
                                       end_date=end_date,
                                       block=block)
    else:

        return render_template('login_fail.html', user=user)
Exemplo n.º 9
0
def profile():

    email = session['email']

    user = User.get_by_email(email)

    if email:

        if user.designation == 'HQ Staff':

            return render_template('profile_HQ.html', user=user)

        else:

            return render_template('profile_blocks.html', user=user)

    else:

        return render_template('login_fail.html')
Exemplo n.º 10
0
def view_stage(work_id):

    email = session['email']

    user = User.get_by_email(email)

    if email is not None:

        if user.designation == 'HQ Staff':

            return render_template('view_stage.html',
                                   user=user,
                                   work_id=work_id)
        else:

            return render_template('view_stage_blocks.html',
                                   user=user,
                                   work_id=work_id)

    else:

        return render_template('login_fail.html', user=user)
Exemplo n.º 11
0
def Deadline_violation_work():

    email = session['email']

    user = User.get_by_email(email)

    if email is not None:

        if user.designation == 'HQ Staff':

            return render_template('deadline_violation_work.html', user=user)
        else:

            block = user.block

            return render_template('deadline_violation_work_blocks.html',
                                   user=user,
                                   block=block)

    else:

        return render_template('login_fail.html', user=user)
Exemplo n.º 12
0
def Scheme_Summary():

    email = session['email']

    user = User.get_by_email(email)

    if email is not None:

        if request.method == 'GET':

            return render_template('between_dates_departmentwise.html',
                                   user=user)

        else:

            start_date = request.form['startdate']

            end_date = request.form['enddate']

            scheme_group_name = request.form['schemegroupname']

            scheme_name = request.form['schemename']

            work_group_name = request.form['workgroupname']

            work_type = request.form['worktype']

            return render_template('departmentwise_summary_sheet.html',
                                   user=user,
                                   start_date=start_date,
                                   end_date=end_date,
                                   scheme_group_name=scheme_group_name,
                                   scheme_name=scheme_name,
                                   work_group_name=work_group_name,
                                   work_type=work_type)
    else:

        return render_template('login_fail.html', user=user)
Exemplo n.º 13
0
def update_stage(_id):

    email = session['email']

    if email is not None:

        if request.method == 'GET':
            user = User.get_by_email(email)
            if user.designation == 'HQ Staff':
                return render_template('update_stage_form.html',
                                       user=user,
                                       _id=_id)

            else:

                return render_template('update_stage_from_blocks.html',
                                       user=user,
                                       _id=_id)

        else:

            user = User.get_by_email(email)

            amount = request.form['amount']

            stage_name = request.form['stagename']

            stage_order_id = request.form['stageorderid']

            total_stages = request.form['totalstages']

            stage_status = request.form['stagestatus']

            start_date = request.form['startdate']

            end_date = request.form['enddate']

            user_id = user._id

            user_name = user.username

            start_date = datetime.combine(
                datetime.strptime(start_date, '%Y-%m-%d').date(),
                datetime.now().time())

            end_date = datetime.combine(
                datetime.strptime(end_date, '%Y-%m-%d').date(),
                datetime.now().time())

            application = Database.find("stages", {"_id": _id})

            work_id = None

            for result_object in application[0:1]:

                work_id = result_object['work_id']

            application = Database.find("stages", {"_id": _id})

            stage_status_old = None

            for result_object in application[0:1]:
                stage_status_old = result_object['stage_status']

            if stage_status_old != stage_status and stage_status == 'Close':

                var = int(stage_order_id) + 1

                print(work_id, var)

                app = Database.find("stages", {
                    "$and": [{
                        "work_id": work_id
                    }, {
                        "stage_order_id": str(var)
                    }]
                })

                stage_second_name = None

                for result_object in app[0:1]:
                    stage_second_name = result_object['stage_name']
                    Work.update_current_stage(work_id=work_id,
                                              stage_name=stage_second_name,
                                              stage_order_id=stage_order_id)

            Stage.update_stage(amount=amount,
                               stage_name=stage_name,
                               stage_order_id=stage_order_id,
                               total_stages=total_stages,
                               start_date=start_date,
                               user_id=user_id,
                               user_name=user_name,
                               _id=_id,
                               work_id=work_id,
                               stage_status=stage_status,
                               end_date=end_date)

            if user.designation == 'HQ Staff':

                return render_template('application_added.html', user=user)

            else:

                return render_template('application_added_blocks.html',
                                       user=user)

    else:

        return render_template('login_fail.html')
Exemplo n.º 14
0
def add_stage(work_id):

    email = session['email']

    if email is not None:

        if request.method == 'GET':

            user = User.get_by_email(email)

            if user.designation == 'HQ Staff':

                return render_template('add_stage.html',
                                       user=user,
                                       work_id=work_id)

            else:

                return render_template('add_stage_blocks.html',
                                       user=user,
                                       work_id=work_id)

        else:

            user = User.get_by_email(email)

            stage_name = request.form['stagename']

            start_date = request.form['startdate']

            end_date = request.form['enddate']

            amount = request.form['amount']

            total_stages = request.form['totalstages']

            stage_order_id = request.form['stageorderid']

            user_id = user._id

            user_name = user.username

            work_id = work_id

            application = Stage(stage_name=stage_name,
                                start_date=start_date,
                                end_date=end_date,
                                amount=amount,
                                total_stages=total_stages,
                                stage_status="Open",
                                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',
                                       application=application,
                                       user=user)

            else:
                return render_template('application_added_blocks.html',
                                       application=application,
                                       user=user)

    else:

        return render_template('login_fail.html')
Exemplo n.º 15
0
def update_work(work_id):

    email = session['email']

    if email is not None:

        if request.method == 'GET':

            user = User.get_by_email(email)

            if user.designation == 'HQ Staff':

                return render_template('update_work_form.html',
                                       user=user,
                                       work_id=work_id)

            else:

                return render_template('update_work_form_blocks.html',
                                       user=user,
                                       work_id=work_id)
        else:

            user = User.get_by_email(email)

            amount = request.form['amount']

            block = request.form['Blocks']

            work_status = request.form['workstatus']

            total_stages = request.form['totalstages']

            start_date = request.form['startdate']

            end_date = request.form['enddate']

            work_name = request.form['workname']

            amount_spent = request.form['amountspent']

            scheme_group_name = request.form['schemegroupname']

            scheme_name = request.form['schemename']

            work_group_name = request.form['workgroupname']

            work_type = request.form['worktype']

            user_id = user._id

            user_name = user.username

            start_date = datetime.combine(
                datetime.strptime(start_date, '%Y-%m-%d').date(),
                datetime.now().time())

            end_date = datetime.combine(
                datetime.strptime(end_date, '%Y-%m-%d').date(),
                datetime.now().time())

            Work.update_work(amount=amount,
                             block=block,
                             amount_spent=amount_spent,
                             scheme_group_name=scheme_group_name,
                             scheme_name=scheme_name,
                             work_group_name=work_group_name,
                             work_type=work_type,
                             total_stages=total_stages,
                             start_date=start_date,
                             user_id=user_id,
                             user_name=user_name,
                             work_id=work_id,
                             work_status=work_status,
                             work_name=work_name,
                             end_date=end_date)

            Stage.update_work_name(work_id=work_id, work_name=work_name)

            if user.designation == 'HQ Staff':

                return render_template('application_added.html', user=user)

            else:

                return render_template('application_added_blocks.html',
                                       user=user)

    else:

        return render_template('login_fail.html')
Exemplo n.º 16
0
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']

            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']

            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,
                        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.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')