Example #1
0
def dashboard_visitor():
    society_id = request.form['society_id']
    all_visitor_details = queries['all_visitor_details3']
    postgres_watchman = all_visitor_details.format(society_id)
    
    with dbm.dbManager() as manager:
        result = manager.getDataFrame(postgres_watchman)

    return jsonify(result.to_dict(orient='records'))
Example #2
0
def dashboard_watchman():
    admin_user = queries['non_admin_user']
    society_id = request.form['society_id']
    postgres_admin = admin_user.format(society_id)
    
    with dbm.dbManager() as manager:
        result = manager.getDataFrame(postgres_admin)
        result_Data = result.to_json(orient='values')
        
    return result_Data
Example #3
0
def login():
    validate_query = queries['validate_user']
    
    username = request.form['username']
    password = request.form['password']
    postgres_user_login_query = validate_query.format(username,password)
    
    with dbm.dbManager() as manager:
            result = manager.getDataFrame(postgres_user_login_query)

    return jsonify(result.to_dict(orient='records'))
Example #4
0
def get_wing_list():
    """get list of wings from a Society"""
    try:
        society_id = request.form['society_id']
        society_wing_list = queries['get_society_wing_list']
        query = society_wing_list.format(society_id)

        with dbm.dbManager() as manager:
            result = manager.getDataFrame(query)
        return jsonify(result.to_dict(orient='records'))
    except psycopg2.DatabaseError as error:
        errors = {'get_wing_list': False, 'error': (error)}
        return str(errors)
Example #5
0
def society_info():
    """ Gives the society id and society name for all registered society."""
    try:
        query = queries['society_info']

        with dbm.dbManager() as manager:
            result = manager.getDataFrame(query)

        return jsonify(result.to_dict(orient='records'))

    except psycopg2.DatabaseError as error:
        errors = {'society info': False, 'error': error}
        return str(errors)
Example #6
0
def update_exit():
    #update_exit=queries['update_exit']
    visitor_id=request.form['id']
    exit_time=request.form['exit_time']
    try:
        update_query='''update visitor_management_schema.visitor_table set exit_time='{}' where id={}'''.format(exit_time,visitor_id)
        
        with dbm.dbManager() as manager:
            manager.updateDB(update_query)
        success=True
    except:
        success=False
    return jsonify(success)
Example #7
0
def get_flat_id():
    """get flat id by giving the society and flat no and wing name"""
    society_id = request.form['society_id']
    wing_name = request.form['wing_name']
    flat_no = request.form['flat_no']
    query_flat_id = queries['get_flat_id_query']

    query = query_flat_id.format(society_id, wing_name, flat_no)

    with dbm.dbManager() as manager:
        result = manager.getDataFrame(query)

    return jsonify(result.to_dict(orient='records'))
Example #8
0
def dashboard_visitor():
    society_id = '2'
    all_visitor_details = queries['all_visitor_details']
    postgres_watchman = all_visitor_details.format(society_id)

    with dbm.dbManager() as manager:
        result = manager.getDataFrame(postgres_watchman)
        #result_Data = result.to_json(orient='values')
        result_Data = result.to_dict(orient='records')
        # result_Data = result.to_(orient='records')
        # result_type = type(jsonify(result_Data))

    return result_Data
Example #9
0
def get_id():
    """ get the society id by passing the society registration."""
    try:
        regd_no = request.form['regd_no']
        query_society_id = queries['get_society_id']
        query = query_society_id.format(regd_no)
        
        with dbm.dbManager() as manager:
            result = manager.getDataFrame(query)

        return jsonify(result.to_dict(orient='records'))
    except psycopg2.DatabaseError as error:
        errors = {'registeration': False, 'error': (error) }
        return str(errors)
Example #10
0
def get_flat_list():
    try:
        society_id = request.form['society_id']
        wing_name = request.form['wing_name']
        wing_flats_list = queries['get_flat_list']
        query = wing_flats_list.format(society_id, wing_name)

        with dbm.dbManager() as manager:
            result = manager.getDataFrame(query)

        return jsonify(result.to_dict(orient='records'))
    except psycopg2.DatabaseError as error:
        errors = {'get_flat_list': False, 'error': (error)}
        return str(errors)
Example #11
0
def dashboard_count():
    try:
        society_id = '2'
        query_society_id = queries['visitor_and_watchman_cnt']
        query = query_society_id.format(society_id)

        with dbm.dbManager() as manager:
            result = manager.getDataFrame(query)

        #return result.to_dict(orient='records')
        return jsonify(result.to_dict(orient='records'))
    except psycopg2.DatabaseError as error:
        errors = {'registeration': False, 'error': (error)}
        return str(errors)
Example #12
0
def visitor_entry():
#    insert_visitor=queries['insert_visitor']
    try:
        photo = request.form['photo']
        first_name = request.form['first_name']
        last_name = replace(request.form['last_name'])
        contact_number = request.form['contact_number']
        entry_time = request.form['entry_time']
        #entry_time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        flat_id = request.form['flat_id']

        staff_id = request.form['staff_id']
        visit_reason = request.form['visit_reason']
        society_id = request.form['society_id']
        
#        postgres_visitor_insert_query=insert_visitor.format(str(first_name),str(last_name),int(contact_number),str(entry_time),str(flat_info),int(staff_id),str(visit_reason),int(society_id),str(photo))
        	#first_name,last_name,contact_number,entry_time,flat_id,staff_id,visit_reason,society_id,photo) 
#
#        df = pd.DataFrame(
#            {
#                'first_name': str(first_name),
#                'last_name': str(last_name),
#                'contact_number': int(contact_number),
#                'entry_time': str(entry_time),
#                'flat_id': str(flat_id),
#                'staff_id': int(staff_id),
#                'visit_reason': str(visit_reason),
#                'society_id': int(society_id),
#                'photo': str(photo)
#                           },
#            index=[0]
#        )
        tuple_insert=['{}'.format(str(first_name)),'{}'.format(str(last_name)),'{}'.format(str(contact_number)),'{}'.format(str(entry_time)),int(flat_id),int(staff_id),'{}'.format(str(visit_reason)),int(society_id),'{}'.format(str(photo))]
        
        try:
            with dbm.dbManager() as manager:
                value=manager.callprocedure(tuple_insert)

        except psycopg2.DatabaseError as error:
            errors = {'visitor_entry': False,
                      'error':(error)
                      }
        return str(errors)

    except psycopg2.DatabaseError as error:
        errors = {'visitor_entry': False,
             'error':(error)
              }
        return str(errors)
Example #13
0
def add_wing():
    """Add details of Flat if Flat not Present"""
    try:
        society_id = request.form['society_id']
        wing_name = request.form['wing_name']
        flat_no = request.form['flat_no']

        df = pd.DataFrame({'society_id': str(society_id), 'wing': str(wing_name), 'flat_no': str(flat_no)}, index=[0])

        with dbm.dbManager() as manager:
            manager.commit(df, 'visitor_management_schema.flat_details')
            success = True
            return jsonify(success)
            #return jsonify(q)

    except psycopg2.DatabaseError as error:
        errors = {'get_wing_list': False, 'error': (error)}
        return str(errors)
Example #14
0
def society_register():
    """Register society"""
    try:
        # society details
        regd_no = request.form['regd_no']
        society_name = request.form['society_name']
        society_address = request.form['society_address']
        total_buildings = request.form['total_buildings']
        total_flats = request.form['total_flats']

        df = pd.DataFrame({'regd_no': regd_no, 'society_name': society_name, 'society_address': society_address,
                           'total_buildings': total_buildings, 'total_flats': total_flats}, index=[0])

        with dbm.dbManager() as manager:
            manager.commit(df, 'visitor_management_schema.society_table')
        # first user details
        return "Society registered successfully"
    except psycopg2.DatabaseError as error:
        errors = {'society registeration': False,
                  'error': (error)
                  }
        return str(errors)
Example #15
0
def user_register():
    """staff Registeration (staff may be watchman or secretary)"""
    try:
        #username=request.form['username']
        email = request.form['email']
        first_name = request.form['first_name']
        middle_name = request.form['middle_name']
        last_name = request.form['last_name']
        password = request.form['password']
        society_id = request.form['society_id']
        flat_id = request.form['flat_id']
        isadmin = request.form['isadmin']
        user_entity = request.form['user_entity']
        username = request.form['email']
        
#        postgres_insert_query=create_user.format(str(username),str(email),str(first_name),str(middle_name),str(last_name),str(password),str(society_id),str(isadmin))
        
        df = pd.DataFrame({'username': str(username),
                           'email': str(email),
                           'first_name': str(first_name),
                           'middle_name': str(middle_name),
                           'last_name': str(last_name),
                           'password': str(password),
                           'society_id': str(society_id),
                           'isadmin': str(isadmin),
                           'flat_id': str(flat_id),
                           'user_entity': str(user_entity)
                           },
                          index=[0])

        with dbm.dbManager() as manager:
            manager.commit(df, 'visitor_management_schema.user_table')
        return "User registered Succesfully"
    except psycopg2.DatabaseError as error:
        errors = {'registeration': False, 'error': error}
        return str(errors)