예제 #1
0
def block_filter_by_scheme(start_date, end_date):

    all_works = []

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

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

    all_works_dict = Database.find("works",
                                   {"end_date": {
                                       "$gte": start,
                                       "$lt": end
                                   }})

    for tran in all_works_dict:

        all_works.append(tran)

    all_w = json.dumps(all_works, default=json_util.default)

    return all_w
예제 #2
0
def Block_report(start_date, end_date, block):

    all_works = []

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

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

    all_works_dict = Database.find("works", {
        "$and": [{
            "end_date": {
                "$gte": start,
                "$lt": end
            }
        }, {
            "block": block
        }]
    })

    for tran in all_works_dict:

        all_works.append(tran)

    all_w = json.dumps(all_works, default=json_util.default)

    return all_w
예제 #3
0
def get_work_by_deadline_blocks(block, scheme_value):

    work = []

    work_dict = Database.find(
        "works", {
            "$and": [{
                "block": block
            }, {
                "scheme_name": scheme_value
            }, {
                "end_date": {
                    "$lte": datetime.now()
                }
            }, {
                "work_status": "Open"
            }]
        })

    for tran in work_dict:

        work.append(tran)

    single_work = json.dumps(work, default=json_util.default)

    return single_work
예제 #4
0
def stages_by_work(work_id):

    stage = []

    stage_dict = Database.find("stages", {"work_id": work_id})

    for tran in stage_dict:

        stage.append(tran)

    single_stage = json.dumps(stage, default=json_util.default)

    return single_stage
예제 #5
0
def get_work_by_blocks(block_value):

    work = []

    work_dict = Database.find("works", {"block": block_value})

    for tran in work_dict:

        work.append(tran)

    single_work = json.dumps(work, default=json_util.default)

    return single_work
예제 #6
0
def view_all_work():

    work = []

    work_dict = Database.find("works", {})

    for tran in work_dict:

        work.append(tran)

    single_work = json.dumps(work, default=json_util.default)

    return single_work
예제 #7
0
def view_all_schemes():

    scheme = []

    scheme_dict = Database.find("schemes", {})

    for tran in scheme_dict:

        scheme.append(tran)

    single_scheme = json.dumps(scheme, default=json_util.default)

    return single_scheme
예제 #8
0
def raw_demands_by_scheme_id(_id):

    scheme = []

    scheme_dict = Database.find("schemes", {"_id": _id})

    for tran in scheme_dict:

        scheme.append(tran)

    single_scheme = json.dumps(scheme, default=json_util.default)

    return single_scheme
예제 #9
0
def get_work_by_scheme(scheme_value):

    work = []

    work_dict = Database.find("works", {"scheme_name": scheme_value})

    for tran in work_dict:

        work.append(tran)

    single_work = json.dumps(work, default=json_util.default)

    return single_work
예제 #10
0
def view_all_completed_work():

    work = []

    work_dict = Database.find("works", {"work_status": "Close"})

    for tran in work_dict:

        work.append(tran)

    single_work = json.dumps(work, default=json_util.default)

    return single_work
예제 #11
0
def raw_demands_by_work_id(work_id):

    work = []

    work_dict = Database.find("works", {"work_id": work_id})

    for tran in work_dict:

        work.append(tran)

    single_work = json.dumps(work, default=json_util.default)

    return single_work
예제 #12
0
def get_work_type_second():

    district_intents_array = []

    district_intents = Database.find("schemes", {})

    for intent in district_intents:

        district_intents_array.append(intent)

    completed_intents = json.dumps(district_intents_array,
                                   default=json_util.default)

    return completed_intents
예제 #13
0
def get_scheme_name(scheme_group_name):

    district_intents_array = []

    district_intents = Database.find("schemes",
                                     {"scheme_group_name": scheme_group_name})

    for intent in district_intents:

        district_intents_array.append(intent)

    completed_intents = json.dumps(district_intents_array,
                                   default=json_util.default)

    return completed_intents
예제 #14
0
def get_work_by_scheme_block(block, scheme_value):

    work = []

    work_dict = Database.find(
        "works", {"$and": [{
            "block": block
        }, {
            "scheme_name": scheme_value
        }]})

    for tran in work_dict:

        work.append(tran)

    single_work = json.dumps(work, default=json_util.default)

    return single_work
예제 #15
0
def view_all_ongoing_work_blocks(block):

    work = []

    work_dict = Database.find(
        "works", {"$and": [{
            "block": block
        }, {
            "work_status": "Open"
        }]})

    for tran in work_dict:

        work.append(tran)

    single_work = json.dumps(work, default=json_util.default)

    return single_work
예제 #16
0
def get_work_by_ongoing(block_value):

    work = []

    work_dict = Database.find(
        "works", {"$and": [{
            "block": block_value
        }, {
            "work_status": "Open"
        }]})

    for tran in work_dict:

        work.append(tran)

    single_work = json.dumps(work, default=json_util.default)

    return single_work
예제 #17
0
def deadline_violation_stages_report():
    stage = []
    d = datetime.today() - timedelta(days=30)
    stage_dict = Database.find(
        "stages",
        {"$and": [{
            "stage_status": "Open"
        }, {
            "start_date": {
                "$lte": d
            }
        }]})

    for tran in stage_dict:
        stage.append(tran)

    single_stage = json.dumps(stage, default=json_util.default)

    return single_stage
예제 #18
0
def view_all_deadline_work():

    work = []

    work_dict = Database.find("works", {
        "$and": [{
            "end_date": {
                "$lte": datetime.now()
            }
        }, {
            "work_status": "Open"
        }]
    })

    for tran in work_dict:

        work.append(tran)

    single_work = json.dumps(work, default=json_util.default)

    return single_work
예제 #19
0
def get_work_type(scheme_group_name, scheme_name, work_group_name):

    district_intents_array = []

    district_intents = Database.find(
        "schemes", {
            "$and": [{
                "scheme_group_name": scheme_group_name
            }, {
                "work_group_name": work_group_name
            }, {
                "scheme_name": scheme_name
            }]
        })

    for intent in district_intents:

        district_intents_array.append(intent)

    completed_intents = json.dumps(district_intents_array,
                                   default=json_util.default)

    return completed_intents
예제 #20
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')
예제 #21
0
def initialize_database():

    Database.initialize()
예제 #22
0
def Department_report(start_date, end_date, scheme_group_name, scheme_name,
                      work_group_name, work_type):

    all_works = []

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

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

    if scheme_group_name == 'All':
        all_works_dict = Database.find(
            "works", {"end_date": {
                "$gte": start,
                "$lt": end
            }})
    elif scheme_name == 'All':
        all_works_dict = Database.find(
            "works", {
                "$and": [{
                    "end_date": {
                        "$gte": start,
                        "$lt": end
                    }
                }, {
                    "scheme_group_name": scheme_group_name
                }]
            })
    elif work_group_name == 'All':
        all_works_dict = Database.find(
            "works", {
                "$and": [{
                    "end_date": {
                        "$gte": start,
                        "$lt": end
                    }
                }, {
                    "scheme_name": scheme_name
                }, {
                    "scheme_group_name": scheme_group_name
                }]
            })
    elif work_type == 'All':
        all_works_dict = Database.find(
            "works", {
                "$and": [{
                    "end_date": {
                        "$gte": start,
                        "$lt": end
                    }
                }, {
                    "scheme_name": scheme_name
                }, {
                    "work_group_name": work_group_name
                }, {
                    "scheme_group_name": scheme_group_name
                }]
            })

    else:

        all_works_dict = Database.find(
            "works", {
                "$and": [{
                    "end_date": {
                        "$gte": start,
                        "$lt": end
                    }
                }, {
                    "scheme_name": scheme_name
                }, {
                    "work_group_name": work_group_name
                }, {
                    "work_type": work_type
                }, {
                    "scheme_group_name": scheme_group_name
                }]
            })

    for tran in all_works_dict:

        all_works.append(tran)

    all_w = json.dumps(all_works, default=json_util.default)

    return all_w