Ejemplo n.º 1
0
def menu(request):
    menu_texts = FrontendTexts('menu')
    if not request.user.is_authenticated:
        return redirect('/auth/login')
    else:
        return render(request, 'menu/menu.html',
                      {'menu_text': menu_texts.getComponent()})
Ejemplo n.º 2
0
def rfq_manager(request):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('rfqs', 'manage')
    try:
        if request.method == 'POST':
            selector_form = SelectorForm(request.POST)

            if selector_form.is_valid():
                code = selector_form.cleaned_data['code']
                action = selector_form.cleaned_data['action']

                if action == '1':
                    return redirect('edit/' + code)
                elif action == '2':
                    return redirect('material_reload/' + code)
                elif action == '3':
                    return redirect('analyze/' + code)

        else:
            selector_form = SelectorForm()
            return render(request, 'rfqs/rfq_selector.html', {'menu_text': menu_texts.getComponent(),
                                                              'view_texts': view_texts.getComponent(),
                                                              'selector_form': selector_form,
                                                              'instructions_title': instructions.getTitle(),
                                                              'instructions_steps': instructions.getSteps()})

    except ValueError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'rfqs/rfq_selector.html', {'menu_text': menu_texts.getComponent(),
                                                          'view_texts': view_texts.getComponent(),
                                                          'error_message': 'Backend problem',
                                                          'instructions_title': instructions.getTitle(),
                                                          'instructions_steps': instructions.getSteps()
                                                          })

    except ConnectionError as exception:
        print("Backend connection problem")
        print(exception)
        return render(request, 'rfqs/rfq_selector.html', {'menu_text': menu_texts.getComponent(),
                                                                    'view_texts': view_texts.getComponent(),
                                                                    'error_message': 'Backend connection problem',
                                                                    'instructions_title': instructions.getTitle(),
                                                                    'instructions_steps': instructions.getSteps()
                                                                    })

    except Exception as exception:
        print(exception)
        return render(request, 'rfqs/rfq_selector.html', {'menu_text': menu_texts.getComponent(),
                                                          'view_texts': view_texts.getComponent(),
                                                          'error_message': 'System error',
                                                          'instructions_title': instructions.getTitle(),
                                                          'instructions_steps': instructions.getSteps()
                                                          })
Ejemplo n.º 3
0
def list_all(request):
    menu_texts = FrontendTexts('menu')
    try:

        backend_host = MachineConfigurator().getBackend()

        r = requests.get(backend_host + '/auth/providers/')

        backend_message = BackendMessage(json.loads(r.text))

        providers_list = json.loads(backend_message.getValue())

        paginator = Paginator(providers_list, 10)  # Show 25 contacts per page

        page = request.GET.get('page')

        contacts = paginator.get_page(page)

        return render(request, 'providers/list_all.html', {'menu_text': menu_texts.getComponent(),
                                                           'view_texts': view_texts.getComponent(),
                                                           'contacts': contacts})

    except ValueError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'providers/list_all.html', {'menu_text': menu_texts.getComponent(),
                                                           'view_texts': view_texts.getComponent(),
                                                           'error_message': 'Backend problem',
                                                           })

    except ConnectionError as exception:
        print("Backend connection problem")
        print(exception)
        return render(request, 'providers/list_all.html', {'menu_text': menu_texts.getComponent(),
                                                           'view_texts': view_texts.getComponent(),
                                                           'error_message': 'Backend connection problem',
                                                           })

    except Exception as exception:
        print(exception)
        return render(request, 'providers/list_all.html', {'menu_text': menu_texts.getComponent(),
                                                           'view_texts': view_texts.getComponent(),
                                                           'error_message': 'System error',
                                                           })
Ejemplo n.º 4
0
def rfq_material_reload(request, code):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('rfqs', 'reload')
    try:

        backend_host = MachineConfigurator().getBackend()

        r = requests.put(backend_host + '/auth/rfqs/reload/' + code, json={})

        backend_message = BackendMessage(json.loads(r.text))

        backend_result = json.loads(backend_message.getValue())

        return render(request, 'rfqs/rfq_material_reload.html', {'menu_text': menu_texts.getComponent(),
                                                                 'view_texts': view_texts.getComponent(),
                                                                 'updated_materials': backend_result})

    except ValueError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'rfqs/rfq_material_reload.html', {'menu_text': menu_texts.getComponent(),
                                                                 'view_texts': view_texts.getComponent(),
                                                                 'error_message': 'No such RFQ exists in the DB: ' + code,
                                                                 'instructions_title': instructions.getTitle(),
                                                                 'instructions_steps': instructions.getSteps()})

    except ConnectionError as exception:
        print("Backend connection problem")
        print(exception)
        return render(request, 'rfqs/rfq_material_reload.html', {'menu_text': menu_texts.getComponent(),
                                                                 'view_texts': view_texts.getComponent(),
                                                                 'error_message': 'Backend connection problem',
                                                                 'instructions_title': instructions.getTitle(),
                                                                 'instructions_steps': instructions.getSteps()})

    except Exception as exception:
        print(exception)
        return render(request, 'rfqs/rfq_material_reload.html', {'menu_text': menu_texts.getComponent(),
                                                                 'view_texts': view_texts.getComponent(),
                                                                 'error_message': 'System error',
                                                                 'instructions_title': instructions.getTitle(),
                                                                 'instructions_steps': instructions.getSteps()})
Ejemplo n.º 5
0
def material_weight(request, code):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('materials', 'weightcalc')
    try:

        backend_host = MachineConfigurator().getBackend()

        quantity_form = WeightCalculatorForm(request.POST)

        if request.method == 'POST':

            if quantity_form.is_valid():
                # ... update current material with the data provided

                value = quantity_form.cleaned_data['value']
                units = UNIT_CHOICES[int(quantity_form.cleaned_data['units']) -
                                     1][1]

                result = {'quantity': value, 'units': units}

                r = requests.post(backend_host + '/auth/materials/weights/' +
                                  code,
                                  json=result)

                backend_message = BackendMessage(json.loads(r.text))

                backend_result = json.loads(backend_message.getValue())

                return render(
                    request, 'materials/material_weight.html', {
                        'menu_text': menu_texts.getComponent(),
                        'weight_materials': backend_result
                    })

        return render(
            request, 'materials/material_weight.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'quantity_form': quantity_form,
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })

    except ConnectionError as exception:
        print("Backend connection problem")
        print(exception)
        return render(
            request, 'materials/material_weight.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'error_message': 'Backend connection problem',
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })

    except Exception as exception:
        print(exception)
        return render(
            request, 'materials/material_weight.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'error_message': 'System error',
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })
Ejemplo n.º 6
0
from .services.QuoteCreator import QuoteCreator
from .services.ExtQuotedMaterialCreator import ExtQuotedMaterialCreator
from .forms import QuotesForm, QuotedMaterialsForm, SelectorForm, QuotesFormOnlyinfo, QuotedMaterialForm
from .forms import SmartQuotesForm

import requests
import json
import os

from common.BackendMessage import BackendMessage
from common.MachineConfig import MachineConfigurator
from common.Instructions import Instructions
from common.FrontendTexts import FrontendTexts


view_texts = FrontendTexts('quotes')


def cleanup(filename):
    try:
        os.remove('.' + filename)
        print("removed file: " + filename)
    except Exception as error:
        print(error)


@login_required(login_url='/auth/login')
def quotes_upload(request):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('quotes', 'upload')
    uploaded_file_url = ''
Ejemplo n.º 7
0
def singlexcheck(request):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('materials', 'singlexcheck')
    try:
        if request.method == 'POST':
            form = xcheckForm(request.POST)
            if form.is_valid():

                itemcode = form.cleaned_data['itemcode']

                backend_host = MachineConfigurator().getBackend()

                r = requests.post(backend_host + '/auth/materials/xcheck/' +
                                  itemcode)

                backend_message = BackendMessage(json.loads(r.text))
                backend_result = json.loads(backend_message.getValue())

                return render(
                    request, 'materials/singlexcheck.html', {
                        'menu_text': menu_texts.getComponent(),
                        'view_texts': view_texts.getComponent(),
                        'uploaded_materials': backend_result
                    })

        else:
            form = xcheckForm()

        return render(
            request, 'materials/singlexcheck.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'xform': form,
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })

    except ValueError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(
            request, 'materials/singlexcheck.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'error_message': 'Backend problem',
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })

    except ConnectionError as exception:
        print("Backend connection problem")
        print(exception)
        return render(
            request, 'materials/singlexcheck.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'error_message': 'Backend connection problem',
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })

    except Exception as exception:
        print(exception)
        return render(
            request, 'materials/singlexcheck.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'error_message': 'System error',
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })
Ejemplo n.º 8
0
def simple_upload(request):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('materials', 'upload')
    uploaded_file_url = ''
    try:
        if request.method == 'POST' and request.FILES['myfile']:

            myfile = request.FILES['myfile']
            fs = FileSystemStorage()
            filename = fs.save(myfile.name, myfile)
            uploaded_file_url = fs.url(filename)

            # ... do here the magic
            creator = MaterialCreator()
            result = creator.createMaterialfromCSV('.' + uploaded_file_url)
            result_json = []

            for material in result:
                result_json.append(json.dumps(material))

            backend_host = MachineConfigurator().getBackend()

            r = requests.post(backend_host + '/auth/materials/', json=result)

            backend_message = BackendMessage(json.loads(r.text))

            backend_result = json.loads(backend_message.getValue())

            cleanup(uploaded_file_url)

            return render(
                request, 'materials/simple_upload.html', {
                    'menu_text': menu_texts.getComponent(),
                    'view_texts': view_texts.getComponent(),
                    'uploaded_materials': backend_result
                })

        return render(
            request, 'materials/simple_upload.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })

    except MultiValueDictKeyError as exception:
        print("No file selected")
        print(exception)
        return render(
            request, 'materials/simple_upload.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'error_message': 'No file selected',
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })
    except UnicodeDecodeError as exception:
        print(
            "There is a problem with the input file - unicode decoding error")
        print(exception)
        cleanup(uploaded_file_url)
        return render(
            request, 'materials/simple_upload.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'error_message': 'Cannot read file correctly',
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })

    except ValueError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        cleanup(uploaded_file_url)
        return render(
            request, 'materials/simple_upload.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'error_message': 'Backend problem',
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })

    except ConnectionError as exception:
        cleanup(uploaded_file_url)
        print("Backend connection problem")
        print(exception)
        return render(
            request, 'materials/simple_upload.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'error_message': 'Backend connection problem',
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })

    except Exception as exception:
        print(exception)
        cleanup(uploaded_file_url)
        return render(
            request, 'materials/simple_upload.html', {
                'menu_text': menu_texts.getComponent(),
                'view_texts': view_texts.getComponent(),
                'error_message': 'System error',
                'instructions_title': instructions.getTitle(),
                'instructions_steps': instructions.getSteps()
            })
Ejemplo n.º 9
0
from django import forms
from .choices import *
from common.FrontendTexts import FrontendTexts

view_texts = FrontendTexts('providers')


class ProviderForm(forms.Form):
    labels = view_texts.getComponent()['creator']['labels']
    name = forms.CharField(max_length=255, label=labels['name'])
    category = forms.ChoiceField(choices=CATEGORY_CHOICES,
                                 label=labels['category'],
                                 initial='',
                                 widget=forms.Select(),
                                 required=True)
    specialty = forms.CharField(max_length=255, label=labels['specialty'])
    webpage = forms.CharField(max_length=255, label=labels['webpage'])
    contactNames = forms.CharField(max_length=255, label=labels['contactNames'])
    emailAddresses = forms.EmailField(label=labels['emailAddresses'])
    address = forms.CharField(max_length=255, label=labels['address'])
    country = forms.CharField(max_length=255, label=labels['country'])
    city = forms.CharField(max_length=255, label=labels['city'])
    phone = forms.CharField(max_length=255, label=labels['phone'])
    taxId = forms.CharField(max_length=255, label=labels['taxId'])
    coordinates = forms.CharField(max_length=255, label=labels['coordinates'])


class ProviderFinderForm(forms.Form):
    labels = view_texts.getComponent()['finder']['labels']
    code = forms.CharField(max_length=255)
Ejemplo n.º 10
0
def provider_creator(request):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('providers', 'create')
    try:
        if request.method == 'POST':
            form = ProviderForm(request.POST)
            if form.is_valid():

                creator = ProviderCreator()
                result = creator.createProvider(form)
                result_json = []

                print(result)

                for provider in result:
                    result_json.append(json.dumps(provider))

                backend_host = MachineConfigurator().getBackend()

                r = requests.post(backend_host + '/auth/providers/', json=result)

                backend_message = BackendMessage(json.loads(r.text))

                backend_result = json.loads(backend_message.getValue())

                return render(request, 'providers/provider_creator.html', {'menu_text': menu_texts.getComponent(),
                                                                           'view_texts': view_texts.getComponent(),
                                                                           'uploaded_providers': backend_result})

        else:
            form = ProviderForm()
            return render(request, 'providers/provider_creator.html', {'menu_text': menu_texts.getComponent(),
                                                                       'view_texts': view_texts.getComponent(),
                                                                       'providerform': form,
                                                                       'instructions_title': instructions.getTitle(),
                                                                       'instructions_steps': instructions.getSteps()})

    except ValueError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'providers/provider_creator.html', {'menu_text': menu_texts.getComponent(),
                                                                   'view_texts': view_texts.getComponent(),
                                                                   'error_message': 'Backend problem',
                                                                   'instructions_title': instructions.getTitle(),
                                                                   'instructions_steps': instructions.getSteps()
                                                                   })

    except ConnectionError as exception:
        print("Backend connection problem")
        print(exception)
        return render(request, 'providers/provider_creator.html', {'menu_text': menu_texts.getComponent(),
                                                                   'view_texts': view_texts.getComponent(),
                                                                   'error_message': 'Backend connection problem',
                                                                   'instructions_title': instructions.getTitle(),
                                                                   'instructions_steps': instructions.getSteps()
                                                                   })

    except Exception as exception:
        print(exception)
        return render(request, 'providers/provider_creator.html', {'menu_text': menu_texts.getComponent(),
                                                                   'view_texts': view_texts.getComponent(),
                                                                   'error_message': 'System error',
                                                                   'instructions_title': instructions.getTitle(),
                                                                   'instructions_steps': instructions.getSteps()
                                                                   })
Ejemplo n.º 11
0
def quoted_materials_editor(request, code):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('quotes', 'edit')
    try:

        backend_host = MachineConfigurator().getBackend()

        r = requests.post(backend_host + '/auth/quotes/materials/' + code)

        backend_message = BackendMessage(json.loads(r.text))

        quoted_materials_data = json.loads(backend_message.getValue())

        quoted_material_form = QuotedMaterialForm(initial=quoted_materials_data)

        if request.method == 'POST':

            quoted_material_form = QuotedMaterialForm(request.POST)

            if quoted_material_form.is_valid():
                # ... update current material with the data provided
                # ... send data to backend

                creator = QuoteCreator()
                result = creator.editQuotedMaterials(quoted_material_form, quoted_materials_data)

                result_json = []

                for quote in result:
                    result_json.append(json.dumps(quote))

                r = requests.put(backend_host + '/auth/quotes/materials/' + code, json=result)

                backend_message = BackendMessage(json.loads(r.text))

                backend_result = json.loads(backend_message.getValue())

                return render(request, 'quotes/materials_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                        'view_texts': view_texts.getComponent(),
                                                                        'updated_materials': backend_result})
            else:
                print("Invalid form")

        return render(request, 'quotes/materials_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'quote_form': quoted_material_form,
                                                                'instructions_title': instructions.getTitle(),
                                                                'instructions_steps': instructions.getSteps()})

    except ValueError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'quotes/materials_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'error_message': 'No such quoted material exists ' +
                                                                                 'in the DB: ' + code,
                                                                'instructions_title': instructions.getTitle(),
                                                                'instructions_steps': instructions.getSteps()})

    except ConnectionError as exception:
        print("Backend connection problem")
        print(exception)
        return render(request, 'quotes/materials_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'error_message': 'Backend connection problem',
                                                                'instructions_title': instructions.getTitle(),
                                                                'instructions_steps': instructions.getSteps()})

    except Exception as exception:
        print(exception)
        return render(request, 'quotes/materials_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'error_message': 'System error',
                                                                'instructions_title': instructions.getTitle(),
                                                                'instructions_steps': instructions.getSteps()})
Ejemplo n.º 12
0
from django.contrib.auth import logout
from django.shortcuts import render, redirect

from common.FrontendTexts import FrontendTexts

view_texts = FrontendTexts('login')


def logout_view(request):
    logout(request)
    return redirect('/auth/login')
Ejemplo n.º 13
0
def quoted_materials_upload(request):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('quotes', 'materials_upload')
    uploaded_file_url = ''
    try:
        if request.method == 'POST':
            form = QuotedMaterialsForm(request.POST, request.FILES)
            if form.is_valid():

                data = ExtQuotedMaterialCreator()

                providerId = form.cleaned_data['providerId']
                providerName = form.cleaned_data['providerName']
                revision = form.cleaned_data['revision']

                data.setExtendedInformation(providerId, providerName, revision)

                my_file = request.FILES['document']
                fs = FileSystemStorage()
                filename = fs.save(my_file.name, my_file)
                uploaded_file_url = fs.url(filename)

                result = data.createExtQuotedMaterialsfromCSV('.' + uploaded_file_url)

                # print(json.dumps(result))

                backend_host = MachineConfigurator().getBackend()
                r = requests.post(backend_host + '/auth/quotes/materials', json=result)

                backend_message = BackendMessage(json.loads(r.text))

                cleanup(uploaded_file_url)

                backend_result = []

                if backend_message.errorInd:
                    display_message = {}
                    display_message['itemcode'] = "-"
                    display_message['revision'] = "-"
                    display_message['status'] = "-"
                    backend_result.append(display_message)
                else:
                    backend_result = json.loads(backend_message.getValue())

                return render(request, 'quotes/materials_upload.html', {'menu_text': menu_texts.getComponent(),
                                                                        'view_texts': view_texts.getComponent(),
                                                                        'upload_result': backend_result})
        else:
            form = QuotedMaterialsForm()

        return render(request, 'quotes/materials_upload.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'form': form,
                                                                'instructions_title': instructions.getTitle(),
                                                                'instructions_steps': instructions.getSteps()
                                                                })

    except ValueError as exception:
        cleanup(uploaded_file_url)
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'quotes/materials_upload.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'error_message': 'Backend problem',
                                                                'instructions_title': instructions.getTitle(),
                                                                'instructions_steps': instructions.getSteps()
                                                                })

    except ConnectionError as exception:
        cleanup(uploaded_file_url)
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'quotes/materials_upload.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'error_message': 'Backend connection problem',
                                                                'instructions_title': instructions.getTitle(),
                                                                'instructions_steps': instructions.getSteps()
                                                                })

    except Exception as exception:
        cleanup(uploaded_file_url)
        print(exception)
        return render(request, 'quotes/materials_upload.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'error_message': "Frontend Error",
                                                                'instructions_title': instructions.getTitle(),
                                                                'instructions_steps': instructions.getSteps()
                                                                })
Ejemplo n.º 14
0
def rfq_qfinder(request):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('rfqs', 'qfinder')
    uploaded_file_url = ''
    try:
        if request.method == 'POST' and request.FILES['myfile']:
            myfile = request.FILES['myfile']
            fs = FileSystemStorage()
            filename = fs.save(myfile.name, myfile)
            uploaded_file_url = fs.url(filename)

            rfq = RFQCreator()
            result = rfq.findQuotesFromCSV('.' + uploaded_file_url)

            # ... print(json.dumps(result))

            backend_host = MachineConfigurator().getBackend()
            r = requests.post(backend_host + '/auth/rfqs/quotes', json=result)

            backend_message = BackendMessage(json.loads(r.text))

            if not backend_message.getErrorInd():

                quoted_materials = json.loads(backend_message.getValue())
                cleanup(uploaded_file_url)

                return render(request, 'rfqs/rfq_qfinder.html', {'menu_text': menu_texts.getComponent(),
                                                                 'view_texts': view_texts.getComponent(),
                                                                 'quoted_materials': quoted_materials,
                                                                 'instructions_title': instructions.getTitle(),
                                                                 'instructions_steps': instructions.getSteps()
                                                                 })
            else:
                print(backend_message.getValue())
                cleanup(uploaded_file_url)
                return render(request, 'rfqs/rfq_qfinder.html', {'menu_text': menu_texts.getComponent(),
                                                                 'view_texts': view_texts.getComponent(),
                                                                 'error_message': backend_message.getValue(),
                                                                 'instructions_title': instructions.getTitle(),
                                                                 'instructions_steps': instructions.getSteps()
                                                                 })

        return render(request, 'rfqs/rfq_qfinder.html', {'menu_text': menu_texts.getComponent(),
                                                         'view_texts': view_texts.getComponent(),
                                                         'instructions_title': instructions.getTitle(),
                                                         'instructions_steps': instructions.getSteps()
                                                         })

    except ConnectionError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'rfqs/rfq_qfinder.html', {'menu_text': menu_texts.getComponent(),
                                                         'view_texts': view_texts.getComponent(),
                                                         'error_message': 'Backend connection problem',
                                                         'instructions_title': instructions.getTitle(),
                                                         'instructions_steps': instructions.getSteps()
                                                         })

    except Exception as exception:
        cleanup(uploaded_file_url)
        print(exception)
        return render(request, 'rfqs/rfq_qfinder.html', {'menu_text': menu_texts.getComponent(),
                                                         'view_texts': view_texts.getComponent(),
                                                         'error_message': "Frontend Error",
                                                         'instructions_title': instructions.getTitle(),
                                                         'instructions_steps': instructions.getSteps()
                                                         })
Ejemplo n.º 15
0
def rfq_export(request):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('rfqs', 'export')
    output_file = ''
    try:
        if request.method == 'POST':
            form = RFQInternalCode(request.POST)
            if form.is_valid():

                internal_code = form.cleaned_data['internalcode']

                incoterms = form.cleaned_data['incoterms']

                port = form.cleaned_data['port']

                backend_host = MachineConfigurator().getBackend()

                r = requests.get(backend_host + '/auth/rfqs/' + internal_code)

                backend_message = BackendMessage(json.loads(r.text))

                if not backend_message.getErrorInd():

                    rfq = json.loads(backend_message.getValue())
                    rfq_service = RFQCreator()
                    output_file = rfq_service.exportRFQtoCSV(rfq, incoterms, port)

                    if os.path.exists(output_file):
                        with open(output_file, 'rb') as fh:
                            response = HttpResponse(fh.read(), content_type="application/vnd.ms-excel")
                        cleanup('/' + output_file)
                        response['Content-Disposition'] = 'inline; filename=' + os.path.basename(output_file)
                        return response
                    raise Http404

                else:
                    print("There is a backend error message")
                    return render(request, 'rfqs/rfq_export.html', {'menu_text': menu_texts.getComponent(),
                                                                    'view_texts': view_texts.getComponent(),
                                                                    'rfqform': form,
                                                                    'error_message': backend_message.getValue(),
                                                                    'instructions_title': instructions.getTitle(),
                                                                    'instructions_steps': instructions.getSteps()
                                                                    })

        else:
            form = RFQInternalCode()

        return render(request, 'rfqs/rfq_export.html', {'menu_text': menu_texts.getComponent(),
                                                        'view_texts': view_texts.getComponent(),
                                                        'rfqform': form,
                                                        'instructions_title': instructions.getTitle(),
                                                        'instructions_steps': instructions.getSteps()
                                                        })

    except ValueError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'rfqs/rfq_export.html', {'menu_text': menu_texts.getComponent(),
                                                        'view_texts': view_texts.getComponent(),
                                                        'error_message': 'Backend problem',
                                                        'instructions_title': instructions.getTitle(),
                                                        'instructions_steps': instructions.getSteps()
                                                        })

    except ConnectionError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'rfqs/rfq_upload.html', {'menu_text': menu_texts.getComponent(),
                                                        'view_texts': view_texts.getComponent(),
                                                        'error_message': 'Backend connection problem',
                                                        'instructions_title': instructions.getTitle(),
                                                        'instructions_steps': instructions.getSteps()
                                                        })

    except Exception as exception:
        cleanup(output_file)
        print(exception)
        return render(request, 'rfqs/rfq_upload.html', {'menu_text': menu_texts.getComponent(),
                                                        'view_texts': view_texts.getComponent(),
                                                        'error_message': "Frontend Error",
                                                        'instructions_title': instructions.getTitle(),
                                                        'instructions_steps': instructions.getSteps()
                                                        })
Ejemplo n.º 16
0
def provider_comment(request, code):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('providers', 'comment')
    try:

        if request.method == 'POST':

            comment_form = CommentForm(request.POST)

            if comment_form.is_valid():
                # ... update current provider with the data provided

                backend_host = MachineConfigurator().getBackend()

                creator = ProviderCreator()
                result = creator.createComment(comment_form)

                r = requests.post(backend_host + '/auth/providers/comments/' + code, json=result)

                backend_message = BackendMessage(json.loads(r.text))

                backend_result = json.loads(backend_message.getValue())

                return render(request, 'providers/provider_comment.html', {'menu_text': menu_texts.getComponent(),
                                                                           'view_texts': view_texts.getComponent(),
                                                                           'updated_providers': backend_result})

        form = CommentForm()
        return render(request, 'providers/provider_comment.html', {'menu_text': menu_texts.getComponent(),
                                                                   'view_texts': view_texts.getComponent(),
                                                                   'comment_form': form,
                                                                   'instructions_title': instructions.getTitle(),
                                                                   'instructions_steps': instructions.getSteps()})

    except ValueError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'providers/provider_comment.html', {'menu_text': menu_texts.getComponent(),
                                                                   'view_texts': view_texts.getComponent(),
                                                                   'error_message': 'Backend problem',
                                                                   'instructions_title': instructions.getTitle(),
                                                                   'instructions_steps': instructions.getSteps()
                                                                   })

    except ConnectionError as exception:
        print("Backend connection problem")
        print(exception)
        return render(request, 'providers/provider_comment.html', {'menu_text': menu_texts.getComponent(),
                                                                   'view_texts': view_texts.getComponent(),
                                                                   'error_message': 'Backend connection problem',
                                                                   'instructions_title': instructions.getTitle(),
                                                                   'instructions_steps': instructions.getSteps()
                                                                   })

    except Exception as exception:
        print(exception)
        return render(request, 'providers/provider_comment.html', {'menu_text': menu_texts.getComponent(),
                                                                   'view_texts': view_texts.getComponent(),
                                                                   'error_message': 'System error',
                                                                   'instructions_title': instructions.getTitle(),
                                                                   'instructions_steps': instructions.getSteps()
                                                                   })
Ejemplo n.º 17
0
def provider_editor(request, code):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('providers', 'edit')
    try:

        backend_host = MachineConfigurator().getBackend()

        r = requests.post(backend_host + '/auth/providers/' + code)

        backend_message = BackendMessage(json.loads(r.text))

        backend_result = json.loads(backend_message.getValue())

        provider_form = ProviderForm(initial=backend_result)

        if request.method == 'POST':

            provider_form = ProviderForm(request.POST)

            if provider_form.is_valid():
                # ... update current provider with the data provided
                print(code)

                creator = ProviderCreator()
                result = creator.createProvider(provider_form)
                result_json = []

                print(result)

                for provider in result:
                    result_json.append(json.dumps(provider))

                r = requests.put(backend_host + '/auth/providers/' + code, json=result)

                backend_message = BackendMessage(json.loads(r.text))

                backend_result = json.loads(backend_message.getValue())

                return render(request, 'providers/provider_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                          'view_texts': view_texts.getComponent(),
                                                                          'updated_providers': backend_result})

        return render(request, 'providers/provider_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                  'view_texts': view_texts.getComponent(),
                                                                  'provider_form': provider_form,
                                                                  'instructions_title': instructions.getTitle(),
                                                                  'instructions_steps': instructions.getSteps()})

    except ValueError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'providers/provider_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                  'view_texts': view_texts.getComponent(),
                                                                  'error_message': 'No such provider exists in the DB: '
                                                                                   + code,
                                                                  'instructions_title': instructions.getTitle(),
                                                                  'instructions_steps': instructions.getSteps()
                                                                  })

    except ConnectionError as exception:
        print("Backend connection problem")
        print(exception)
        return render(request, 'providers/provider_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                  'view_texts': view_texts.getComponent(),
                                                                  'error_message': 'Backend connection problem',
                                                                  'instructions_title': instructions.getTitle(),
                                                                  'instructions_steps': instructions.getSteps()
                                                                  })

    except Exception as exception:
        print(exception)
        return render(request, 'providers/provider_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                  'view_texts': view_texts.getComponent(),
                                                                  'error_message': 'System error',
                                                                  'instructions_title': instructions.getTitle(),
                                                                  'instructions_steps': instructions.getSteps()
                                                                  })
Ejemplo n.º 18
0
def quotes_upload(request):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('quotes', 'upload')
    uploaded_file_url = ''
    try:
        form = QuotesForm()
        if request.method == 'POST':
            form = QuotesForm(request.POST, request.FILES)
            if form.is_valid():

                quote = QuoteCreator()

                internal_code = form.cleaned_data['internalCode']
                external_code = form.cleaned_data['externalCode']
                provider_code = form.cleaned_data['providerCode']
                received_date = form.cleaned_data['receivedDate']
                sent_date = form.cleaned_data['sentDate']
                user = form.cleaned_data['user']
                provider_id = form.cleaned_data['providerId']
                provider_name = form.cleaned_data['providerName']
                contact_name = form.cleaned_data['contactName']
                incoterms = form.cleaned_data['incoterms']
                note = form.cleaned_data['note']
                edt = form.cleaned_data['edt']

                quote.setQuoteInformation(internal_code, external_code, provider_code, provider_id, provider_name,
                                          contact_name, received_date, sent_date, user, edt)
                quote.setQuoteIncoterms(incoterms)
                quote.setQuoteNote(note)

                myfile = request.FILES['document']
                fs = FileSystemStorage()
                filename = fs.save(myfile.name, myfile)
                uploaded_file_url = fs.url(filename)

                result = quote.createQuotefromCSV('.' + uploaded_file_url)

                # ...  print(json.dumps(result))
                backend_host = MachineConfigurator().getBackend()

                r = requests.post(backend_host + '/auth/quotes/', json=result)

                backend_message = BackendMessage(json.loads(r.text))

                cleanup(uploaded_file_url)

                backend_result = []

                if backend_message.errorInd:
                    display_message = {}
                    display_message['internalCode'] = internal_code
                    display_message['externalCode'] = external_code
                    display_message['status'] = backend_message.getValue()
                    backend_result.append(display_message)
                else:
                    backend_result = json.loads(backend_message.getValue())

                return render(request, 'quotes/quote_upload.html', {'menu_text': menu_texts.getComponent(),
                                                                    'view_texts': view_texts.getComponent(),
                                                                    'upload_result': backend_result})

        return render(request, 'quotes/quote_upload.html', {'menu_text': menu_texts.getComponent(),
                                                            'view_texts': view_texts.getComponent(),
                                                            'form': form,
                                                            'instructions_title': instructions.getTitle(),
                                                            'instructions_steps': instructions.getSteps()})

    except ValueError as exception:
        cleanup(uploaded_file_url)
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'quotes/quote_upload.html', {'menu_text': menu_texts.getComponent(),
                                                            'view_texts': view_texts.getComponent(),
                                                            'error_message': 'Backend problem',
                                                            'instructions_title': instructions.getTitle(),
                                                            'instructions_steps': instructions.getSteps()
                                                            })

    except ConnectionError as exception:
        cleanup(uploaded_file_url)
        print("Backend connection problem")
        print(exception)
        return render(request, 'quotes/quote_upload.html', {'menu_text': menu_texts.getComponent(),
                                                            'view_texts': view_texts.getComponent(),
                                                            'error_message': 'Backend connection problem',
                                                            'instructions_title': instructions.getTitle(),
                                                            'instructions_steps': instructions.getSteps()
                                                            })

    except Exception as exception:
        cleanup(uploaded_file_url)
        print(exception)
        return render(request, 'quotes/quote_upload.html', {'menu_text': menu_texts.getComponent(),
                                                            'view_texts': view_texts.getComponent(),
                                                            'error_message': 'General problem',
                                                            'instructions_title': instructions.getTitle(),
                                                            'instructions_steps': instructions.getSteps()
                                                            })
Ejemplo n.º 19
0
def rfq_material_editor(request, code):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('rfqs', 'edit')
    try:

        backend_host = MachineConfigurator().getBackend()

        r = requests.post(backend_host + '/auth/rfqs/' + code)

        backend_message = BackendMessage(json.loads(r.text))

        backend_result = json.loads(backend_message.getValue())

        material_data = backend_result['materialList']

        rfq_form = RFQFormOnlyinfo(initial=backend_result)

        MaterialFormSet = formset_factory(ExtMaterialForm, extra=0)
        materials_formset = MaterialFormSet(initial=material_data)

        if request.method == 'POST':

            rfq_form = RFQFormOnlyinfo(request.POST)

            materials_formset = MaterialFormSet(request.POST)

            if rfq_form.is_valid() and materials_formset.is_valid():
                # ... update current material with the data provided
                # ... send data to backend

                creator = RFQCreator()
                result = creator.editRFQwithMaterials(rfq_form, materials_formset, material_data)
                result_json = []

                for rfq in result:
                    result_json.append(json.dumps(rfq))

                r = requests.put(backend_host + '/auth/rfqs/' + code, json=result)

                backend_message = BackendMessage(json.loads(r.text))

                backend_result = json.loads(backend_message.getValue())

                return render(request, 'rfqs/rfq_material_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                         'view_texts': view_texts.getComponent(),
                                                                         'updated_materials': backend_result})

        return render(request, 'rfqs/rfq_material_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                 'view_texts': view_texts.getComponent(),
                                                                 'rfq_form': rfq_form,
                                                                 'materials_formset': materials_formset,
                                                                 'instructions_title': instructions.getTitle(),
                                                                 'instructions_steps': instructions.getSteps()})

    except ValueError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'rfqs/rfq_material_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                 'view_texts': view_texts.getComponent(),
                                                                 'error_message': 'No such RFQ exists in the DB: ' + code,
                                                                 'instructions_title': instructions.getTitle(),
                                                                 'instructions_steps': instructions.getSteps()})

    except ConnectionError as exception:
        print("Backend connection problem")
        print(exception)
        return render(request, 'rfqs/rfq_material_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                 'view_texts': view_texts.getComponent(),
                                                                 'error_message': 'Backend connection problem',
                                                                 'instructions_title': instructions.getTitle(),
                                                                 'instructions_steps': instructions.getSteps()})

    except Exception as exception:
        print(exception)
        return render(request, 'rfqs/rfq_material_editor.html', {'menu_text': menu_texts.getComponent(),
                                                                 'view_texts': view_texts.getComponent(),
                                                                 'error_message': 'System error',
                                                                 'instructions_title': instructions.getTitle(),
                                                                 'instructions_steps': instructions.getSteps()})
Ejemplo n.º 20
0
from django import forms
from .models import RFQ
from .choices import *
from common.FrontendTexts import FrontendTexts

view_texts = FrontendTexts('rfqs')


class RFQForm(forms.ModelForm):
    class Meta:
        model = RFQ
        labels = view_texts.getComponent()['simple_upload']['labels']
        fields = ('internalCode', 'externalCode', 'sender', 'company',
                  'receivedDate', 'note', 'document')


class RFQFormOnlyinfo(forms.ModelForm):
    class Meta:
        model = RFQ
        labels = view_texts.getComponent()['simple_upload']['labels']
        fields = ('internalCode', 'externalCode', 'sender', 'company',
                  'receivedDate', 'note')


class ExtMaterialForm(forms.Form):
    orderNumber = forms.CharField(max_length=255)
    itemcode = forms.CharField(max_length=255)
    quantity = forms.FloatField()
    unit = forms.CharField(max_length=255)

Ejemplo n.º 21
0
def rfq_upload(request):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('rfqs', 'upload')
    uploaded_file_url = ''
    try:

        if request.method == 'POST':
            form = RFQForm(request.POST, request.FILES)
            if form.is_valid():

                rfq = RFQCreator()

                internal_code = form.cleaned_data['internalCode']
                external_code = form.cleaned_data['externalCode']
                sender = form.cleaned_data['sender']
                company = form.cleaned_data['company']
                received_date = form.cleaned_data['receivedDate']
                note = form.cleaned_data['note']

                rfq.setRFQInformation(internal_code, external_code, sender, company, received_date)
                rfq.addRFQNote(note)

                myfile = request.FILES['document']
                fs = FileSystemStorage()
                filename = fs.save(myfile.name, myfile)
                uploaded_file_url = fs.url(filename)

                result = rfq.createRFQfromCSV('.' + uploaded_file_url)

                print(json.dumps(result))

                backend_host = MachineConfigurator().getBackend()
                r = requests.post(backend_host + '/auth/rfqs/', json=result)

                backend_message = BackendMessage(json.loads(r.text))

                cleanup(uploaded_file_url)

                backend_result = []

                if backend_message.errorInd:
                    display_message = {}
                    display_message['internalCode'] = internal_code
                    display_message['externalCode'] = external_code
                    display_message['status'] = backend_message.getValue()
                    backend_result.append(display_message)
                else:
                    backend_result = json.loads(backend_message.getValue())

                return render(request, 'rfqs/rfq_upload.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'upload_result': backend_result})
        else:
            form = RFQForm()

        return render(request, 'rfqs/rfq_upload.html', {'menu_text': menu_texts.getComponent(),
                                                        'view_texts': view_texts.getComponent(),
                                                        'form': form,
                                                        'instructions_title': instructions.getTitle(),
                                                        'instructions_steps': instructions.getSteps()
                                                        })

    except ValueError as exception:
        cleanup(uploaded_file_url)
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'rfqs/rfq_upload.html', {'menu_text': menu_texts.getComponent(),
                                                        'view_texts': view_texts.getComponent(),
                                                        'error_message': 'Backend problem',
                                                        'instructions_title': instructions.getTitle(),
                                                        'instructions_steps': instructions.getSteps()
                                                        })

    except ConnectionError as exception:
        cleanup(uploaded_file_url)
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'rfqs/rfq_upload.html', {'menu_text': menu_texts.getComponent(),
                                                        'view_texts': view_texts.getComponent(),
                                                        'error_message': 'Backend connection problem',
                                                        'instructions_title': instructions.getTitle(),
                                                        'instructions_steps': instructions.getSteps()
                                                        })

    except Exception as exception:
        cleanup(uploaded_file_url)
        print(exception)
        return render(request, 'rfqs/rfq_upload.html', {'menu_text': menu_texts.getComponent(),
                                                        'view_texts': view_texts.getComponent(),
                                                        'error_message': "Frontend Error",
                                                        'instructions_title': instructions.getTitle(),
                                                        'instructions_steps': instructions.getSteps()
                                                        })
Ejemplo n.º 22
0
from common.FrontendTexts import FrontendTexts

view_texts = FrontendTexts('materials')
labels = view_texts.getComponent()['selector']['choices']

ACTION_CHOICES = ((1, labels['edit']), (2, labels['weight']))

UNIT_CHOICES = ((1, "M"), (2, "M2"), (3, "M3"), (4, "EA"))
Ejemplo n.º 23
0
def rfq_basic_analyzer(request, code):
    menu_texts = FrontendTexts('menu')
    instructions = Instructions('rfqs', 'analyze')
    output_file = ''
    try:

        backend_host = MachineConfigurator().getBackend()

        r = requests.get(backend_host + '/auth/rfqs/analysis/' + code)

        backend_message = BackendMessage(json.loads(r.text))

        print(backend_message.getErrorInd())
        
        if not backend_message.getErrorInd():

            rfq = json.loads(backend_message.getValue())

            rfq_service = RFQCreator()
            output_file = rfq_service.runBasicAnalysis(rfq)

            if os.path.exists(output_file):
                with open(output_file, 'rb') as fh:
                    response = HttpResponse(fh.read(), content_type="application/vnd.ms-excel")
                cleanup('/' + output_file)
                response['Content-Disposition'] = 'inline; filename=' + os.path.basename(output_file)
                return response
            raise Http404

        return render(request, 'rfqs/rfq_basic_analysis.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'error_message': 'Backend problem - cannot create file',
                                                                'instructions_title': instructions.getTitle(),
                                                                'instructions_steps': instructions.getSteps()})

    except ValueError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'rfqs/rfq_basic_analysis.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'error_message': 'Backend problem',
                                                                'instructions_title': instructions.getTitle(),
                                                                'instructions_steps': instructions.getSteps()
                                                                })

    except ConnectionError as exception:
        print("There is a problem with the backend return value")
        print(exception)
        return render(request, 'rfqs/rfq_basic_analysis.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'error_message': 'Backend connection problem',
                                                                'instructions_title': instructions.getTitle(),
                                                                'instructions_steps': instructions.getSteps()
                                                                })

    except Exception as exception:
        cleanup(output_file)
        print(exception)
        return render(request, 'rfqs/rfq_basic_analysis.html', {'menu_text': menu_texts.getComponent(),
                                                                'view_texts': view_texts.getComponent(),
                                                                'error_message': "Frontend Error",
                                                                'instructions_title': instructions.getTitle(),
                                                                'instructions_steps': instructions.getSteps()
                                                                })
Ejemplo n.º 24
0
from django import forms
from .choices import *
from common.FrontendTexts import FrontendTexts

view_texts = FrontendTexts('materials')


class xcheckForm(forms.Form):
    labels = view_texts.getComponent()['singlexcheck']['labels']
    itemcode = forms.CharField(max_length=30, label=labels['code'])


class SelectorForm(forms.Form):
    labels = view_texts.getComponent()['selector']['labels']
    code = forms.CharField(max_length=255, label=labels['code'])
    action = forms.ChoiceField(choices=ACTION_CHOICES,
                               label=labels['action'],
                               initial='',
                               widget=forms.Select(),
                               required=True)


class MaterialForm(forms.Form):
    labels = view_texts.getComponent()['editor']['labels']
    itemcode = forms.CharField(max_length=255, label=labels['itemcode'])
    description = forms.CharField(max_length=500, label=labels['description'])
    type = forms.CharField(max_length=255, label=labels['type'])
    category = forms.CharField(max_length=255, label=labels['category'])
    dimensions = forms.CharField(max_length=255, label=labels['dimensions'])

Ejemplo n.º 25
0
from common.FrontendTexts import FrontendTexts
view_texts = FrontendTexts('providers')

category_labels = view_texts.getComponent()['creator']['choices']
action_labels = view_texts.getComponent()['selector']['choices']

CATEGORY_CHOICES = (
    (1, category_labels['materials']),
    (2, category_labels['transporters']),
)

ACTION_CHOICES = (
    (1, action_labels['edit']),
    (2, action_labels['comment']),
)

# ... country list extracted from file