Home | Trees | Indices | Help |
---|
|
1 ########################################################################### 2 # # 3 # Copyright (C) 2016 Rafal Kobel <rafyco1@gmail.com> # 4 # # 5 # This program is free software: you can redistribute it and/or modify # 6 # it under the terms of the GNU General Public License as published by # 7 # the Free Software Foundation, either version 3 of the License, or # 8 # (at your option) any later version. # 9 # # 10 # This program is distributed in the hope that it will be useful, # 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of # 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 13 # GNU General Public License for more details. # 14 # # 15 # You should have received a copy of the GNU General Public License # 16 # along with this program. If not, see <http://www.gnu.org/licenses/>. # 17 # # 18 ########################################################################### 19 """ Modul zarzadzania polami wejsciowymi. """ 20 21 from __future__ import print_function 22 from django.core.management.base import CommandError 23 from ajango.core.factory import FactoryBase 24 from ajango.database.validate import ValidationManager 25 from ajango.core.generable import Generable 26 from ajango.core.hybrid import Hybrid, get_str_object_factory 2729 """ Klasa fabryki pol wejsciowych. """37 41 42 #pylint: disable=R090231 """ Metoda inicujujaca. """ 32 self.set_items('Input', { 33 'default' : 'ajango.database.inputs.default', 34 'number' : 'ajango.database.inputs.number' 35 }) 36 get_str_object_factory(self)44 """ Abstrakcyjna klasa pola wejsiowego. """14546 self.type = "unKnown" 47 self.theme = 'default' 48 self.default = "" 49 self.messages = [] 50 self.has_prepare = False 51 self.data = {} 52 self.xml_name = "INPUT" 53 self.pre_init() 54 self.label = "" 55 self.default = "" 56 self.tag = "" 57 self.validation_manager = ValidationManager() 58 Hybrid.__init__(self, params) 59 self.value = self.default 60 self.post_init()62 """ Inicjalizacja z danych XML. """ 63 self.label = self.getAttribute('label') 64 self.default = self.getAttribute('default') 65 self.tag = self.getAttribute('tag')67 """ Inicjalizacja ze zmiennej slownikowej. """ 68 try: 69 self.validation_manager = params['vm'] 70 if self.validation_manager == None: 71 self.validation_manager = ValidationManager() 72 except KeyError: 73 self.validation_manager = ValidationManager() 74 try: 75 self.label = params['label'] 76 self.default = params['default'] 77 self.tag = params['tag'] 78 except KeyError: 79 raise CommandError("Input element is invalid")87 """ Wykonanie zadan obiektu. """ 88 self.validation_manager.execute(view) 89 if len(self.validation_manager) > 0: 90 view.add_line("%s.add_input({'type': %r, " 91 "'label': %r, " 92 "'tag': %r, " 93 "'default': %r, " 94 "'vm': vm })" % 95 (view_name, self.type, self.label, 96 self.tag, self.default)) 97 else: 98 view.add_line("%s.add_input({'type': %r, " 99 "'label': %r, " 100 "'tag': %r, " 101 "'default': %r })" % 102 (view_name, self.type, self.label, 103 self.tag, self.default))108 """ Oczytanie nodow wewnetrznych. """ 109 if name == 'VALIDATE': 110 self.validation_manager.add_validate(xmldoc_elem)112 """ Przygotowanie danych dla szablonu. """ 113 if self.has_prepare: 114 return 115 # Id dla fromularza, do uzycia przy kilku widokach na jednej stronie 116 self.has_prepare = True 117 self.data['label'] = self.label 118 self.data['default'] = self.default 119 self.data['value'] = self.value 120 self.data['tag'] = self.tag 121 self.data['url'] = '%s/ajango_inputs/%s.html' % (self.theme, self.type) 122 self.data['messages'] = self.messages135 """ Sprawdzenie pole wejsciowe jest poprawnie wypelnione. """ 136 value = False 137 try: 138 text = data[self.tag] 139 value = self.validation_manager.is_valid(text) 140 self.messages += self.validation_manager.get_messages() 141 except KeyError: 142 self.messages.append("Cannot read data named %r from POST" % 143 self.tag) 144 return value147 """ Klasa zarzadzajaca obiektami pol wejsiowych. """182158 """ Sprawdza czy pola wejsiowe sa poprawnie wypelnione. """ 159 result = True 160 for elem in self.inputs: 161 if not elem.is_valid(data): 162 self.messages += elem.get_messages() 163 result = False 164 return result166 """ Ustawienie elementow danymi z parametru. """ 167 for elem in self.inputs: 168 try: 169 value = data[elem.tag] 170 elem.value = value 171 except KeyError: 172 print("There are no tag %r in data object" % elem.tag) 173 elem.value = elem.default175 """ Ustwienie elementow na podstawie tabeli. """ 176 for elem in self.inputs: 177 value = table_el.serializable_value(elem.tag) 178 elem.value = value
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Oct 20 21:01:52 2016 | http://epydoc.sourceforge.net |