Package ajango :: Package site :: Package sites :: Module display
[hide private]
[frames] | no frames]

Source Code for Module ajango.site.sites.display

 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  """ 
20  Modul do wyswietlania danych. 
21   
22  Obiekt obsluguje strone ze szczegolami rekordu z bazy danych. Moga one 
23  pochodzic zarowno z pojedynczej tabeli jak i jako wynik zapytania SQL. 
24   
25  Obiekt Generujacy 
26  ================= 
27   
28  L{ajango.generator.views.display} 
29  """ 
30   
31  from django.utils.datastructures    import MultiValueDictKeyError 
32  from django.core.management.base    import CommandError 
33  from ajango.site.sites              import GetSite 
34  from ajango.site.sites.list         import Site   as List 
35  from ajango.database.columns.button import Column as Button 
36   
37 -class Site(List, GetSite):
38 """ Klasa do wyswietlania danych. """
39 - def __init__(self, ob):
40 self.column = [] 41 List.__init__(self, ob)
42 - def init(self):
43 """ Metoda inicjalizujaca. """ 44 self.type = 'display' 45 self.column = []
46 - def get_id(self):
47 """ Zwraca id rekordu ktory wyswietla. """ 48 try: 49 identity = self.request.GET['id'] 50 except MultiValueDictKeyError: 51 identity = -1 52 return identity
53 - def content(self):
54 """ Buduje dane dla strony. """ 55 self.data['tabledata'] = [] 56 results = self.query.get_by_filter({'id' : self.get_id()}) 57 if len(results) < 1: 58 self.data['result'] = False 59 else: 60 elem = results[0] 61 self.data['result'] = True 62 line = [] 63 for col in self.column: 64 if isinstance(col, Button): 65 raise CommandError("Display view cannot have Button column") 66 else: 67 line.append(col.get_data({'result': elem})) 68 self.data['tabledata'] = line
69