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

Source Code for Module ajango.site.sites.list

 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 obslugujacy strone z lista elementow. 
21   
22  Obiekt obsluguje strone z lista elementow. Moga one pochodzic zarowno 
23  z pojedynczej tabeli jak i jako wynik zapytania SQL. 
24   
25  Obiekt Generujacy 
26  ================= 
27   
28  L{ajango.generator.views.list} 
29  """ 
30   
31  from __future__              import print_function 
32  from ajango.site.sites       import SiteBase 
33  from ajango.database.columns import column_factory 
34   
44   
45 -class Site(SiteBase):
46 """ Klasa obslugujaca strone tabeli z lista elementow. """
47 - def __init__(self, ob):
48 self.table = "" 49 self.column = [] 50 self.query = None 51 SiteBase.__init__(self, ob)
52 - def get_request(self):
53 """ Zwraca obiekt request. """ 54 return self.request
55 - def init(self):
56 """ Inicjalizacja metody. """ 57 self.type = 'list'
58 - def add_column(self, param):
59 """ Dodanie nowej kolumny do wyswietlenia. """ 60 col = column_factory(param) 61 self.column.append(col)
62 - def set_query(self, query):
63 """ Ustawienie zapytania dla strony. """ 64 self.query = query
65 - def content(self):
66 """ Ustawienie zmiennych dostarczanych do szablonow. """ 67 self.data['tableheader'] = [] 68 for col in self.column: 69 self.data['tableheader'].append(col.get_label()) 70 data = [] 71 results = self.query.get_all() 72 print_debug("======== Column list ===============") 73 for elem in results: 74 line = [] 75 for col in self.column: 76 line.append(col.get_data({'result' : elem})) 77 print_debug(line) 78 print_debug("------------------------------------") 79 data.append(list(line)) 80 print_debug(data) 81 print_debug("====================================") 82 self.data['tabledata'] = data
83