Example #1
0
def get_all_users():
    context = {}
    users_list = []
    # Show all except system users (SmartGIS users)
    users = UserStorage.objects.select_related(
        'organizace', 'id').all().exclude(organizace=3)
    auth_records = dict(
        UserGroupAuthStorage.objects.filter(id__item_type=-10).values_list(
            'user_group', 'auth_level'))
    organizace = heslar_organizace()

    for user in users:
        for o in organizace:
            if o[0] == user.organizace.id:
                user.organizace_zkr = o[1]
                break
        auth_level = get_auth_level(user, auth_records)
        rolesAndPerm = doc_helper.get_roles_and_permissions(auth_level)
        user_dict = user.__dict__
        user_dict['role'] = rolesAndPerm['role']
        user_dict['opravneni'] = rolesAndPerm['opravneni']
        users_list.append(user_dict)

    context['uzivatele'] = users_list
    return context
Example #2
0
def archive(request, **kwargs):
    curr_user = kwargs['user']
    curr_role = helper_doc.get_roles_and_permissions(curr_user['auth'])['role']
    params_dict = {'stav': '3'}
    docArray = []
    if curr_role in ['Archivář', 'Admin']:
        docArray = table_view(request, params_dict)

    return render(request, 'detectors/archive.html', {'table': docArray})
Example #3
0
def confirm(request, **kwargs):
    curr_user = kwargs['user']
    curr_role = helper_doc.get_roles_and_permissions(curr_user['auth'])['role']
    params_dict = {
        'stav': '2',
        'predano_organizace': str(curr_user['organizace'])
    }
    docArray = []
    if curr_role in ['Archeolog', 'Archivář', 'Admin']:
        docArray = table_view(request, params_dict)

    return render(request, 'detectors/confirm.html', {'table': docArray})
Example #4
0
def cooperate(request, **kwargs):
    context = {}

    user = kwargs['user']
    curr_role = helper_doc.get_roles_and_permissions(user['auth'])['role']
    if (curr_role == "Admin"):
        context['canDelete'] = True
    else:
        context['canDelete'] = False

    spolupraceQ = models.VazbaSpoluprace.objects.all()
    organizaceQ = models.Organizace.objects.values_list('id',
                                                        'nazev_zkraceny',
                                                        named=True)

    if curr_role in ('Badatel', 'Archeolog'):
        spolupraceQ = spolupraceQ.filter(
            Q(badatel=user['id']) | Q(archeolog=user['id']))
    spoluprace = spolupraceQ.values('id', 'badatel', 'archeolog', 'aktivni',
                                    'potvrzeno', 'datum_vytvoreni')

    for s in spoluprace:
        badatel = models.UserStorage.objects.get(pk=s['badatel'])
        archeolog = models.UserStorage.objects.get(pk=s['archeolog'])
        badatelOrg = organizaceQ.get(pk=badatel.organizace.id)
        archeologOrg = organizaceQ.get(pk=archeolog.organizace.id)
        s['badatel'] = badatel.prijmeni + ', ' + badatel.jmeno
        s['badatel_organizace'] = badatelOrg.nazev_zkraceny
        s['badatel_email'] = badatel.email
        s['archeolog'] = archeolog.prijmeni + ', ' + archeolog.jmeno
        s['archeolog_organizace'] = archeologOrg.nazev_zkraceny
        s['archeolog_email'] = archeolog.email
        s['aktivni'] = c.BOOL_DICT[s['aktivni']]
        s['potvrzeno'] = c.BOOL_DICT[s['potvrzeno']]
        s['badatel_ident'] = badatel.ident_cely
        s['archeolog_ident'] = archeolog.ident_cely
        s['datum_vytvoreni'] = helper_doc.epoch_timestamp_to_datetime(
            s['datum_vytvoreni'])
        s['zmena_potvrzeni'] = models.HistorieSpoluprace.objects.filter(
            vazba_spoluprace=s['id'],
            typ_zmeny=det_const.SPOLUPRACE_POTVRZENI).order_by(
                'datum_zmeny').last()

    context['spoluprace'] = spoluprace

    return render(request, 'detectors/cooperate.html', {'context': context})
Example #5
0
def load_my_projects(badatel_id, projects):
    my_projects = []
    my_links = []
    curr_auth = get_object_or_404(
        models.UserGroupAuthStorage,
        Q(id__item_type=-10) & Q(user_group=badatel_id)).auth_level
    curr_role = helper.get_roles_and_permissions(curr_auth)['role']
    if curr_role in (c.ARCHIVAR, c.ADMIN):
        return projects  # Archivar and Admin can see all projects
    else:
        try:
            if curr_role == c.BADATEL:  # Badatel can see projects if he has active coorporation with archeolog, organization of this archeolog created this project
                my_links = load_my_active_links(badatel_id)
                # Removing duplicate links (when two cooperations are with archeologists from the same organization)
                my_organizations = set()
                for link in my_links:
                    my_organizations.add(link[2])
                for one_project in projects:
                    project_organizace = models.UserStorage.objects.get(
                        id=one_project['odpovedny_pracovnik_prihlaseni']
                    ).organizace.id
                    for organization in my_organizations:
                        if organization == project_organizace:
                            my_projects.append(one_project)
                return my_projects
            elif curr_role == c.ARCHEOLOG:  # Archeolog can see all projects his organization
                for one_project in projects:
                    project_organizace = models.UserStorage.objects.get(
                        id=one_project['odpovedny_pracovnik_prihlaseni']
                    ).organizace.id
                    organizace_archeolog = models.UserStorage.objects.get(
                        id=badatel_id).organizace.id
                    if project_organizace == organizace_archeolog:
                        my_projects.append(one_project)
                return my_projects
            else:
                return my_projects

        except:
            #print("----chyba load_my_projects")
            # print(sys.exc_info())
            return my_projects
Example #6
0
def create(request, ident_cely='0', **kwargs):
    projekt_id = []
    user_sid = request.COOKIES.get('sessionId')
    current_user = kwargs['user']
    user_id = str(current_user['id'])
    user = get_object_or_404(models.UserStorage, pk=user_id)
    if request.method == 'POST':
        # create FORM
        form = make_CreateDetectorForm(user_id, user_sid, request.POST)

        if form.is_valid():
            detector_project = form.data.get('detector_project')
            detector_localization = form.data.get('detector_localization')
            detector_coordinates_x = form.data.get('detector_coordinates_x')
            detector_coordinates_y = form.data.get('detector_coordinates_y')
            detector_finder = form.data.get('detector_finder')
            detector_find_date = form.data.get('detector_find_date')
            detector_circumstances = form.data.get('detector_circumstances')
            detector_depth = form.data.get('detector_depth')
            detector_dating = form.data.get('detector_dating')
            detector_exact_dating = form.data.get('detector_exact_dating')
            detector_kind = form.data.get('detector_kind')
            detector_material = form.data.get('detector_material')
            detector_quantity = form.data.get('detector_quantity')
            detector_note = form.data.get('detector_note')
            detector_organisation_passed = form.data.get(
                'detector_organisation_passed')
            detector_evidence_number = form.data.get(
                'detector_evidence_number')
            detector_find_passed = form.data.get('detector_find_passed')
            detector_accessibility = form.data.get('detector_accessibility')

            params = {}
            if (detector_project):
                params['projekt'] = str(detector_project)
            if (detector_localization):
                params['lokalizace'] = str(detector_localization)
            params['katastr'] = '-1'
            if (detector_coordinates_x and detector_coordinates_y):
                params['zswgs'] = str(detector_coordinates_x)
                params['zdwgs'] = str(detector_coordinates_y)
            if (detector_finder):
                params['nalezce'] = str(detector_finder)
            if (detector_find_date):
                params['datum_nalezu'] = helper_doc.date_to_psql_date(
                    str(detector_find_date))
            else:
                params['datum_nalezu'] = '__NULL__'
            if (detector_circumstances):
                params['okolnosti'] = str(detector_circumstances)
            else:
                params['okolnosti'] = '__NULL__'
            if (detector_depth):
                params['hloubka'] = str(detector_depth)
            if (detector_dating):
                params['obdobi'] = str(detector_dating)
            else:
                params['obdobi'] = '__NULL__'
            if (detector_exact_dating):
                params['presna_datace'] = str(detector_exact_dating)
            if (detector_kind):
                params['druh_nalezu'] = str(detector_kind)
            else:
                params['druh_nalezu'] = '__NULL__'
            if (detector_material):
                params['specifikace'] = str(detector_material)
            else:
                params['specifikace'] = '__NULL__'
            if (detector_quantity):
                params['pocet'] = str(detector_quantity)
            if (detector_note):
                params['poznamka'] = str(detector_note)
            if (detector_organisation_passed):
                params['predano_organizace'] = str(
                    detector_organisation_passed)
            if (detector_evidence_number):
                params['inv_cislo'] = str(detector_evidence_number)
            if (detector_find_passed):
                if str(detector_find_passed) == 'True':
                    params['predano'] = 'true'
                else:
                    params['predano'] = 'false'
            if (detector_accessibility):
                params['pristupnost'] = str(detector_accessibility)

            if (ident_cely == '0'):
                # I am creating the object
                ret = helper_det.zapsani(params, user, user_sid)

                if ret:
                    ident_cely = ret.ident_cely
                    messages.add_message(request, messages.SUCCESS,
                                         c.OBJECT_CREATED_SUCCESSFULLY)
                else:
                    ident_cely = ''
                    logger.error("Nepovedlo se vytvorit samostatny nalez")
                    messages.add_message(request, messages.WARNING,
                                         c.OBEJCT_COULD_NOT_BE_CREATED)
            else:
                params['ident_cely'] = ident_cely
                nalez = models.SamostatnyNalez.objects.get(
                    ident_cely=ident_cely)
                params['id'] = nalez.id
                params['stav'] = nalez.stav

                if 'button_save' in request.POST:
                    ret = helper_det.update(params, nalez, user, user_sid)
                elif 'button_send_to_confirm' in request.POST:
                    ret = helper_det.odeslani(params, nalez, user, user_sid)
                elif 'button_confirm' in request.POST:
                    ret = helper_det.potvrzeni(params, nalez, user, user_sid)
                elif 'button_archive' in request.POST:
                    ret = helper_det.archivace(params, nalez, user, user_sid)
                else:
                    logger.debug("Unknown post request button type")

                if 'button_delete' in request.POST:
                    resp = nalez.delete()
                    if resp[0] > 0:
                        logger.debug("Objekt " + str(resp) + ' smazán')
                        messages.add_message(request, messages.SUCCESS,
                                             c.OBJECT_DELETED_SUCCESSFULLY)
                        return redirect('/pas/create/')
                    else:
                        messages.add_message(request, messages.WARNING,
                                             c.OBEJCT_COULD_NOT_BE_DELETED)

            return redirect('/pas/create/' + ident_cely)

        logger.warning('Form create is not valid')
        logger.warning(form.errors)
        logger.warning(form.non_field_errors)
        return render(request, 'detectors/create.html',
                      {'formDetCreate': form})

    elif request.method == 'GET':
        addNameForm = AddNameForm()
        context = {}
        if (ident_cely == '0'):
            formDetCreate = make_CreateDetectorForm(
                user_id,
                user_sid,
                initial={
                    'detector_find_passed':
                    False,
                    'detector_finder':
                    str(connector.get_id_name_by_user_id(user_id)),
                    'detector_accessibility':
                    3,  # Admin
                },
                editProject=True)
            context['showFiles'] = 'False'
            context['archivovano'] = False

        else:
            # Detail
            context['showFiles'] = 'True'
            nalez = get_object_or_404(models.SamostatnyNalez,
                                      ident_cely=ident_cely)
            context[
                'archivovano'] = True if nalez.stav == det_const.ARCHIVOVANY else False
            id_nalez = nalez.id
            resp = xmlrpc.nacti_informace_list(user_sid, 'detektor',
                                               [id_nalez])
            db_param = resp[0]['0']
            coor = db_param['geom'].replace(")", "").replace("POINT(",
                                                             "").split(" ")
            #print(db_param)
            userArchive = get_object_or_404(
                models.UserStorage,
                pk=db_param['odpovedny_pracovnik_archivace'])
            # Now assuming id of the organisation is the same as id of the atree object
            orgArch = get_object_or_404(models.Organizace,
                                        pk=userArchive.organizace.id)
            userAdded = get_object_or_404(
                models.UserStorage, pk=db_param['odpovedny_pracovnik_vlozeni'])
            orgAdd = get_object_or_404(models.Organizace,
                                       pk=userAdded.organizace.id)
            if len(coor) == 1:
                coor = ['', '']

            param = {
                'detector_project':
                db_param['projekt'],
                'detector_localization':
                db_param['lokalizace'],
                'detector_coordinates_x':
                coor[1],
                'detector_coordinates_y':
                coor[0],
                'detector_finder':
                db_param['nalezce'],
                'detector_find_date':
                helper_doc.date_from_psql_date(db_param['datum_nalezu']),
                'detector_circumstances':
                db_param['okolnosti'],
                'detector_depth':
                db_param['hloubka'],
                'detector_dating':
                db_param['obdobi'],
                'detector_exact_dating':
                db_param['presna_datace'],
                'detector_kind':
                db_param['druh_nalezu'],
                'detector_material':
                db_param['specifikace'],
                'detector_quantity':
                db_param['pocet'],
                'detector_note':
                db_param['poznamka'],
                'detector_organisation_passed':
                db_param['predano_organizace'],
                'detector_find_passed':
                False if db_param['predano'] == 'f' else db_param['predano'],
                'detector_evidence_number':
                '' if db_param['inv_cislo'] == '-1' else db_param['inv_cislo'],
                'detector_accessibility':
                db_param['pristupnost']
            }

            try:
                if db_param['katastr'] != '-1':
                    param['detector_cadastry'] = c.CADASTRY_DICT[int(
                        db_param['katastr'])]
            except KeyError:
                logger.debug("Unknown cataster id: " + db_param['katastr'])

            projekt_id = db_param['projekt']
            soubory = models.Soubor.objects.filter(samostatny_nalez=id_nalez)
            context['soubory'] = soubory
            if (not resp[0]):
                raise Http404()
            formDetCreate = make_CreateDetectorForm(user_id,
                                                    user_sid,
                                                    initial=param)

    curr_role = helper_doc.get_roles_and_permissions(
        current_user['auth'])['role']
    if (ident_cely == '0'):
        return render(
            request, 'detectors/create.html', {
                'canEdit': True,
                'canConfirm': False,
                'canArchive': False,
                'canUnarchive': False,
                'canProject': True,
                'smStav': 0,
                'ident_cely': '0',
                'projectId': 's',
                'addNameForm': addNameForm,
                'formDetCreate': formDetCreate,
                'context': context
            })

    # print("---+++++++++++++++++----")
    # print("user = "******"role = "+curr_role)
    # print("organizace = "+str(curr_user['organizace']))
    # print("SM stav = "+db_param['stav'])
    # print("SM nalezce = "+str(db_param['nalezce']))
    # print("SM organizace = "+str(db_param['predano_organizace']))

    # detector state in header
    detStav = int(db_param['stav'])
    states_dict = dict(det_const.DETECTOR_STATE_CACHE)
    currentStav = states_dict[detStav]
    isOwner = str(db_param['odpovedny_pracovnik_vlozeni']) == str(
        current_user['id'])
    isFromOrganisation = str(db_param['predano_organizace']) == str(
        current_user['organizace'])
    isBadatel = curr_role == c.BADATEL
    isArcheolog = curr_role == c.ARCHEOLOG
    isArchivar = curr_role == c.ARCHIVAR
    isAdmin = curr_role == c.ADMIN

    if (str(db_param['stav']) == str(det_const.ZAPSANY) and isOwner) or (
            str(db_param['stav']) != str(det_const.ARCHIVOVANY) and
        (isArchivar or isAdmin)):
        canEdit = True
    else:
        canEdit = False

    if (str(db_param['stav']) == str(det_const.ODESLANY)
            and curr_role == 'Archeolog' and isFromOrganisation) or (
                str(db_param['stav']) != str(det_const.ARCHIVOVANY)
                and curr_role in ['Archivář', 'Admin']):
        canConfirm = True
    else:
        canConfirm = False

    if str(db_param['stav']) == str(
            det_const.POTVRZENY) and curr_role in ['Archivář', 'Admin']:
        canArchive = True
    else:
        canArchive = False
    if str(db_param['stav']) == str(
            det_const.ARCHIVOVANY) and curr_role in ['Archivář', 'Admin']:
        canUnarchive = True
    else:
        canUnarchive = False

    canSeeDetail = (isOwner and isBadatel) or (
        isArcheolog and isFromOrganisation) or isArchivar or isAdmin
    #print("canEdit= "+str(canEdit));
    #print("canConfirm= "+str(canConfirm));
    #print("canArchive= "+str(canArchive));

    if canSeeDetail:
        return render(
            request,
            'detectors/create.html',
            {
                'canEdit': canEdit,  # Pokud jsem vlastnikem
                'canConfirm':
                canConfirm,  # pokud jsem archeol & mam stejnou organizaci jako SN
                'canArchive': canArchive,  # pokud jsem archiv
                'canUnarchive': canUnarchive,
                'canProject': True if ident_cely == '0' else False,
                'smStav': int(db_param['stav']),
                'currentStav': currentStav,
                'ident_cely': ident_cely,
                'projectId': projekt_id,
                'addNameForm': addNameForm,
                'formDetCreate': formDetCreate,
                'context': context
            })
    else:
        return render(request, '403.html')
Example #7
0
def choose(request, **kwargs):
    user_sid = request.COOKIES.get('sessionId')
    curr_user = kwargs['user']
    user_id = str(curr_user['id'])
    if request.method == 'POST':
        form = make_ChooseDetectorForm(user_id, user_sid, request.POST)
        if form.is_valid():
            detector_project_id = form.data.get('detector_project_id')
            detector_finding_id = form.data.get('detector_finding_id')
            detector_process_state = form.data.get('detector_process_state')
            detector_region = form.data.get('detector_region')
            detector_district = form.data.get('detector_district')
            detector_finder = form.data.get('detector_finder')
            detector_date_of_change_from = form.data.get(
                'detector_date_of_change_from')
            detector_date_of_change_to = form.data.get(
                'detector_date_of_change_to')
            detector_find_date_from = form.data.get('detector_find_date_from')
            detector_find_date_to = form.data.get('detector_find_date_to')
            detector_description_details = form.data.get(
                'detector_description_details')
            detector_dating = form.data.get('detector_dating')
            detector_kind = form.data.get('detector_kind')
            detector_material = form.data.get('detector_material')
            detector_organisation = form.data.get('detector_organisation')
            detector_project_leader = form.data.get('detector_project_leader')
            detector_evidence_number = form.data.get(
                'detector_evidence_number')
            detector_find_passed = form.data.get('detector_find_passed')
            detector_accessibility = form.data.get('detector_accessibility')

            params = {}
            params['stav'] = '-1'
            params['predano'] = '-1'
            # Parameters retrieved from the form that are non are ignored
            if (detector_project_id):
                params['projekt_ident'] = str(detector_project_id)
            if (detector_finding_id):
                params['ident_cely'] = str(detector_finding_id)
            if (detector_process_state):
                params['stav'] = str(detector_process_state)
            if (detector_region):
                params['region'] = str(detector_region)
            if (detector_district):
                params['okres'] = str(detector_district)
            if (detector_finder):
                params['nalezce'] = str(detector_finder)
            if (detector_date_of_change_from):
                params['datum_zmeny_od'] = helper_doc.date_to_psql_date(
                    str(detector_date_of_change_from))
            if (detector_date_of_change_to):
                params['datum_zmeny_do'] = helper_doc.date_to_psql_date(
                    str(detector_date_of_change_to))
            if (detector_find_date_from):
                params['datum_nalezu_od'] = str(detector_find_date_from)
            if (detector_find_date_to):
                params['datum_nalezu_do'] = str(detector_find_date_to)
            if (detector_description_details):
                params['popis'] = str(detector_description_details)
            if (detector_dating):
                params['obdobi'] = str(detector_dating)
            if (detector_kind):
                params['druh_nalezu'] = str(detector_kind)
            if (detector_material):
                params['specifikace'] = str(detector_material)
            if (detector_organisation):
                params['predano_organizace'] = str(detector_organisation)
            if (detector_project_leader):
                params['projekt_vedouci'] = str(detector_project_leader)
            if (detector_evidence_number):
                params['inv_cislo'] = str(detector_evidence_number)
            if (detector_find_passed):
                if str(detector_find_passed) == 'True':
                    params['predano'] = 'true'
                elif str(detector_find_passed) == 'False':
                    params['predano'] = 'false'
            if (detector_accessibility):
                params['pristupnost'] = str(detector_accessibility)
            curr_role = helper_doc.get_roles_and_permissions(
                curr_user['auth'])['role']
            if curr_role in ['Badatel']:
                params['odpovedny_pracovnik_vlozeni'] = str(curr_user['id'])
            elif curr_role in ['Archeolog']:
                params['predano_organizace'] = str(curr_user['organizace'])

            docArray = table_view(request, params)
            return render(request, 'detectors/list.html', {'table': docArray})

        print('Form is not valid')
        print(form.errors)

    else:
        formChoose = make_ChooseDetectorForm(user_id, user_sid, initial={})
    return render(request, 'detectors/choose.html', {'formChoose': formChoose})
Example #8
0
def user_edit(request, pk, **kwargs):

    message = {}
    sid = request.COOKIES.get('sessionId')
    user = get_object_or_404(UserStorage, pk=pk)
    auth_records = dict(
        m.UserGroupAuthStorage.objects.filter(id__item_type=-10).values_list(
            'user_group', 'auth_level'))

    # What is auth_level of the user
    auth_level = user_helper.get_auth_level(user, auth_records)

    rolesAndPerm = doc_helper.get_roles_and_permissions(auth_level)
    permissions = []
    for perm in rolesAndPerm['opravneni']:
        permissions.append(str(c.USER_PERMISSIONS_DICT[perm]))

    if (request.method == 'POST'):

        form = EditUserForm(request.POST)

        if form.is_valid():

            params = {'id': user.id.id}

            manage_username = form.cleaned_data['manage_username']
            manage_surname = form.cleaned_data['manage_surname']
            manage_phone_number = form.cleaned_data['manage_phone_number']
            manage_password = form.cleaned_data['manage_password']
            manage_password_control = form.cleaned_data[
                'manage_password_control']
            manage_organization = form.cleaned_data['manage_organization']
            manage_email = form.cleaned_data['manage_email']
            manage_role_id = form.cleaned_data['manage_role']
            manage_permissions = form.cleaned_data['manage_permissions']

            # Check that the passwords are the same
            if manage_password != manage_password_control:
                logger.debug("Hesla se neshodují")
                form.add_error('manage_password_control',
                               _('Hesla se neshodují'))
            else:

                # Getting auth level based on roles and permissions
                authLevel = helper.build_auth_level(manage_role_id,
                                                    manage_permissions)

                # Check what has been changed
                if manage_username != user.jmeno:
                    params['jmeno'] = manage_username
                if manage_surname != user.prijmeni:
                    params['prijmeni'] = manage_surname
                if manage_phone_number != user.telefon:
                    params['telefon'] = manage_phone_number
                if int(manage_organization) != user.organizace.id:
                    params['organizace'] = manage_organization
                if manage_email != user.email:
                    params['email'] = manage_email
                if (int(manage_role_id) !=
                        c.USER_ROLES_DICT[rolesAndPerm['role']]) or (
                            manage_permissions != permissions):
                    params['auth'] = authLevel

                    # Now if 'Spravce 3D' vas removed or added send notifiaction
                    # was_added = str(c.ADMIN3D_ID) in manage_permissions and str(c.ADMIN3D_ID) not in permissions
                    # was_removed = str(c.ADMIN3D_ID) in permissions and str(c.ADMIN3D_ID) not in manage_permissions
                    # if was_added:
                    #     # Added
                    #     email_send_3D3.delay(user.email)
                    # elif was_removed:
                    #     # Removed
                    #     email_send_3D4.delay(user.email)

                if (len(manage_password) > 0) and (manage_password !=
                                                   user.pasw):
                    params['pasw'] = hashlib.sha1(
                        manage_password.encode('utf8')).hexdigest()

                # Update the user using xmlrpc request
                resp = xmlrpc.zmena(sid, 'uzivatel', 'update', params)

                if resp[0]:
                    logger.debug("User with id updated: " + str(resp[1]))
                    message['type'] = c.SUCCESS
                    message['text'] = c.OBJECT_UPDATED_SUCCESSFULLY
                else:
                    logger.debug("Could not update user: "******"Form is not valid")
    else:

        # Create form
        form = EditUserForm({
            'manage_username':
            user.jmeno,
            'manage_surname':
            user.prijmeni,
            'manage_organization':
            user.organizace.id,
            'manage_email':
            user.email,
            'manage_permissions':
            permissions,
            'manage_role':
            c.USER_ROLES_DICT[rolesAndPerm['role']],
            'manage_phone_number':
            user.telefon
        })

        print(form.errors)

    return render(request, 'amcrusers/user_create.html', {
        'form': form,
        'context': {
            'title': _('Editace uživatele'),
        }
    })