Пример #1
0
def get_tasks_line():
    #api defaults
    modelName = "stock.warehouse.logistic.task.line"
    fields_toget = [
        'name',
        'qty',
        'state',
        'note',
    ]

    if (request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        line_ids = request_dict['line_ids']
        list_lines = (line_ids.split(','))
        new_list = [int(x) for x in list_lines]
        api_class = Helpers(request_dict['url'], request_dict['db'],
                            int(request_dict['uid']), request_dict['password'])
        check_access = api_class.check_access_rights(modelName)
        if (check_access):
            get_task_lines = api_class.api_read(modelName, new_list,
                                                fields_toget)
            if (get_task_lines):
                response = get_task_lines
            else:
                response = {'status': 'error', 'msg': 'No Lines Found'}

        return jsonify(response)
Пример #2
0
def find_location():
    modelName1 = "res.partner"
    fields_toget = ['street2','city','state_id','country_id',]
    if(request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        user_id = request_dict['uid']
        partner_id=request_dict['partner_id']
        api_class=Helpers(request_dict['url'],request_dict['db'],int(request_dict['uid']),request_dict['password'])
        check_access = api_class.check_access_rights(modelName1)
        if(check_access):
            assigned_user=api_class.location_details(modelName1,partner_id,fields_toget)
            print assigned_user
            source='La Plata'
            string_data=''
            # string_data=assigned_user['city']+','+assigned_user['state_id'][1]+','+assigned_user['country_id'][1]
            if assigned_user['street2'] != False:
                string_data=assigned_user['street2']+','
            if assigned_user['city'] != False:
                string_data=string_data+assigned_user['city']+','
            if assigned_user['state_id'] != False:
                string_data=string_data+assigned_user['state_id'][1]+','
            if assigned_user['country_id'] != False:
                string_data=string_data+assigned_user['country_id'][1]
            print (string_data)
            data=api_class.get_location_data(source,string_data)
            print data
    return jsonify(data)
Пример #3
0
def get_tasks():

    #api_defaults
    modelName = "stock.warehouse.logistic.task"
    fields = ['name',
              'purchase_id',
              'partner_id',
              'type',
              'date_planned',
              'create_uid',
              'state',
              'line_ids']


    if(request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        api_class = Helpers(request_dict['url'],request_dict['db'],int(request_dict['uid']),request_dict['password'])
        check_access = api_class.check_access_rights(modelName)
        checksum = []
        if(check_access):
            get_all_tasks = api_class.api_search_read(modelName,checksum,fields)
            if(get_all_tasks):
                response = get_all_tasks
            else:
                response = {'status': 'error', 'msg': 'No Tasks Found'}
    return jsonify(response)
Пример #4
0
def update_task_flow_accept():
    modelName = "stock.warehouse.logistic.task"
    if(request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        update_id = request_dict['to_update_id']
        print update_id
        api_class=Helpers(request_dict['url'],request_dict['db'],int(request_dict['uid']),request_dict['password'])
        check_access = api_class.check_access_rights(modelName)
        if(check_access):
            updated_id=api_class.api_workflow_reject(modelName,update_id)
            print("updated id is %s"%updated_id)
            response={'status':'success','msg':'updated Successfully'}
    return jsonify(response)
Пример #5
0
def partner_det():
    print "Entered into partner Details"
    modelName1 = "res.partner"
    fields_toget = ['street','street2', 'city', 'state_id', 'country_id', 'name','zip']
    if (request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        user_id = request_dict['uid']
        checksum = [['customer','=',True]]
        # partner_id = request_dict['partner_id']
        api_class = Helpers(request_dict['url'], request_dict['db'], int(request_dict['uid']),
                            request_dict['password'])
        check_access = api_class.check_access_rights(modelName1)
        if (check_access):
            assigned_user = api_class.api_search_read(modelName1,checksum,fields_toget)
            print assigned_user
            if assigned_user:
                for loc_det in assigned_user:

                    string_data = ''
                    # string_data=assigned_user['city']+','+assigned_user['state_id'][1]+','+assigned_user['country_id'][1]
                    if loc_det['street'] != False:
                        string_data = loc_det['street'] + ','
                    if loc_det['street2'] != False:
                        string_data = string_data + loc_det['street2'] + ','
                    if loc_det['city'] != False:
                        string_data = string_data + loc_det['city'] + ','
                    if loc_det['state_id'] != False:
                        string_data = string_data + loc_det['state_id'][1] + ','
                    if loc_det['country_id'] != False:
                        string_data = string_data + loc_det['country_id'][1]
                    print (string_data)
                    partner_location = geocoder.google(string_data)
                    print partner_location.latlng
                    partner_loc = partner_location.latlng
                    if partner_loc:
                        loc_det['latitude'] = partner_loc[0]
                        loc_det['longitude'] = partner_loc[1]
                    else:
                        loc_det['latitude'] = False
                        loc_det['longitude'] = False
                response = assigned_user
            else:
                response = {'status': 'error', 'msg': 'No Customers Found'}

    return jsonify(response)
Пример #6
0
def get_project():
    print "entered into project listing"
    modelName= "project.project"
    fields =['name']
    if request.data:
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        api_class = Helpers(request_dict['url'], request_dict['db'], int(request_dict['uid']), request_dict['password'])
        check_access = api_class.check_access_rights(modelName)

        checksum = [['user_id', '=', int(request_dict['uid'])]]
        if (check_access):
            get_all_tasks = api_class.api_search_read(modelName,checksum, fields)
            if (get_all_tasks):
                response = get_all_tasks
            else:
                response = {'status': 'error', 'msg': 'No Tasks Found'}
    return jsonify(response)
Пример #7
0
def post_tasks_lines():
    #api_defaults
    modelName = "stock.warehouse.logistic.task.line"

    if(request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        update_id = request_dict['to_update_id']
        update_data = request_dict['update_data']
        api_class = Helpers(request_dict['url'],request_dict['db'],int(request_dict['uid']),request_dict['password'])
        check_access = api_class.check_access_rights(modelName)
        if(check_access):
            updated_id = api_class.api_update(modelName,update_id,update_data)
            if(updated_id):
                response = {'status': 'success', 'msg': 'Updated Successfully'}
            else:
                response = {'status': 'error', 'msg': 'updation failed'}

    return jsonify(response)
Пример #8
0
def partner_find():
    print "entered into function"
    modelName="res.partner"

    if request.data:
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        user_id = request_dict['uid']

        partner_id = request_dict['partner_id']
        city = request_dict['city']
        api_class = Helpers(request_dict['url'], request_dict['db'], int(request_dict['uid']), request_dict['password'])
        check_access = api_class.check_access_rights(modelName)
        if (check_access):
            assigned_user = api_class.partner_name_details(modelName, partner_id, city)
            response = {'status': 'success', 'msg': 'updated Successfully'}
            print assigned_user


    return jsonify(response)
Пример #9
0
def get_tasks_det():
    #api defaults
    modelName = "project.materials"
    fields_toget = ['product_id','to_use','used']

    if(request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        print "data is %s"%request_dict
        checksum = [['task_id', '=', int(request_dict['task_id'])]]
        api_class = Helpers(request_dict['url'],request_dict['db'],int(request_dict['uid']),request_dict['password'])
        check_access = api_class.check_access_rights(modelName)
        if(check_access):
            get_task_lines = api_class.api_search_read(modelName,checksum,fields_toget)
            if(get_task_lines):
                response = get_task_lines
            else:
                response = {'status': 'error', 'msg': 'No Materials Found'}


        return jsonify(response)
Пример #10
0
def assign_task():
    modelName = "stock.warehouse.logistic.task"
    if (request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        update_id = request_dict['to_update_id']
        assign_uid = request_dict['uid']
        api_class = Helpers(request_dict['url'], request_dict['db'],
                            int(request_dict['uid']), request_dict['password'])
        check_access = api_class.check_access_rights(modelName)
        if (check_access):
            assigned_user = api_class.api_check_assigned_user(
                modelName, update_id)
            print assigned_user
            if assigned_user and assigned_user['assigned_id'] != False:
                response = {
                    'status': 'assigned',
                    'msg': 'already assigned task'
                }
            else:
                updated_id = api_class.assign_user(modelName, update_id,
                                                   assign_uid)
                if updated_id:
                    status_update = api_class.api_workflow_assign(
                        modelName, update_id)
                    print status_update
                    response = {
                        'status': 'assigned',
                        'msg': 'you are assigned to this task'
                    }

    return jsonify(response)
Пример #11
0
def get_project_task():
    print "entered into project listing"
    modelName= "project.task"
    fields =['name','project_id','user_id','planned_hours','material_ids','description','stage_id']
    if request.data:
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        api_class = Helpers(request_dict['url'], request_dict['db'], int(request_dict['uid']), request_dict['password'])
        check_access = api_class.check_access_rights(modelName)
        if 'project_id' in request_dict:
            checksum = [['project_id', '=', int(request_dict['project_id'])]]
        else:
            checksum = []
        if (check_access):
            get_all_tasks = api_class.api_search_read(modelName,checksum, fields)
            if (get_all_tasks):
                for all in get_all_tasks:
                    test=all['description']
                    plain_text= re.sub(r'<.*?>', '', test)
                    all['description'] = plain_text
                response = get_all_tasks
            else:
                response = {'status': 'error', 'msg': 'No Tasks Found'}
    return jsonify(response)
Пример #12
0
def main():
    """ Main """
    args = appstack()
    add_variables = {}

    if args.action == 'raise':
        for item in args.stack_definition.split(","):
            engine = Helpers(args, item, add_variables)
            add_variables.update(engine.create())

    elif args.action == 'destroy':
        for item in args.stack_definition.split(","):
            engine = Helpers(args, item, add_variables)
            engine.destroy()
    else:
        print("Unsupported action!")
        exit(1)
Пример #13
0
from flask import Flask, request, jsonify
import json
from lib.dataHandler import DataHandler
from lib.helpers import Helpers
import os

# Init app
app = Flask(__name__)
_data = DataHandler()
_helpers = Helpers()


@app.errorhandler(404)
def not_found(e):
    return jsonify({'message': 'Page not found!'}), 404


@app.route('/', methods=['GET', 'POST', 'PUT', 'DELETE'])
def home():
    res = {
        'message':
        'Welcome to Home Page. Use these Routes in POSTMAN',
        'POST':
        'https://py-flask-restapi.herokuapp.com/users -> firstName, lastName, email, phone and password in request body',
        'GET':
        'https://py-flask-restapi.herokuapp.com/users?phone=(phone_number_here)',
        'PUT':
        'https://py-flask-restapi.herokuapp.com/users -> phone(required) and other optional fields in request body',
        'DELETE':
        'https://py-flask-restapi.herokuapp.com/users?phone=(phone_number_here)'
    }
Пример #14
0
from time import time

from lib.analyzer import Analyzer
from lib.helpers import Helpers
from lib.writer import Writer
from lib.grapher import Grapher
from lib.reporter import Reporter

ENCODING = "latin-1"
FILEFORMAT = ".log"

if __name__ == '__main__':
    print("Running Log Auswertung")
    start = time()

    helpers = Helpers(ENCODING, FILEFORMAT)
    helpers.create_directorys()
    analyzer = Analyzer(helpers)
    analyzer.run()
    grapher = Grapher(ENCODING, helpers)
    grapher.run()
    csv_writer = Writer(ENCODING, helpers)
    csv_writer.run_all()
    reporter = Reporter()
    reporter.write_html_doc()

    end = time() - start
    print("Prozess beendet: {:02.0f}:{:02.0f}:{:02.2f}".format(
        end // 3600, end % 3600 // 60, end % 60))
Пример #15
0
def multi_update():
    modelName = "stock.warehouse.logistic.task"
    update_list = list()
    if (request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        list_arry = request_dict['to_update_id']
        state = request_dict['update_data']

        for dict in (list_arry):
            update_id = dict
            api_class = Helpers(request_dict['url'], request_dict['db'],
                                int(request_dict['uid']),
                                request_dict['password'])
            check_access = api_class.check_access_rights(modelName)
            if (check_access):
                update = api_class.api_multi_update(modelName, update_id,
                                                    state)
                print update
                if (update):
                    update_list.append(update_id)

        if (update_list):
            response = {
                'status': 'assigned',
                'msg': 'Updated Successfully',
                'update_ids': update_list
            }
        else:
            response = {
                'status': 'failed',
                'msg': 'Some Tasks are not updated'
            }

        return jsonify(response)

    @app.route('/api/v1/locationdetails', methods=['POST'])
    def find_location():
        modelName1 = "res.partner"
        fields_toget = [
            'street2',
            'city',
            'state_id',
            'country_id',
        ]
        if (request.data):
            data_list = json.loads(request.data)
            request_dict = data_list['params']
            user_id = request_dict['uid']
            partner_id = request_dict['partner_id']
            api_class = Helpers(request_dict['url'], request_dict['db'],
                                int(request_dict['uid']),
                                request_dict['password'])
            check_access = api_class.check_access_rights(modelName1)
            if (check_access):
                assigned_user = api_class.location_details(
                    modelName1, partner_id, fields_toget)
                print assigned_user
                source = 'california'
                string_data = ''
                # string_data=assigned_user['city']+','+assigned_user['state_id'][1]+','+assigned_user['country_id'][1]
                if assigned_user['street2'] != False:
                    string_data = assigned_user['street2'] + ','
                if assigned_user['city'] != False:
                    string_data = string_data + assigned_user['city'] + ','
                if assigned_user['state_id'] != False:
                    string_data = string_data + assigned_user['state_id'][
                        1] + ','
                if assigned_user['country_id'] != False:
                    string_data = string_data + assigned_user['country_id'][1]
                print(string_data)
                data = api_class.get_location_data(source, string_data)
                print data
        return jsonify(data)
Пример #16
0
def update_task_flow():
    response = {}
    modelName = "stock.warehouse.logistic.task"
    if (request.data):
        data_list = json.loads(request.data)
        request_dict = data_list['params']
        update_id = request_dict['to_update_id']
        state = request_dict['update_data']
        print update_id
        api_class = Helpers(request_dict['url'], request_dict['db'],
                            int(request_dict['uid']), request_dict['password'])
        check_access = api_class.check_access_rights(modelName)
        if (check_access):
            if (state == 'confirmed'):
                updated_id = api_class.api_workflow(modelName, update_id)
                print("updated id is %s" % updated_id)
                response = {'status': 'success', 'msg': 'updated Successfully'}
            if (state == 'assigned'):
                updated_id = api_class.api_workflow_assign(
                    modelName, update_id)
                print("updated id is %s" % updated_id)
                response = {'status': 'success', 'msg': 'updated Successfully'}
            if (state == 'accepted'):
                updated_id = api_class.api_workflow_accept(
                    modelName, update_id)
                print("updated id is %s" % updated_id)
                response = {'status': 'success', 'msg': 'updated Successfully'}
            if (state == 'done'):
                updated_id = api_class.api_workflow_done(modelName, update_id)
                print("updated id is %s" % updated_id)
                response = {'status': 'success', 'msg': 'updated Successfully'}
            if (state == 'cancel'):
                updated_id = api_class.api_workflow_cancel(
                    modelName, update_id)
                print("updated id is %s" % updated_id)
                response = {'status': 'success', 'msg': 'updated Successfully'}
            if (state == 'rejected'):
                updated_id = api_class.api_workflow_reject(
                    modelName, update_id)
                print("updated id is %s" % updated_id)
                response = {'status': 'success', 'msg': 'updated Successfully'}
            if (state == 'failed'):
                updated_id = api_class.api_workflow_fail(modelName, update_id)
                print("updated id is %s" % updated_id)
                response = {'status': 'success', 'msg': 'updated Successfully'}
            if (state == 'draft'):
                updated_id = api_class.api_workflow_draft(modelName, update_id)
                print("updated id is %s" % updated_id)
                response = {'status': 'success', 'msg': 'updated Successfully'}
    return jsonify(response)