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
def __init__(self, *args, readonly=False, **kwargs): super().__init__(*args, **kwargs) self.fields['organizace_autora'] = forms.ChoiceField( label=_('Organizace'), choices=heslar_organizace(), required=True) self.fields['zeme'] = forms.ChoiceField(label=_('Země'), choices=heslar_zeme(), required=False) self.fields['format'] = forms.ChoiceField( label=_('Formát'), choices=heslar_format_dokumentu(), required=True) self.fields['typ_dokumentu'] = forms.ChoiceField( label=_('Typ dokumentu'), choices=heslar_typ_dokumentu(), required=True) self.fields['obdobi'] = forms.CharField( label=_('Období'), widget=forms.Select(choices=heslar_obdobi_12()), required=False) self.fields['areal'] = forms.CharField( label=_('Areál'), widget=forms.Select(choices=heslar_areal_12()), required=False) for key in self.fields.keys(): self.fields[key].disabled = readonly
class ChooseDetectorForm(forms.Form): detector_project_id = forms.CharField(label=_('Projekt'), required=False) detector_finding_id = forms.CharField(label=_('ID nálezu'), required=False) detector_process_state = forms.ChoiceField( label=_('Procesní stavy'), choices=[('', '')] + det_const.DETECTOR_STATE_CACHE, required=False) #detector_cadastry = forms.ChoiceField(label=_('Katastrální území'), choices=[ # ('', '')] + c.CADASTRE_12_CACHE, required=False) detector_district = forms.ChoiceField(label=_('Okres'), choices=heslar_spz_storage(), required=False) detector_watch_changes = forms.CharField(label=_('Sledovat změny'), required=False) detector_finder = forms.ChoiceField(label=_('Nálezce'), choices=[(-1, '')] + list(connector.prijmeni_jmeno()), required=True) detector_date_of_change_from = forms.CharField( label=_('Datum změny od'), required=False) detector_date_of_change_to = forms.CharField(label=_('Datum změny do'), required=False) detector_find_date_from = forms.CharField(label=_('Nalezeno od'), required=False) detector_find_date_to = forms.CharField(label=_('Nalezeno do'), required=False) detector_description_details = forms.CharField( label=_('Popisné údaje'), required=False) detector_dating = forms.CharField( label=_('Období'), widget=forms.Select(choices=heslar_obdobi_12()), required=False) detector_kind = forms.ChoiceField(label=_('Nález'), choices=heslar_predmet_12(), required=False) detector_material = forms.ChoiceField( label=_('Materiál'), choices=heslar_specifikace_predmetu(), required=False) detector_organisation = forms.ChoiceField(label=_('Organizace'), choices=heslar_organizace(), required=False) detector_project_leader = forms.ChoiceField( label=_('Vedoucí projektu'), choices=[(-1, '')] + list(connector.prijmeni_jmeno()), required=False) detector_evidence_number = forms.CharField(label=_('Evidenční číslo'), required=False) detector_find_passed = forms.ChoiceField( label=_('Předáno'), choices=c.BOOL_WITH_BOTH_CHOICES, required=False) detector_accessibility = forms.ChoiceField( label=_('Přístupnost'), choices=heslar_pristupnost(), required=False)
def my_models(request, **kwargs): context = {} current_user = kwargs['user'] o = Dokument.objects.select_related('extradata').filter( rada_id=c.MODELY_DOCUMENTS_ID).filter( odpovedny_pracovnik_vlozeni=current_user['id']) context['table'] = o context['doc_states'] = c.DOCUMENT_STATE_DICT context['org_dict'] = dict(heslar_organizace()) context['active_items'] = [c.MENU_LIBRARY, c.MENU_LIST_3D] return render(request, 'documents/list.html', {'context': context})
def manage_models(request, **kwargs): context = {} current_user = kwargs['user'] role_opravneni = helper.get_roles_and_permissions(int( current_user['auth'])) if c.ADMIN3D in role_opravneni['opravneni']: o = Dokument.objects.select_related('extradata').filter( rada_id=c.MODELY_DOCUMENTS_ID).filter(stav=c.SENT_STATE_ID) context['table'] = o context['doc_states'] = c.DOCUMENT_STATE_DICT context['org_dict'] = dict(heslar_organizace()) context['active_items'] = [c.MENU_LIBRARY, c.MENU_MANAGE_3D] return render(request, 'documents/list.html', {'context': context})
def choose(request, *args, **kwargs): sid = request.COOKIES.get('sessionId') context = {} names = xmlrpc.get_list(sid, 'jmena', 'prijmeni', 'jmeno') users = UserStorage.objects.all().order_by('prijmeni').values( 'id', 'prijmeni', 'jmeno', 'ident_cely') usersList = [] for user in users: if user['id'] != -1: usersList.append((user['id'], user['prijmeni'] + ", " + user['jmeno'] + " (" + user['ident_cely'] + ")")) if request.method == 'POST': form = ChooseForm(request.POST, names=names, users=usersList) if form.is_valid(): o = Dokument.objects.filter( rada_id=c.MODELY_DOCUMENTS_ID).select_related('extradata') o = filter_documents(o, form.cleaned_data) context['table'] = o context['doc_states'] = c.DOCUMENT_STATE_DICT context['org_dict'] = dict(heslar_organizace()) context['active_items'] = [c.MENU_LIBRARY, c.MENU_CHOOSE_3D] return render(request, 'documents/list.html', {'context': context}) else: logger.debug('Form is not valid') logger.debug(form.errors) messages.add_message(request, messages.WARNING, c.FORM_IS_NOT_VALID) else: formChoose = ChooseForm(names=names, users=usersList) return render(request, 'documents/choose.html', { 'formChoose': formChoose, })
def __init__(self, *args, names, users, **kwargs): super().__init__(*args, **kwargs) self.fields['autori'] = forms.MultipleChoiceField(label=_("Autoři"), required=False, choices=names) self.fields['zmena_uzivatel'] = forms.ChoiceField(label=_("Uživatel"), required=False, choices=[('', '')] + users) self.fields['organizace'] = forms.ChoiceField( label=_('Organizace'), choices=heslar_organizace(), required=False) self.fields['specifikace_predmetu'] = forms.MultipleChoiceField( label=_('Specifikace předmětu'), choices=heslar_specifikace_predmetu(), required=False) self.fields['typ_dokumentu'] = forms.ChoiceField( label=_('Typ dokumentu'), choices=heslar_typ_dokumentu(), required=False) self.fields['druh_objektu'] = forms.CharField( label=_('Druh objektu'), widget=forms.Select(choices=heslar_objekt_12()), required=False) self.fields['druh_predmetu'] = forms.CharField( label=_('Druh předmětu'), widget=forms.Select(choices=heslar_predmet_12()), required=False) self.fields['obdobi'] = forms.MultipleChoiceField( label=_('Období'), choices=heslar_obdobi_12(), required=False) self.fields['areal'] = forms.CharField( label=_('Areál'), widget=forms.Select(choices=heslar_areal_12()), required=False) self.fields['specifikace_objektu'] = forms.CharField( label=_('Specifikace objektu'), widget=forms.Select(choices=heslar_specifikace_objektu_12()), required=False)
class CreateDetectorForm(forms.Form): projekty = connector.projekty_vyzkumne() if editProject: # zapisuju novy nalez projekty = connector.projekty_zahajene_ukoncene_v_terenu(projekty) projekty = connector.load_my_projects(str(user_id), projekty) projekt_choices = [ (i['id'], i['ident_cely'] + ' (' + connector.get_vypis_cely_by_id_name(i['vedouci_projektu']) + ')') for i in projekty ] detector_project = forms.ChoiceField( label=_('Projekt'), choices=[('', '')] + projekt_choices, required=True, ) detector_cadastry = forms.CharField( label=_('Katastrální území'), widget=forms.TextInput( attrs={'placeholder': _('Vyplněno automaticky')}), required=False) detector_localization = forms.CharField( label=_('Lokalizace'), required=False, widget=forms.TextInput( attrs={ 'title': _("Slovní popis lokalizace formou parcelního čísla a/nebo pomístního jména (jména ulic, tratí, poloh)." ) }), ) detector_system_coordinates = forms.ChoiceField( label=_('Souř. systém'), choices=c.COORDINATE_SYSTEM_CACHE, required=False) detector_coordinates_x = forms.CharField(label=_('Šířka (N / Y)'), required=False) detector_coordinates_y = forms.CharField(label=_('Délka (E / X)'), required=False) detector_finder = forms.ChoiceField(label=_('Nálezce'), choices=connector.prijmeni_jmeno(), required=False) detector_find_date = forms.CharField(label=_('Datum nálezu'), required=False) detector_circumstances = forms.ChoiceField( label=_('Nálezové okolnosti'), choices=heslar_nalezove_okolnosti(), required=False) detector_depth = forms.IntegerField( min_value=0, max_value=2147483647, label=_('Hloubka (cm)'), required=False, widget=forms.TextInput( attrs={ 'title': _("Přibližná hloubka, ze které byl nález získán. Povrchové nálezy označte hloubkou 0." ) }), ) detector_dating = forms.CharField( label=_('Období'), widget=forms.Select(choices=heslar_obdobi_12()), required=False) detector_exact_dating = forms.CharField( label=_('Přesná datace'), required=False, widget=forms.TextInput( attrs={ 'title': _("Upřesněná datace, např. pomocí roku (pro mince) nebo stupňů (Lt B2/C1; nikoli však pouze B2/C1)." ) }), ) detector_kind = forms.CharField( label=_('Nález'), widget=forms.Select(choices=heslar_predmet_12()), required=False) detector_material = forms.ChoiceField( label=_('Materiál'), choices=heslar_specifikace_predmetu(), required=False) detector_quantity = forms.CharField(label=_('Počet'), required=False) detector_note = forms.CharField( label=_('Poznámka / bližší popis'), required=False, widget=forms.TextInput( attrs={ 'title': _("Interpretace či bližší popis nálezu a jeho okolností.") }), ) detector_photo = forms.ImageField(required=False) detector_organisation_passed = forms.ChoiceField( label=_('Předáno organizaci'), choices=heslar_organizace(), required=False, ) detector_evidence_number = forms.CharField( label=_('Evidenční číslo'), required=False, widget=forms.TextInput( attrs={ 'title': _("Označení nálezu v organizaci, které byl předán. V případě využití čísla podle AMČR-PAS doplňte pouze \"PAS\"." ) }), ) detector_find_passed = forms.ChoiceField(label=_('Nález předán'), choices=c.BOOL_CHOICES, required=False) detector_accessibility = forms.ChoiceField( label=_('Přístupnost'), choices=heslar_pristupnost(), required=False) detector_type = forms.ChoiceField(label=_('Typ nálezu'), choices=heslar_typ_nalezu(), required=False)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['manage_organization'] = forms.ChoiceField(label=_('Organizace'), choices=heslar_organizace(), required=False)
def table_view(request, params_dict): detektors = connector.detector(request, params_dict) language = translation.get_language() docArray = [] NAME_CACHE = dict(helper_doc.load_name_cache()) organizace = heslar_organizace() predmet_druhy = HeslarPredmetDruh.objects.all() odbodi_druha = HeslarObdobiDruha.objects.all() specofikace_druha = HeslarSpecifikacePredmetu.objects.all() for det in detektors: f_data = det['0'] try: for i in det_const.DETECTOR_STATE_CACHE: if i[0] == int(f_data['stav']): f_data['stav'] = 'N' + f_data['stav'] + ' (' + str( i[1]) + ')' break except Exception as ex: logger.warning(ex) f_data['stav'] = '' try: f_data['nalezce'] = NAME_CACHE[int(f_data['nalezce'])] except: logger.debug("Could not map finder to name") f_data['nalezce'] = '' try: for druh in predmet_druhy: if druh.id == int(f_data['druh_nalezu']): if language == 'cs': f_data['druh_nalezu'] = druh.nazev elif language == 'en': f_data['druh_nalezu'] = druh.en break except: f_data['druh_nalezu'] = '' try: for spec in specofikace_druha: if spec.id == int(f_data['specifikace']): if language == 'cs': f_data['specifikace'] = spec.nazev elif language == 'en': f_data['specifikace'] = spec.en break except: f_data['specifikace'] = '' try: for obdobi in odbodi_druha: if obdobi.id == int(f_data['obdobi']): if language == 'cs': f_data['obdobi'] = obdobi.nazev elif language == 'en': f_data['obdobi'] = obdobi.en break except: f_data['obdobi'] = '' try: for o in organizace: if o[0] == int(f_data['predano_organizace']): f_data['predano_organizace'] = o[1] break except: f_data['predano_organizace'] = '' if f_data['predano'] == 't': f_data['predano'] = _('Ano') else: f_data['predano'] = _('Ne') if f_data['inv_cislo'] == '-1': f_data['inv_cislo'] = '' try: if f_data['datum_vlozeni'] != '-1': f_data[ 'datum_vlozeni'] = helper_doc.epoch_timestamp_to_datetime( int(f_data['datum_vlozeni'])) else: f_data['datum_vlozeni'] = '' except: f_data['datum_vlozeni'] = '' try: if f_data['datum_archivace'] != '-1': f_data[ 'datum_archivace'] = helper_doc.epoch_timestamp_to_datetime( int(f_data['datum_archivace'])) else: f_data['datum_archivace'] = '' except: f_data['datum_archivace'] = '' try: kat_id = int(f_data['katastr']) cadastre_index = [x[0] for x in c.CADASTRE_12_CACHE].index(kat_id) kataster = c.CADASTRE_12_CACHE[cadastre_index][1] f_data['katastr'] = kataster[:kataster.index('(') - 1] f_data['okres'] = kataster[kataster.index('(') + 1:kataster.index(')')] except: f_data['katastr'] = '' f_data['okres'] = '' docArray.append(f_data) return docArray