def POST(self): _ip = unicode(web.ctx['ip']) VisitLog.VisitLog().write(_ip, 'SQL-Code des Neuer Datensatzes') _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _h2 = HtmlTemplate.Tag("h2") _h2.addContent("SQL-Code") _appbox.addContent(_h2) _p_1 = HtmlTemplate.Tag("p") _p_1.addContent(u'''Diesen SQL-Code kannst du an <a href="mailto:[email protected]"> [email protected]</a> senden. Möglichst noch mit einem Kommentar wo die Änderungen sind und warum du die Änderungen wünschst. Oder du Machst ein so genanntes <i>Ticket</i> auf unter: <a href="http://sourceforge.net/p/belief-matching/tickets/"> http://sourceforge.net/p/belief-matching/tickets/</a> <br> <b>Vielen Dank!</b>''') _appbox.addContent(_p_1) _editor = HtmlTemplate.Tag("textarea") _editor.setAttribute("class", "result") _editor.setAttribute("cols", "80") _editor.setAttribute("rows", "40") _editor.addContent(self.getSqlCode()) _appbox.addContent(_editor) _appbox.addContent(_p_1) _htmlcode = self.htemp.getCompleteSite("sqlgenerator", _appbox) web.header('Content-Type', 'text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar(_htmlcode)
def getEditRow(self, _isOdd, _row_array): _answer_optionen = self.getAnswers() _rowTag = HtmlTemplate.Tag("tr") if int(_isOdd) == int(1): _rowTag.setAttribute("class", "oddrow") # column: number _col_1 = HtmlTemplate.Tag("td") _col_1.addContent('<small>' + unicode(_row_array[0]) + '</small>') _rowTag.addContent(_col_1) # column: question & comment _col_3 = HtmlTemplate.Tag("td") _tooltip = HtmlTemplate.Tag("a") _tooltip.setAttribute("href", "#hint") _tooltip.setAttribute("class", "tooltip") _tooltip.addContent(u'<b>Aussge:</b> ' + unicode(_row_array[1])) _info = HtmlTemplate.Tag("span") _info.setAttribute("class", "info") _info.addContent(u'<b>Erläuterung:</b> ') _info.addContent(unicode(_row_array[3])) _tooltip.addContent(_info) _col_3.addContent(_tooltip) _col_3.addContent("<br>") # column: comment _comment = HtmlTemplate.Tag("textarea") _comment.setAttribute("name", "comment_" + str(_row_array[0])) _comment.setAttribute("cols", "60") _comment.setAttribute("rows", "2") _comment.addContent(unicode(_row_array[5])) _col_3.addContent(_comment) _rowTag.addContent(_col_3) # column: answer _col_4 = HtmlTemplate.Tag("td") _select = HtmlTemplate.Tag("select") _select.setAttribute("name", u'answer_' + str(_row_array[0])) _select.setAttribute("size", "1") for _optionenline in _answer_optionen: _option = HtmlTemplate.Tag("option") _option.setAttribute("value", str(_optionenline[0])) if str(_optionenline[0]) == str(_row_array[4]): _option.setAttribute("selected", "selected") _option.addContent(unicode(_optionenline[1])) _select.addContent(_option) _col_4.addContent(_select) _rowTag.addContent(_col_4) return _rowTag
def GET(self): _ip = unicode(web.ctx['ip']) VisitLog.VisitLog().write(_ip, 'Datenbearbeitungsstart') _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _htmlcode = self.htemp.getCompleteSite("databaseedit", _appbox) web.header('Content-Type', 'text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar(_htmlcode)
def POST(self): _ip = unicode ( web.ctx['ip'] ) VisitLog.VisitLog().write ( _ip, 'Testergebnis' ) _appbox = HtmlTemplate.Tag ( "div" ) _appbox.setAttribute ( "class", "appbox" ) _table = self.matchingTable() _appbox.addContent ( _table ) _htmlcode = self.htemp.getCompleteSite( "belieftest", _appbox ) web.header('Content-Type','text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar( _htmlcode )
class sqlgenerator: htemp = HtmlTemplate.HtmlTemplate() # get back a array of anser options def getAnswers(self): _answers = list() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute(''' SELECT answers_nr, deno_statement FROM answers ORDER BY answers_nr ; ''') for row in cur: _answers.append([row[0], row[1]]) return _answers # Gibt ein dict zurück mit gewichtungsnummer und gewichtungsbeschreibung. def getWeightings(self): weightingsNames = dict() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute(''' SELECT weighting_nr, description FROM weightings ORDER BY weighting_nr ASC; ''') for row in cur: weightingsNames[str(row[0])] = str(row[1]) return weightingsNames # get bach the highest id from denomination def getHighestID(self): conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute(''' SELECT MAX( denomination_id ) FROM denominations ;''') for row in cur: maxID = row[0] return maxID # vergleicht die Antworten des Benutzer mit den der Konfessionen. def getSqlCode(self): _htmlcode = u'' _highestID = self.getHighestID() _highestID += 1 _max_weighting_points = 0 max_points = 0 denomination_points = dict() denomination_weighting_points = dict() user_answers = dict() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute("SELECT question_id FROM questions;") widgetlist = web.input(groups=[]) _denomination = widgetlist['denomination'] _denominationURL = widgetlist['denominationurl'] _sqlcode = u'BEGIN; \n\n' _sqlcode += u'INSERT INTO denominations ( denomination_id, denomination, url ) \n' _sqlcode += u' VALUES ( \n' _sqlcode += u' ' + str(_highestID) + u', \n' _sqlcode += u' \'' + _denomination + '\', \n' _sqlcode += u' \'' + _denominationURL + '\'); \n\n' for row in cur: q_no = row[0] _sqlcode += u'INSERT INTO denomination_answers ( \n' _sqlcode += u' question_id, \n' _sqlcode += u' denomination_id, \n' _sqlcode += u' answer_nr, \n' _sqlcode += u' commentary ) \n ' _sqlcode += u' VALUES ( \n ' _sqlcode += u' ' + str(q_no) + ', \n' _sqlcode += u' ' + str(_highestID) + ', \n' _sqlcode += u' ' + widgetlist['answer_' + str(q_no)] + ', \n' _sqlcode += u' \'' + widgetlist['comment_' + str(q_no)] + '\'); \n \n' _sqlcode += u'COMMIT;; \n\n' return _sqlcode def GET(self): _ip = unicode(web.ctx['ip']) VisitLog.VisitLog().write(_ip, 'Neuer Datensatz') _sqlBackend = SQLBackend.SQLBackend() _answer_optionen = self.getAnswers() _last_kat = "" weightingsDict = self.getWeightings() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute(''' SELECT question_id, kat, question, commentary FROM questions ORDER BY kat; ''') _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _section_1 = HtmlTemplate.Tag("h2") _section_1.addContent(u'''SQL-Code-Generator''') _appbox.addContent(_section_1) _form = HtmlTemplate.Tag("form") _form.setAttribute("method", "POST") _form.setAttribute("name", "test") _form.setAttribute("action", "sqlgenerator") _intro = HtmlTemplate.Tag("p") _intro.addContent( u'''Hier kannst du auf einfache weise den SQL-Code generieren um in die Datenbankt Informationen über Konfessionen hinzuzufügen. Den generierten SQL-Code kannst du mir dann per E-Mail an ''') _mail = HtmlTemplate.Tag("a") _mail.setAttribute("href", "mailto:[email protected]") _mail.addContent(u'*****@*****.**') _intro.addContent(_mail) _intro.addContent(u' schicken.') _form.addContent(_intro) _section_glossar = HtmlTemplate.Tag("h3") _section_glossar.addContent( u'''Glossar - Erleuterung zu den Aussagen.''') _form.addContent(_section_glossar) _list = HtmlTemplate.Tag("ul") for _row in _sqlBackend.getAnswersDescriptions(): _item = HtmlTemplate.Tag("li") _item.addContent(u'<b>' + unicode(_row[3]) + ':</b> ') _item.addContent(unicode(_row[4])) _list.addContent(_item) _form.addContent(_list) _section_newdata = HtmlTemplate.Tag("h2") _section_newdata.addContent(u'''Der neuer Datensatz''') _form.addContent(_section_newdata) _p_2 = HtmlTemplate.Tag("p") _p_2.addContent(u'<b>Name der Konfession:</b><br>') _donname = HtmlTemplate.TagSingle("input") _donname.setAttribute("name", "denomination") _donname.setAttribute("type", "text") _donname.setAttribute("size", "40") _p_2.addContent(_donname) _p_2.addContent(u'<br>') _p_2.addContent(u'<b>URL zu weiterführenden Informationen:</b><br>') _donURL = HtmlTemplate.TagSingle("input") _donURL.setAttribute("name", "denominationurl") _donURL.setAttribute("type", "text") _donURL.setAttribute("size", "40") _p_2.addContent(_donURL) _p_2.addContent(u'<br><br>') _form.addContent(_p_2) _table = HtmlTemplate.Tag("table") _table_titles = HtmlTemplate.Tag("tr") _title_1 = HtmlTemplate.Tag("th") _title_1.addContent(u'Nr.') _table_titles.addContent(_title_1) #_title_2 = HtmlTemplate.Tag ( "th" ) #_title_2.addContent ( u'Kategorie' ) #_table_titles.addContent ( _title_2 ) _title_3 = HtmlTemplate.Tag("th") _title_3.addContent(u'Kommentar zu Aussage') _table_titles.addContent(_title_3) _title_4 = HtmlTemplate.Tag("th") _title_4.addContent(u'Ja/Nein') _table_titles.addContent(_title_4) _table.addContent(_table_titles) _odd = 0 _line_count = 1 for row in cur: if _last_kat != row[1]: _table.addContent(u'''<tr><td class="category" colspan="3"> ''' + unicode(row[1]) + u'''</td></tr>''') _last_kat = unicode(row[1]) _rowTag = HtmlTemplate.Tag("tr") if _odd == 1: _rowTag.setAttribute("class", "oddrow") _odd = 0 else: _odd = 1 # column: number _col_1 = HtmlTemplate.Tag("td") _col_1.addContent(str(_line_count)) _rowTag.addContent(_col_1) _line_count = _line_count + 1 # column: category #_col_2 = HtmlTemplate.Tag ( "td" ) #if _last_kat == row[1] : #pass #else: #_col_2.addContent ( row[1] ) #_last_kat = row[1] #_rowTag.addContent ( _col_2 ) # column: question & comment _col_3 = HtmlTemplate.Tag("td") _tooltip = HtmlTemplate.Tag("a") _tooltip.setAttribute("href", "#hint") _tooltip.setAttribute("class", "tooltip") _tooltip.addContent(u'<b>Aussge:</b> ' + unicode(row[2])) _info = HtmlTemplate.Tag("span") _info.setAttribute("class", "info") _info.addContent(u'<b>Erläuterung:</b> ') _info.addContent(unicode(row[3])) _tooltip.addContent(_info) _col_3.addContent(_tooltip) _col_3.addContent("<br>") # column: comment _comment = HtmlTemplate.Tag("textarea") _comment.setAttribute("name", "comment_" + str(row[0])) _comment.setAttribute("cols", "60") _comment.setAttribute("rows", "2") _comment.addContent(u'(Noch) Kein Kommentar') _col_3.addContent(_comment) _rowTag.addContent(_col_3) # column: answer _col_4 = HtmlTemplate.Tag("td") _select = HtmlTemplate.Tag("select") _select.setAttribute("name", u'answer_' + unicode(row[0])) _select.setAttribute("size", "1") for _optionenline in _sqlBackend.getAnswersDescriptions(): _option = HtmlTemplate.Tag("option") _option.setAttribute("value", unicode(_optionenline[0])) _option.addContent(_optionenline[3]) _select.addContent(_option) _col_4.addContent(_select) _rowTag.addContent(_col_4) _table.addContent(_rowTag) _form.addContent(_table) _p_button = HtmlTemplate.Tag("p") _p_button.addContent(u'<br>') _button = HtmlTemplate.Tag("button") _button.addContent(u'SQL-Code Generieren') _button.setAttribute("id", "generieren") _button.setAttribute("name", "generieren") _p_button.addContent(_button) _form.addContent(_p_button) _appbox.addContent(_form) _htmlcode = self.htemp.getCompleteSite("sqlgenerator", _appbox) web.header('Content-Type', 'text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar(_htmlcode) def POST(self): _ip = unicode(web.ctx['ip']) VisitLog.VisitLog().write(_ip, 'SQL-Code des Neuer Datensatzes') _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _h2 = HtmlTemplate.Tag("h2") _h2.addContent("SQL-Code") _appbox.addContent(_h2) _p_1 = HtmlTemplate.Tag("p") _p_1.addContent(u'''Diesen SQL-Code kannst du an <a href="mailto:[email protected]"> [email protected]</a> senden. Möglichst noch mit einem Kommentar wo die Änderungen sind und warum du die Änderungen wünschst. Oder du Machst ein so genanntes <i>Ticket</i> auf unter: <a href="http://sourceforge.net/p/belief-matching/tickets/"> http://sourceforge.net/p/belief-matching/tickets/</a> <br> <b>Vielen Dank!</b>''') _appbox.addContent(_p_1) _editor = HtmlTemplate.Tag("textarea") _editor.setAttribute("class", "result") _editor.setAttribute("cols", "80") _editor.setAttribute("rows", "40") _editor.addContent(self.getSqlCode()) _appbox.addContent(_editor) _appbox.addContent(_p_1) _htmlcode = self.htemp.getCompleteSite("sqlgenerator", _appbox) web.header('Content-Type', 'text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar(_htmlcode)
def GET(self): _ip = unicode(web.ctx['ip']) VisitLog.VisitLog().write(_ip, 'Neuer Datensatz') _sqlBackend = SQLBackend.SQLBackend() _answer_optionen = self.getAnswers() _last_kat = "" weightingsDict = self.getWeightings() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute(''' SELECT question_id, kat, question, commentary FROM questions ORDER BY kat; ''') _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _section_1 = HtmlTemplate.Tag("h2") _section_1.addContent(u'''SQL-Code-Generator''') _appbox.addContent(_section_1) _form = HtmlTemplate.Tag("form") _form.setAttribute("method", "POST") _form.setAttribute("name", "test") _form.setAttribute("action", "sqlgenerator") _intro = HtmlTemplate.Tag("p") _intro.addContent( u'''Hier kannst du auf einfache weise den SQL-Code generieren um in die Datenbankt Informationen über Konfessionen hinzuzufügen. Den generierten SQL-Code kannst du mir dann per E-Mail an ''') _mail = HtmlTemplate.Tag("a") _mail.setAttribute("href", "mailto:[email protected]") _mail.addContent(u'*****@*****.**') _intro.addContent(_mail) _intro.addContent(u' schicken.') _form.addContent(_intro) _section_glossar = HtmlTemplate.Tag("h3") _section_glossar.addContent( u'''Glossar - Erleuterung zu den Aussagen.''') _form.addContent(_section_glossar) _list = HtmlTemplate.Tag("ul") for _row in _sqlBackend.getAnswersDescriptions(): _item = HtmlTemplate.Tag("li") _item.addContent(u'<b>' + unicode(_row[3]) + ':</b> ') _item.addContent(unicode(_row[4])) _list.addContent(_item) _form.addContent(_list) _section_newdata = HtmlTemplate.Tag("h2") _section_newdata.addContent(u'''Der neuer Datensatz''') _form.addContent(_section_newdata) _p_2 = HtmlTemplate.Tag("p") _p_2.addContent(u'<b>Name der Konfession:</b><br>') _donname = HtmlTemplate.TagSingle("input") _donname.setAttribute("name", "denomination") _donname.setAttribute("type", "text") _donname.setAttribute("size", "40") _p_2.addContent(_donname) _p_2.addContent(u'<br>') _p_2.addContent(u'<b>URL zu weiterführenden Informationen:</b><br>') _donURL = HtmlTemplate.TagSingle("input") _donURL.setAttribute("name", "denominationurl") _donURL.setAttribute("type", "text") _donURL.setAttribute("size", "40") _p_2.addContent(_donURL) _p_2.addContent(u'<br><br>') _form.addContent(_p_2) _table = HtmlTemplate.Tag("table") _table_titles = HtmlTemplate.Tag("tr") _title_1 = HtmlTemplate.Tag("th") _title_1.addContent(u'Nr.') _table_titles.addContent(_title_1) #_title_2 = HtmlTemplate.Tag ( "th" ) #_title_2.addContent ( u'Kategorie' ) #_table_titles.addContent ( _title_2 ) _title_3 = HtmlTemplate.Tag("th") _title_3.addContent(u'Kommentar zu Aussage') _table_titles.addContent(_title_3) _title_4 = HtmlTemplate.Tag("th") _title_4.addContent(u'Ja/Nein') _table_titles.addContent(_title_4) _table.addContent(_table_titles) _odd = 0 _line_count = 1 for row in cur: if _last_kat != row[1]: _table.addContent(u'''<tr><td class="category" colspan="3"> ''' + unicode(row[1]) + u'''</td></tr>''') _last_kat = unicode(row[1]) _rowTag = HtmlTemplate.Tag("tr") if _odd == 1: _rowTag.setAttribute("class", "oddrow") _odd = 0 else: _odd = 1 # column: number _col_1 = HtmlTemplate.Tag("td") _col_1.addContent(str(_line_count)) _rowTag.addContent(_col_1) _line_count = _line_count + 1 # column: category #_col_2 = HtmlTemplate.Tag ( "td" ) #if _last_kat == row[1] : #pass #else: #_col_2.addContent ( row[1] ) #_last_kat = row[1] #_rowTag.addContent ( _col_2 ) # column: question & comment _col_3 = HtmlTemplate.Tag("td") _tooltip = HtmlTemplate.Tag("a") _tooltip.setAttribute("href", "#hint") _tooltip.setAttribute("class", "tooltip") _tooltip.addContent(u'<b>Aussge:</b> ' + unicode(row[2])) _info = HtmlTemplate.Tag("span") _info.setAttribute("class", "info") _info.addContent(u'<b>Erläuterung:</b> ') _info.addContent(unicode(row[3])) _tooltip.addContent(_info) _col_3.addContent(_tooltip) _col_3.addContent("<br>") # column: comment _comment = HtmlTemplate.Tag("textarea") _comment.setAttribute("name", "comment_" + str(row[0])) _comment.setAttribute("cols", "60") _comment.setAttribute("rows", "2") _comment.addContent(u'(Noch) Kein Kommentar') _col_3.addContent(_comment) _rowTag.addContent(_col_3) # column: answer _col_4 = HtmlTemplate.Tag("td") _select = HtmlTemplate.Tag("select") _select.setAttribute("name", u'answer_' + unicode(row[0])) _select.setAttribute("size", "1") for _optionenline in _sqlBackend.getAnswersDescriptions(): _option = HtmlTemplate.Tag("option") _option.setAttribute("value", unicode(_optionenline[0])) _option.addContent(_optionenline[3]) _select.addContent(_option) _col_4.addContent(_select) _rowTag.addContent(_col_4) _table.addContent(_rowTag) _form.addContent(_table) _p_button = HtmlTemplate.Tag("p") _p_button.addContent(u'<br>') _button = HtmlTemplate.Tag("button") _button.addContent(u'SQL-Code Generieren') _button.setAttribute("id", "generieren") _button.setAttribute("name", "generieren") _p_button.addContent(_button) _form.addContent(_p_button) _appbox.addContent(_form) _htmlcode = self.htemp.getCompleteSite("sqlgenerator", _appbox) web.header('Content-Type', 'text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar(_htmlcode)
def GET(self): _ip = unicode ( web.ctx['ip'] ) VisitLog.VisitLog().write ( _ip, 'Mitarbeitsinfo' ) conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute(''' SELECT denomination_id, denomination FROM denominations ORDER BY denomination; ''' ) htmlcode = "" _appbox = HtmlTemplate.Tag ( "div" ) _appbox.setAttribute ( "class", "appbox" ) _appbox.setAttribute ( "id", "participate" ) _floatleft = HtmlTemplate.Tag ( "div" ) _floatleft.setAttribute ( "class", "floatleft" ) # ############## text part #################### _text = HtmlTemplate.Tag ( "div" ) _text.setAttribute ( "class", "col" ) # ####################### section ################################## _h2 = HtmlTemplate.Tag ( "h2" ) _h2.addContent ( u'Mitmachen bei BELIEF MATCHING' ) _text.addContent ( _h2 ) _h3_intro = HtmlTemplate.Tag ( "h3" ) _h3_intro.addContent ( u'Schnelleinstieg zum mitmachen' ) _text.addContent ( _h3_intro ) _p_1 = HtmlTemplate.Tag ( "p" ) _p_1.addContent ( u'''Du hast Spaß gefunden an dem Projekt und hast jetzt Lust das Programm aktiv zu verbessern? Super! Du muss noch nicht mal richtig programmieren, um ein wichtigen Betrag leisten zu können. Hier schildere ich, was du tun muss um Fehler in den Datensätzen zu beseitigen. Oder Daten zu ergänzen. Diese Anleitung ist besonders an Nichtprogrammiere gerichtet.''' ) _text.addContent ( _p_1 ) # ######################### section ############################## _h3_newaccount = HtmlTemplate.Tag ( "h3" ) _h3_newaccount.addContent ( u'Einen neuen Account anlegen' ) _text.addContent ( _h3_newaccount ) _p_2 = HtmlTemplate.Tag ( "p" ) _p_2.addContent ( u'''Zunächst solltest du auf die Seite von ''' ) _link_github = HtmlTemplate.Tag ( "a" ) _link_github.setAttribute ( "href" , "https://github.com" ) _link_github.addContent ( u'<i>GitHub</i>' ) _p_2.addContent ( _link_github ) _p_2.addContent ( u''' gehen um dir ein eigenes Konto einzurichten. Das ist kostenlos (Siehe Bild 1) und in wenigen Minuten erledigt''' ) _text.addContent ( _p_2 ) # ######################## section ################################### _h3_fork = HtmlTemplate.Tag ( "h3" ) _h3_fork.addContent ( u'Eine Arbeitskopie anlegen' ) _text.addContent ( _h3_fork ) _p_3 = HtmlTemplate.Tag ( "p" ) _p_3.addContent ( u'''Nach dem du dir erfolgreich ein Konto bei GitHub eingerichtet hast, kannst du dir eine Arbeitskopie des Projektes erstellen mit dem du später deine Änderungen erstellst. Dazu gehst du auf die ''' ) _link_github = HtmlTemplate.Tag ( "a" ) _link_github.setAttribute ( "href" , "https://github.com/OlafRadicke/belief-matching" ) _link_github.addContent ( u'<i>Projektseite bei GitHub.</i>' ) _p_3.addContent ( _link_github ) _p_3.addContent ( u''' Wie im Bild 2 kannst du recht oben den Knopf "<i>Fork</i>" sehen. Hier klickst du drauf um deine Arbeitskopie zu erstellen.''' ) _text.addContent ( _p_3 ) _p_4 = HtmlTemplate.Tag ( "p" ) _p_4.addContent ( u'''Deine Arbeitskopie ist völlig separat vom eigentlich Projekt. Du muss also keine angst haben etwas kaputt zu machen..''' ) _text.addContent ( _p_4 ) # ###################################################################### _h3_edit = HtmlTemplate.Tag ( "h3" ) _h3_edit.addContent ( u'Die Arbeitskopie bearbeiten' ) _text.addContent ( _h3_edit ) _p_5 = HtmlTemplate.Tag ( "p" ) _p_5.addContent ( u'''In deiner Projekt-Kopie kannst du dich bewegen wie in einem Datei-Browser und die einzelnen Verzeichnisse durchstöbern. In dem Ordner <b>"./sql"</b> liegen die Datensätze für die Datenbank. Wenn du einen Fehler entdeckt hast, der zu der Beschreibung einer Konfession gehört, bis du hier richtig.''' ) _text.addContent ( _p_5 ) _p_6 = HtmlTemplate.Tag ( "p" ) _p_6.addContent ( u'''Wenn du in den Ordner <b>"./sql"</b> gehst, siehst du eine Reihe von Dateien. Die beginnen immer mit dem Namen der Konfession, deren Informationen sie enthalten. Wenn du Eine - durch anklicken - auswählst, hast du die Möglichkeit die Daten direkt im Browser zu editieren. Da zu klickst du auf den Button <b>"Edit this file"</b>, recht oben. Zusehen im Bild Nr. 3.''') _text.addContent ( _p_6 ) # ###################################################################### _h3_back = HtmlTemplate.Tag ( "h3" ) _h3_back.addContent ( u'Wie deine Änderung in das Projekt zurückfließen' ) _text.addContent ( _h3_back ) _p_7 = HtmlTemplate.Tag ( "p" ) _p_7.addContent ( u'''Als letzter Schritt sollen deine Verbesserungen natürlich zurück in das Projekt fließen. Das geht auf zweierlei Weise:''' ) _text.addContent ( _p_7 ) _p_8 = HtmlTemplate.Tag ( "p" ) _p_8.addContent ( u'''<b>A) Über Webinterface:</b> Dazu klickst du auf den Knopf <b>"Pull Request"</b>, so wie es in dem untersten Bild zusehen ist. Darauf hin wird sich ein Dialog öffnen im dem du aufgevordert wirst u.a. einen Kommentar zu hinterlassen. Hier wäre es gut, wenn du kurz beschreibst das du geändert hast ggf. warum. Ich werde dann vom System benachrichtigt, und gebe dir zeitnahe eine Rückmeldung, ob ich deine Änderungen übernommen habe, und wenn nicht, warum ich sie nicht übernommen habe.''' ) _text.addContent ( _p_8 ) _p_9 = HtmlTemplate.Tag ( "p" ) _p_9.addContent ( u'''<b>B) Per E-Mail:</b> Wem der erste Weg noch zu anspruchsvoll ist, der kann mir auch einfach eine Mail schicken mit dem Link zu seiner Arbeitskopie. Ich werde mir dann die Änderungen gerne ansehen und dann auch übernehmen.''' ) _text.addContent ( _p_9 ) _p_10 = HtmlTemplate.Tag ( "p" ) _p_10.addContent ( u'''Nach dem ich eure Änderung in meinen Hauptzweig eingepflegt habe, stehen sie auch allen Anderen zur Verführung und natürlich auf dieser Website. Sollte noch irgend etwas unklar geblieben sein, dann scheut euch nicht, mich anzuschreiben: ''') _text.addContent ( _p_10 ) _mail = HtmlTemplate.Tag ( "a" ) _mail.setAttribute ( "href", "mailto:[email protected]" ) _mail.addContent ( u'*****@*****.**' ) _text.addContent ( _mail ) _floatleft.addContent ( _text) # ############## pic part ############################################# _pics = HtmlTemplate.Tag ( "div" ) _pics.setAttribute ( "class", "col" ) # bild 1 _p_1 = HtmlTemplate.Tag ( "p" ) _link_img1 = HtmlTemplate.Tag ( "a" ) _link_img1.setAttribute ( "href" , "static/01_create_account.png" ) _img_01 = HtmlTemplate.TagSingle ( "img" ) _img_01.setAttribute ( "class", "participate_img" ) _img_01.setAttribute ( "src", "static/01_create_account.png" ) _img_01.setAttribute ( "alt", "Accound erstellen bei gitHub" ) _link_img1.addContent ( _img_01 ) #_p_1.addContent ( _link_img1 ) _pics.addContent ( _link_img1) # bild 2 _link_img2 = HtmlTemplate.Tag ( "a" ) _link_img2.setAttribute ( "href" , "static/02_fork_project.png" ) _img_02 = HtmlTemplate.TagSingle ( "img" ) _img_02.setAttribute ( "class", "participate_img" ) _img_02.setAttribute ( "src", "static/02_fork_project.png" ) _img_02.setAttribute ( "alt", "Arbeitskopie anlegen" ) _link_img2.addContent ( _img_02 ) _pics.addContent ( _link_img2 ) # bild 4 _link_img4 = HtmlTemplate.Tag ( "a" ) _link_img4.setAttribute ( "href" , "static/04_edit_file.png" ) _img_04 = HtmlTemplate.TagSingle ( "img" ) _img_04.setAttribute ( "class", "participate_img" ) _img_04.setAttribute ( "src", "static/04_edit_file.png" ) _img_04.setAttribute ( "alt", "Arbeitskopie anlegen" ) _link_img4.addContent ( _img_04 ) _pics.addContent ( _link_img4 ) # bild 5 _link_img5 = HtmlTemplate.Tag ( "a" ) _link_img5.setAttribute ( "href" , "static/05_pull_request.png" ) _img_05 = HtmlTemplate.TagSingle ( "img" ) _img_05.setAttribute ( "class", "participate_img" ) _img_05.setAttribute ( "src", "static/05_pull_request.png" ) _img_05.setAttribute ( "alt", "pull request" ) _link_img5.addContent ( _img_05 ) _pics.addContent ( _link_img5 ) _floatleft.addContent ( _pics ) _appbox.addContent ( _floatleft ) # ###################################################################### htmlcode += self.htemp.getCompleteSite( "participate", _appbox ) #return self.htemp.convertGermanChar( htmlcode ) #print htmlcode web.header('Content-Type','text/html; charset=utf-8', unique=True) return htmlcode
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import sys import sqlite3 import web from web import form import HtmlTemplate import index import belieftest import databaseview import participate import sqlgenerator import databaseedit urls = ('/', 'index.index', '/belieftest', 'belieftest.belieftest', '/databaseview', 'databaseview.databaseview', '/databaseedit', 'databaseedit.databaseedit', '/participate', 'participate.participate', '/sqlgenerator', 'sqlgenerator.sqlgenerator') app = web.application(urls, globals()) #, web.reloader) htemp = HtmlTemplate.HtmlTemplate() if __name__ == "__main__": app.run()
class databaseedit: htemp = HtmlTemplate.HtmlTemplate() last_category = "" # get back a 2D-array of questions # that ist exist not a Answers # @ _id a id of a denomination def getNoAnswers(self, _id): _answers = list() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute( ''' SELECT question_id, question, kat, commentary FROM questions WHERE question_id NOT IN ( SELECT question_id FROM denomination_answers WHERE denomination_id = ? ) ORDER BY question_id ; ''', (_id, )) for _row_array in cur: _array = list() #questions.question_id, _array.append(_row_array[0]) #questions.question, _array.append(_row_array[1]) #questions.kat, _array.append(_row_array[2]) #questions.commentary, _array.append(_row_array[3]) #denomination_answers.answer_nr, _array.append(0) #denomination_answers.commentary _array.append("") _answers.append(_array) return _answers # get back a 2D-array of anser options def getAnswers(self): _answers = list() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute(''' SELECT answers_nr, deno_statement FROM answers ORDER BY answers_nr ; ''') for _row_array in cur: _answers.append([_row_array[0], _row_array[1]]) return _answers # Gibt den Namen einer Konfessions-id zurück. def getDenominationName(self, _id): denominationName = "unbekannter Name" conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute( ''' SELECT denomination FROM denominations WHERE denomination_id = ?; ''', (_id, )) for _row_array in cur: denominationName = _row_array[0] return denominationName def getUrlOfDenomination(self, _id): conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute( u''' SELECT url FROM denominations WHERE denomination_id = ? ; ''', (_id, )) for _row_array in cur: return _row_array[0] return "" # formular for editing data. def getSQLResulte(self, _widgetlist): _id = _widgetlist['gen_sql'] _max_weighting_points = 0 max_points = 0 denomination_points = dict() denomination_weighting_points = dict() user_answers = dict() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute(u'''SELECT question_id , kat FROM questions ORDER BY questions.kat, question_id ;''') widgetlist = web.input(groups=[]) _sqlcode = u'BEGIN; \n\n' _sqlcode += u'INSERT INTO denominations ( denomination_id, denomination, url ) \n' _sqlcode += u' VALUES ( \n' _sqlcode += u' ' + str(_id) + u', \n' _sqlcode += u' \'' + self.getDenominationName(_id) + '\', \n' _sqlcode += u' \'' + self.getUrlOfDenomination(_id) + '\'); \n\n' _last_category = u'' for _row_array in cur: q_no = _row_array[0] _category_name = unicode(_row_array[1]) if _last_category != _category_name: _last_category = _category_name _sqlcode += u'\n-- ##################### Kategorie : ' _sqlcode += _category_name + ' #####################\n\n' _answer_key = u'answer_' + unicode(q_no) _comment_key = u'comment_' + unicode(q_no) _sqlcode += u'INSERT INTO denomination_answers ( \n' _sqlcode += u' question_id, \n' _sqlcode += u' denomination_id, \n' _sqlcode += u' answer_nr, \n' _sqlcode += u' commentary ) \n ' _sqlcode += u' VALUES ( ' _sqlcode += u' ' + unicode(q_no) + ', ' _sqlcode += u' ' + unicode(_id) + ', ' _sqlcode += u' ' + unicode(widgetlist[_answer_key]) + ', \n' _sqlcode += u' \'' + unicode( widgetlist[_comment_key]) + '\'); \n \n' _sqlcode += u'COMMIT;; \n\n' _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _h2 = HtmlTemplate.Tag("h2") _h2.addContent("SQL-Code") _appbox.addContent(_h2) _p_1 = HtmlTemplate.Tag("p") _p_1.addContent(u'''Diesen SQL-Code kannst du an <a href="mailto:[email protected]"> [email protected]</a> senden. Möglichst noch mit einem Kommentar wo die Änderungen sind und warum du die Änderungen wünschst. Oder du Machst ein so genanntes <i>Ticket</i> auf unter: <a href="http://sourceforge.net/p/belief-matching/tickets/"> http://sourceforge.net/p/belief-matching/tickets/</a> <br> <b>Vielen Dank!</b>''') _appbox.addContent(_p_1) _editor = HtmlTemplate.Tag("textarea") _editor.setAttribute("class", "result") #_editor.setAttribute ( "cols", "80" ) _editor.setAttribute("rows", "40") _editor.addContent(unicode(_sqlcode)) _appbox.addContent(_editor) return _appbox # get back a tr-tag # @_row_array def getEditRow(self, _isOdd, _row_array): _answer_optionen = self.getAnswers() _rowTag = HtmlTemplate.Tag("tr") if int(_isOdd) == int(1): _rowTag.setAttribute("class", "oddrow") # column: number _col_1 = HtmlTemplate.Tag("td") _col_1.addContent('<small>' + unicode(_row_array[0]) + '</small>') _rowTag.addContent(_col_1) # column: question & comment _col_3 = HtmlTemplate.Tag("td") _tooltip = HtmlTemplate.Tag("a") _tooltip.setAttribute("href", "#hint") _tooltip.setAttribute("class", "tooltip") _tooltip.addContent(u'<b>Aussge:</b> ' + unicode(_row_array[1])) _info = HtmlTemplate.Tag("span") _info.setAttribute("class", "info") _info.addContent(u'<b>Erläuterung:</b> ') _info.addContent(unicode(_row_array[3])) _tooltip.addContent(_info) _col_3.addContent(_tooltip) _col_3.addContent("<br>") # column: comment _comment = HtmlTemplate.Tag("textarea") _comment.setAttribute("name", "comment_" + str(_row_array[0])) _comment.setAttribute("cols", "60") _comment.setAttribute("rows", "2") _comment.addContent(unicode(_row_array[5])) _col_3.addContent(_comment) _rowTag.addContent(_col_3) # column: answer _col_4 = HtmlTemplate.Tag("td") _select = HtmlTemplate.Tag("select") _select.setAttribute("name", u'answer_' + str(_row_array[0])) _select.setAttribute("size", "1") for _optionenline in _answer_optionen: _option = HtmlTemplate.Tag("option") _option.setAttribute("value", str(_optionenline[0])) if str(_optionenline[0]) == str(_row_array[4]): _option.setAttribute("selected", "selected") _option.addContent(unicode(_optionenline[1])) _select.addContent(_option) _col_4.addContent(_select) _rowTag.addContent(_col_4) return _rowTag # formular for editing data. def getEditForm(self, _widgetlist): _id = _widgetlist['edit_denomination'] conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute( ''' SELECT questions.question_id, questions.question, questions.kat, questions.commentary, denomination_answers.answer_nr, denomination_answers.commentary FROM denomination_answers, questions WHERE denomination_answers.denomination_id = ? AND denomination_answers.question_id = questions.question_id ORDER BY questions.kat, denomination_answers.answer_nr; ''', (_id, )) htmlcode = "" _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _section_1 = HtmlTemplate.Tag("h2") _section_1.addContent(u'''SQL-Code-Generator für ''') _section_1.addContent(self.getDenominationName(_id)) _appbox.addContent(_section_1) _form = HtmlTemplate.Tag("form") _form.setAttribute("method", "POST") _form.setAttribute("name", "test") _form.setAttribute("action", "databaseedit") _table = HtmlTemplate.Tag("table") _table_titles = HtmlTemplate.Tag("tr") _title_1 = HtmlTemplate.Tag("th") _title_1.addContent(u'ID') _table_titles.addContent(_title_1) _title_3 = HtmlTemplate.Tag("th") _title_3.addContent(u'Kommentar zu Aussage') _table_titles.addContent(_title_3) _title_4 = HtmlTemplate.Tag("th") _title_4.addContent(u'Ja/Nein') _table_titles.addContent(_title_4) _table.addContent(_table_titles) # loop with exist answers _odd = 0 _count = 1 _last_kat = u'' for _row_array in cur: if _last_kat != _row_array[2]: _table.addContent(u'''<tr><td class="category" colspan="3"> ''' + unicode(_row_array[2]) + u'''</td></tr>''') _last_kat = unicode(_row_array[2]) _count += 1 if _odd == 1: _odd = 0 else: _odd = 1 _rowTag = self.getEditRow(_odd, _row_array) _table.addContent(_rowTag) # loop with not exist answers _cur = self.getNoAnswers(_id) if len(_cur) > 0: _table.addContent( u'<tr><th colspan="4">Bisher nicht hinterlegte Aussagen:</th></tr>' ) _odd = 0 _count = 1 for _row_array in _cur: if _last_kat != _row_array[2]: _table.addContent(u'''<tr><td class="category" colspan="3"> ''' + unicode(_row_array[2]) + u'''</td></tr>''') _last_kat = unicode(_row_array[2]) _count += 1 if _odd == 1: _odd = 0 else: _odd = 1 _rowTag = self.getEditRow(_odd, _row_array) _table.addContent(_rowTag) _form.addContent(_table) _p_editdb = HtmlTemplate.Tag("p") _p_editdb.addContent(u'''<br>''') _button = HtmlTemplate.Tag("button") _button.addContent(u'SQL-Code generieren') _button.setAttribute("id", "gen_sql") _button.setAttribute("name", "gen_sql") _button.setAttribute("value", _id) _p_editdb.addContent(_button) _form.addContent(_p_editdb) _appbox.addContent(_form) return _appbox def GET(self): _ip = unicode(web.ctx['ip']) VisitLog.VisitLog().write(_ip, 'Datenbearbeitungsstart') _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _htmlcode = self.htemp.getCompleteSite("databaseedit", _appbox) web.header('Content-Type', 'text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar(_htmlcode) def POST(self): _widgetlist = web.input(groups=[]) _appbox = "" if "edit_denomination" in _widgetlist: _ip = unicode(web.ctx['ip']) VisitLog.VisitLog().write(_ip, 'Datenbearbeitungsauswahl') _appbox = self.getEditForm(_widgetlist) else: _ip = unicode(web.ctx['ip']) VisitLog.VisitLog().write(_ip, 'DatenbearbeitungsSQLCode') _appbox = self.getSQLResulte(_widgetlist) _htmlcode = self.htemp.getCompleteSite("databaseedit", _appbox) web.header('Content-Type', 'text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar(_htmlcode)
class databaseview: htemp = HtmlTemplate.HtmlTemplate() def getNoAnswersCount(self, _id): _answers = list() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute( ''' SELECT count ( question_id ) FROM questions WHERE question_id NOT IN ( SELECT question_id FROM denomination_answers WHERE denomination_id = ? ) ORDER BY question_id ; ''', (_id, )) for _row_array in cur: return _row_array[0] return 0 def getUrlOfDenomination(self, _id): conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute( u''' SELECT url FROM denominations WHERE denomination_id = ? ; ''', (_id, )) for row in cur: return row[0] return "" def getIntro(self, _preSelect): _sqlBackend = SQLBackend.SQLBackend() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute(''' SELECT denomination_id, denomination FROM denominations ORDER BY denomination;''') _intro = HtmlTemplate.Tag("div") _intro.setAttribute("class", "intro") _section_1 = HtmlTemplate.Tag("h2") _section_1.addContent(u'''Datenbasis des Test''') _intro.addContent(_section_1) _p_1 = HtmlTemplate.Tag("p") _p_1.addContent(u'''Hier kannst du sehen, welche Glaubensgemeinschaften in der Datenbank erfasst sind, und mit welchen Überzeugungen. Gut möglich das du einen Fehler entdeckst, oder du noch Daten über eine noch fehlende Glaubensgemeinschaft hinterlegen willst. Dann nimmt mit mir Kontakt auf: <a href="mailto:[email protected]">[email protected]</a>''' ) _intro.addContent(_p_1) _section_glossar = HtmlTemplate.Tag("h3") _section_glossar.addContent( u'''Glossar - Erleuterung zu den Aussagen.''') _intro.addContent(_section_glossar) _list = HtmlTemplate.Tag("ul") for _row in _sqlBackend.getAnswersDescriptions(): _item = HtmlTemplate.Tag("li") _item.addContent(u'<b>' + unicode(_row[3]) + ':</b> ') _item.addContent(unicode(_row[4])) _list.addContent(_item) _intro.addContent(_list) _section_2 = HtmlTemplate.Tag("h2") _section_2.addContent(u'''Hinterlegte Datensätze ansehen''') _intro.addContent(_section_2) #_p_2 = HtmlTemplate.Tag ( "p" ) _form = HtmlTemplate.Tag("form") _form.setAttribute("method", "POST") _form.setAttribute("name", "databaseview") _form.setAttribute("action", "databaseview") _p_3 = HtmlTemplate.Tag("p") _p_3.addContent(u'''Wähle die Glaubensgemeinschaft:''') _select = HtmlTemplate.Tag("select") _select.setAttribute("name", "glaubensgemeinschaft") _select.setAttribute("size", "1") for row in cur: if int(_preSelect) == int(row[0]): _option = u'<option ' _option += u' value="' + unicode(row[0]) + '" ' _option += u' selected >' _option += row[1] _option += u'</option>' else: _option = HtmlTemplate.Tag("option") _option.setAttribute("value", unicode(row[0])) _option.addContent(row[1]) _select.addContent(_option) _p_3.addContent(_select) _p_3.addContent(form.Button('anzeigen').render()) _form.addContent(_p_3) _intro.addContent(_form) conn.close() return _intro def GET(self): _ip = unicode(web.ctx['ip']) VisitLog.VisitLog().write(_ip, 'Datenbasisstart') _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _intro = self.getIntro(0) _appbox.addContent(_intro) _htmlcode = self.htemp.getCompleteSite("databaseview", _appbox) web.header('Content-Type', 'text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar(_htmlcode) def POST(self): _ip = unicode(web.ctx['ip']) VisitLog.VisitLog().write(_ip, 'Datenbasisabfrage') widgetlist = web.input(groups=[]) _id = widgetlist['glaubensgemeinschaft'] conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute( ''' SELECT questions.question, denomination_answers.answer_nr, denomination_answers.commentary, answers.deno_statement, questions.kat FROM denomination_answers, questions, answers WHERE denomination_answers.denomination_id = ? AND denomination_answers.question_id = questions.question_id AND denomination_answers.answer_nr = answers.answers_nr ORDER BY questions.kat, denomination_answers.answer_nr, questions.question; ''', (_id, )) htmlcode = "" _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _intro = self.getIntro(_id) _appbox.addContent(_intro) _appbox.addContent(u'<br/>') _table = HtmlTemplate.Tag("table") _table_titles = HtmlTemplate.Tag("tr") _title = HtmlTemplate.Tag("th") _title.addContent(u'Aussage zum Glauben (Mehr Infos unter ') _titleLink = HtmlTemplate.Tag("a") _titleLink.setAttribute("href", self.getUrlOfDenomination(_id)) _titleLink.addContent(self.getUrlOfDenomination(_id)) _title.addContent(_titleLink) _table_titles.addContent(_title) _title.addContent(u")") _table.addContent(_table_titles) _last_kat = u'' for row in cur: if _last_kat != row[4]: _table.addContent(u'''<tr><td class="category"> ''' + unicode(row[4]) + u'''</td></tr>''') _last_kat = unicode(row[4]) _row = HtmlTemplate.Tag("tr") _col = HtmlTemplate.Tag("td") if int(row[1]) == 0: _row.setAttribute("class", "no") _col.addContent(u'<b>' + unicode(row[3]) + ':</b> ') elif int(row[1]) == 1: _row.setAttribute("class", "yes") _col.addContent(u'<b>' + unicode(row[3]) + ':</b> ') elif int(row[1]) == 2: _row.setAttribute("class", "void") _col.addContent(u'<b>' + unicode(row[3]) + ':</b> ') else: _row.setAttribute("class", "void") _col.addContent(u'<b>' + unicode(row[3]) + ':</b> ') #_tooltip = HtmlTemplate.Tag ( "a" ) #_tooltip.setAttribute ( "href", "#hint" ) #_tooltip.setAttribute ( "class", "tooltip" ) #_tooltip.addContent ( unicode(row[0] ) ) #_info = HtmlTemplate.Tag ( "span" ) #_info.setAttribute ( "class", "info" ) #_info.addContent ( u'<b>Erläuterung:</b> ') #_info.addContent ( unicode(row[2]) ) #_tooltip.addContent ( _info ) #_col.addContent ( _tooltip ) _col.addContent(unicode(row[0])) _wbox = HtmlTemplate.Tag("div") _wbox.setAttribute("class", "whitebox") _small = HtmlTemplate.Tag("small") _small.addContent(u'<b>Erleuterung:</b> ' + unicode(row[2])) _wbox.addContent(_small) _col.addContent(_wbox) _row.addContent(_col) _table.addContent(_row) _appbox.addContent(_table) _form = HtmlTemplate.Tag("form") _form.setAttribute("method", "POST") _form.setAttribute("name", "databaseedit") _form.setAttribute("action", "databaseedit") _noAnswersCount = self.getNoAnswersCount(_id) if _noAnswersCount > 0: _infoBox = HtmlTemplate.Tag("div") _infoBox.setAttribute("class", "infobox") if _noAnswersCount > 1: _infoBox.addContent(u'Es gibt noch ') _infoBox.addContent(unicode(_noAnswersCount)) _infoBox.addContent(u''' Aussagen zu der noch keine Antworten hinterlegt wurde.''') else: _infoBox.addContent(u'''Es gibt noch eine Aussage zu der noch keine Antwort hinterlegt wurde.''') _form.addContent(_infoBox) _h2_editdb = HtmlTemplate.Tag("h2") _h2_editdb.addContent(u'Änderungswünsche') _form.addContent(_h2_editdb) _p_editdb = HtmlTemplate.Tag("p") _p_editdb.addContent( u'''<b>Du bist nicht mit allen Punkten einverstanden?</b> oder es gibt noch Aussage zu denen noch keine Antwort hinterlegt wurde. Dann sende mir deine Liste mit den Änderungswünsche: ''') _button = HtmlTemplate.Tag("button") _button.addContent(u'Jetzt erstellen') _button.setAttribute("id", "edit_denomination") _button.setAttribute("name", "edit_denomination") _button.setAttribute("value", _id) _p_editdb.addContent(_button) _form.addContent(_p_editdb) _appbox.addContent(_form) htmlcode += self.htemp.getCompleteSite("databaseview", _appbox) web.header('Content-Type', 'text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar(htmlcode)
def getSQLResulte(self, _widgetlist): _id = _widgetlist['gen_sql'] _max_weighting_points = 0 max_points = 0 denomination_points = dict() denomination_weighting_points = dict() user_answers = dict() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute(u'''SELECT question_id , kat FROM questions ORDER BY questions.kat, question_id ;''') widgetlist = web.input(groups=[]) _sqlcode = u'BEGIN; \n\n' _sqlcode += u'INSERT INTO denominations ( denomination_id, denomination, url ) \n' _sqlcode += u' VALUES ( \n' _sqlcode += u' ' + str(_id) + u', \n' _sqlcode += u' \'' + self.getDenominationName(_id) + '\', \n' _sqlcode += u' \'' + self.getUrlOfDenomination(_id) + '\'); \n\n' _last_category = u'' for _row_array in cur: q_no = _row_array[0] _category_name = unicode(_row_array[1]) if _last_category != _category_name: _last_category = _category_name _sqlcode += u'\n-- ##################### Kategorie : ' _sqlcode += _category_name + ' #####################\n\n' _answer_key = u'answer_' + unicode(q_no) _comment_key = u'comment_' + unicode(q_no) _sqlcode += u'INSERT INTO denomination_answers ( \n' _sqlcode += u' question_id, \n' _sqlcode += u' denomination_id, \n' _sqlcode += u' answer_nr, \n' _sqlcode += u' commentary ) \n ' _sqlcode += u' VALUES ( ' _sqlcode += u' ' + unicode(q_no) + ', ' _sqlcode += u' ' + unicode(_id) + ', ' _sqlcode += u' ' + unicode(widgetlist[_answer_key]) + ', \n' _sqlcode += u' \'' + unicode( widgetlist[_comment_key]) + '\'); \n \n' _sqlcode += u'COMMIT;; \n\n' _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _h2 = HtmlTemplate.Tag("h2") _h2.addContent("SQL-Code") _appbox.addContent(_h2) _p_1 = HtmlTemplate.Tag("p") _p_1.addContent(u'''Diesen SQL-Code kannst du an <a href="mailto:[email protected]"> [email protected]</a> senden. Möglichst noch mit einem Kommentar wo die Änderungen sind und warum du die Änderungen wünschst. Oder du Machst ein so genanntes <i>Ticket</i> auf unter: <a href="http://sourceforge.net/p/belief-matching/tickets/"> http://sourceforge.net/p/belief-matching/tickets/</a> <br> <b>Vielen Dank!</b>''') _appbox.addContent(_p_1) _editor = HtmlTemplate.Tag("textarea") _editor.setAttribute("class", "result") #_editor.setAttribute ( "cols", "80" ) _editor.setAttribute("rows", "40") _editor.addContent(unicode(_sqlcode)) _appbox.addContent(_editor) return _appbox
def matchingTable (self): _htmlcode = u'' _max_weighting_points = 0 max_points = 0 denomination_points = dict() denomination_weighting_points = dict() user_answers = dict() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute("SELECT question_id FROM questions;") widgetlist = web.input(groups = []) for row in cur: i = row[0] user_answers[unicode(i)] = {'answer' : unicode( widgetlist[ u'answer_' + unicode(i)] ), \ 'wichtung' : unicode( widgetlist[ u'wichtung_' + unicode(i)] ) } cur.execute( '''SELECT denomination_id FROM denominations ORDER BY denomination;''') # denomination loop for row in cur: _denomination_id = row[0] denomination_points [ unicode(_denomination_id) ] = 0 denomination_weighting_points [ unicode(_denomination_id) ] = 0 # user answer loop for user_answer_key in user_answers.keys() : deno_answer = self.getAnswersOfDenomination( _denomination_id, user_answer_key ) _user_answer = user_answers [ user_answer_key ] [ "answer" ] if ( int ( _user_answer ) == int ( deno_answer ) ) \ or ( int ( deno_answer) == 3 ) \ or ( int ( _user_answer ) == 3 ) : denomination_points [ unicode(_denomination_id) ] = \ int( denomination_points [ unicode(_denomination_id) ]) + 1 if int( user_answers [ user_answer_key ] [ "wichtung" ] ) == 1 : denomination_weighting_points [ unicode(_denomination_id) ] = \ int( denomination_weighting_points [ unicode(_denomination_id) ] ) + 1 # sort key list _sorted_points_keys = list () for key, value in sorted(denomination_points.iteritems(), key=lambda (k,v): (v,k)): _sorted_points_keys.append ( key ) for _key in user_answers.keys() : if int( user_answers [_key][ "wichtung" ] ) == 1 : _max_weighting_points = _max_weighting_points + 1 _table = HtmlTemplate.Tag ( "table" ) _table_titles = HtmlTemplate.Tag ( "tr" ) _title_1 = HtmlTemplate.Tag ( "th" ) _title_1.addContent ( u'Konfession' ) _table_titles.addContent ( _title_1 ) _title_2 = HtmlTemplate.Tag ( "th" ) _title_2.addContent ( u'Übereinstimmung' ) _table_titles.addContent ( _title_2 ) _title_3 = HtmlTemplate.Tag ( "th" ) _title_3.addContent ( u'In wichtigen Fragen' ) _table_titles.addContent ( _title_3 ) _table.addContent ( _table_titles ) _odd = 0 #for denomination_points_key in denomination_points.keys(): for denomination_points_key in _sorted_points_keys: # Prozent zahlen allgemein _all = len ( user_answers.keys() ) _sum_denomination_points = int ( denomination_points [denomination_points_key] ) _relativ = _sum_denomination_points / ( float( _all ) / float ( 100 ) ) # Prozentzahl der Gewichtung _sum_denomination_weighting_points = float ( denomination_weighting_points [denomination_points_key] ) if _max_weighting_points == 0 : _weighting_relativ = 0 else : _one_procent = float( _max_weighting_points ) / float ( 100 ) _weighting_relativ = _sum_denomination_weighting_points / _one_procent _row = HtmlTemplate.Tag ( "tr" ) if _odd == 1: _row.setAttribute ( "class", "oddrow" ) _odd = 0 else: _odd = 1 _col_1 = HtmlTemplate.Tag ( "td" ) _col_1.addContent ( SQLBackend.SQLBackend().getDenominationName( denomination_points_key ) ) _row.addContent ( _col_1 ) _col_2 = HtmlTemplate.Tag ( "td" ) _col_2.setAttribute ( "class", "tabpoints" ) _bar_le = HtmlTemplate.Tag ( "div" ) _bar_le.setAttribute ( "class", "points" ) _bar_le.setAttribute ( "style", 'width:' + unicode ( int ( _relativ ) ) + '%;' ) _bar_le.addContent ( u' ' ) _col_2.addContent ( _bar_le ) _col_2.addContent ( unicode ( int ( _relativ ) ) + ' %' ) _row.addContent ( _col_2 ) _col_3 = HtmlTemplate.Tag ( "td" ) _col_3.setAttribute ( "class", "tabpoints-weighting" ) _bar_ri = HtmlTemplate.Tag ( "div" ) _bar_ri.setAttribute ( "class", "points-weighting" ) _bar_ri.setAttribute ( "style", 'width:' + unicode ( int ( _weighting_relativ ) ) + '%;' ) _bar_ri.addContent ( u' ' ) _col_3.addContent ( _bar_ri ) _col_3.addContent ( unicode ( int ( _weighting_relativ ) ) + ' %' ) _row.addContent ( _col_3 ) _table.addContent ( _row) return _table
class belieftest: htemp = HtmlTemplate.HtmlTemplate() # get back a array of anser options def getAnswers (self): _answers = list() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute( ''' SELECT answers_nr, user_statement FROM answers ORDER BY answers_nr ; ''' ) for row in cur: _answers.append( [ row[0], row[1] ] ) return _answers # Gibt ein dict zurück mit allen gewichtungsnummer und gewichtungsbeschreibung. def getWeightings ( self ): weightingsNames = dict() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute( ''' SELECT weighting_nr, description FROM weightings ORDER BY weighting_nr ASC; ''') for row in cur: weightingsNames [ unicode(row[0]) ] = unicode(row[1]) return weightingsNames # gibt die Antwort einer Konfession auf eine Frage zurück. # Ist keine Antwort hinterlegt wird "egal" also "2" zurückgegeben. def getAnswersOfDenomination( self, denomination_id, question_id ): questionAnswers = dict() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute ( ''' SELECT denomination_answers.answer_nr FROM denomination_answers, questions WHERE denomination_answers.denomination_id = ? AND denomination_answers.question_id = ? ; ''', ( denomination_id, question_id )) # set default value _denomination_answer = "2" for row in cur: _denomination_answer = unicode(row[0]) return _denomination_answer # vergleicht die Antworten des Benutzer mit den der Konfessionen. def matchingTable (self): _htmlcode = u'' _max_weighting_points = 0 max_points = 0 denomination_points = dict() denomination_weighting_points = dict() user_answers = dict() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute("SELECT question_id FROM questions;") widgetlist = web.input(groups = []) for row in cur: i = row[0] user_answers[unicode(i)] = {'answer' : unicode( widgetlist[ u'answer_' + unicode(i)] ), \ 'wichtung' : unicode( widgetlist[ u'wichtung_' + unicode(i)] ) } cur.execute( '''SELECT denomination_id FROM denominations ORDER BY denomination;''') # denomination loop for row in cur: _denomination_id = row[0] denomination_points [ unicode(_denomination_id) ] = 0 denomination_weighting_points [ unicode(_denomination_id) ] = 0 # user answer loop for user_answer_key in user_answers.keys() : deno_answer = self.getAnswersOfDenomination( _denomination_id, user_answer_key ) _user_answer = user_answers [ user_answer_key ] [ "answer" ] if ( int ( _user_answer ) == int ( deno_answer ) ) \ or ( int ( deno_answer) == 3 ) \ or ( int ( _user_answer ) == 3 ) : denomination_points [ unicode(_denomination_id) ] = \ int( denomination_points [ unicode(_denomination_id) ]) + 1 if int( user_answers [ user_answer_key ] [ "wichtung" ] ) == 1 : denomination_weighting_points [ unicode(_denomination_id) ] = \ int( denomination_weighting_points [ unicode(_denomination_id) ] ) + 1 # sort key list _sorted_points_keys = list () for key, value in sorted(denomination_points.iteritems(), key=lambda (k,v): (v,k)): _sorted_points_keys.append ( key ) for _key in user_answers.keys() : if int( user_answers [_key][ "wichtung" ] ) == 1 : _max_weighting_points = _max_weighting_points + 1 _table = HtmlTemplate.Tag ( "table" ) _table_titles = HtmlTemplate.Tag ( "tr" ) _title_1 = HtmlTemplate.Tag ( "th" ) _title_1.addContent ( u'Konfession' ) _table_titles.addContent ( _title_1 ) _title_2 = HtmlTemplate.Tag ( "th" ) _title_2.addContent ( u'Übereinstimmung' ) _table_titles.addContent ( _title_2 ) _title_3 = HtmlTemplate.Tag ( "th" ) _title_3.addContent ( u'In wichtigen Fragen' ) _table_titles.addContent ( _title_3 ) _table.addContent ( _table_titles ) _odd = 0 #for denomination_points_key in denomination_points.keys(): for denomination_points_key in _sorted_points_keys: # Prozent zahlen allgemein _all = len ( user_answers.keys() ) _sum_denomination_points = int ( denomination_points [denomination_points_key] ) _relativ = _sum_denomination_points / ( float( _all ) / float ( 100 ) ) # Prozentzahl der Gewichtung _sum_denomination_weighting_points = float ( denomination_weighting_points [denomination_points_key] ) if _max_weighting_points == 0 : _weighting_relativ = 0 else : _one_procent = float( _max_weighting_points ) / float ( 100 ) _weighting_relativ = _sum_denomination_weighting_points / _one_procent _row = HtmlTemplate.Tag ( "tr" ) if _odd == 1: _row.setAttribute ( "class", "oddrow" ) _odd = 0 else: _odd = 1 _col_1 = HtmlTemplate.Tag ( "td" ) _col_1.addContent ( SQLBackend.SQLBackend().getDenominationName( denomination_points_key ) ) _row.addContent ( _col_1 ) _col_2 = HtmlTemplate.Tag ( "td" ) _col_2.setAttribute ( "class", "tabpoints" ) _bar_le = HtmlTemplate.Tag ( "div" ) _bar_le.setAttribute ( "class", "points" ) _bar_le.setAttribute ( "style", 'width:' + unicode ( int ( _relativ ) ) + '%;' ) _bar_le.addContent ( u' ' ) _col_2.addContent ( _bar_le ) _col_2.addContent ( unicode ( int ( _relativ ) ) + ' %' ) _row.addContent ( _col_2 ) _col_3 = HtmlTemplate.Tag ( "td" ) _col_3.setAttribute ( "class", "tabpoints-weighting" ) _bar_ri = HtmlTemplate.Tag ( "div" ) _bar_ri.setAttribute ( "class", "points-weighting" ) _bar_ri.setAttribute ( "style", 'width:' + unicode ( int ( _weighting_relativ ) ) + '%;' ) _bar_ri.addContent ( u' ' ) _col_3.addContent ( _bar_ri ) _col_3.addContent ( unicode ( int ( _weighting_relativ ) ) + ' %' ) _row.addContent ( _col_3 ) _table.addContent ( _row) return _table def GET(self): _ip = unicode ( web.ctx['ip'] ) VisitLog.VisitLog().write ( _ip, 'Teststart' ) _sqlBackend = SQLBackend.SQLBackend() _answer_optionen = self.getAnswers() _last_kat = "" weightingsDict = self.getWeightings () conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() _weightings = _sqlBackend.getDictOfWeightings() cur.execute( ''' SELECT question_id, kat, question, commentary FROM questions ORDER BY kat; ''') _appbox = HtmlTemplate.Tag ( "div" ) _appbox.setAttribute ( "class", "appbox" ) _section_1 = HtmlTemplate.Tag ( "h2" ) _section_1.addContent ( u'''Selbsttest''') _appbox.addContent ( _section_1 ) _section_glossar = HtmlTemplate.Tag ( "h3" ) _section_glossar.addContent ( u'''Glossar - Erleuterung zu den Aussagen.''') _appbox.addContent ( _section_glossar ) _list = HtmlTemplate.Tag ( "ul" ) for _row in _sqlBackend.getAnswersDescriptions () : _item = HtmlTemplate.Tag ( "li" ) _item.addContent ( u'<b>' + unicode(_row[1]) + ':</b> ') _item.addContent ( unicode(_row[2]) ) _list.addContent ( _item ) _appbox.addContent ( _list ) _appbox.addContent ( u'''<p>Mit <b><i>Heilsrelevant</i></b> ist gemeint, das eine Aussage als <b><i>zentrale Glaubensaussage</i></b> verstanden wird. Und das deren Beantwortung (positiv oder negativ) entscheidend dafür ist, ob man sich vor Gott gerechtfertigt glaubt und sich damit die Erlösung verspricht. Ohne zu konkretisieren, was unter <i>Erlösung, Rechtfertigung, Errettung, bzw. Verdammnis, Verwerfung </i> oder der gleichen Wörter zu verstehen ist. Hier wurde <i>"Heilsrelevant"</i> verwendet. Es hätte aber auch durch eine andere Begrifflichkeit ausgedrückt werden können. Auch durch abgemilderte bzw. neutralere Begriffe wie: <i>"entscheidend"</i> und <i>"nicht entscheidend"</i>. Da es sich hier aber um ausschließlich christliche oder christlichen Ursprüngen entstammenden Glaubensgemeinschaften handelt, wurden hier bewusst kein <i>weltanschaulich neutraler"</i> Begriff verwandt.</p>''' ) _form = HtmlTemplate.Tag ( "form" ) _form.setAttribute ( "method", "POST" ) _form.setAttribute ( "name", "belieftest" ) _form.setAttribute ( "action", "belieftest" ) _table = HtmlTemplate.Tag ( "table" ) _table_titles = HtmlTemplate.Tag ( "tr" ) _title_1 = HtmlTemplate.Tag ( "th" ) _title_1.addContent ( u'Nr.' ) _table_titles.addContent ( _title_1 ) _title_3 = HtmlTemplate.Tag ( "th" ) _title_3.addContent ( u'Überzeugnung' ) _table_titles.addContent ( _title_3 ) _title_4 = HtmlTemplate.Tag ( "th" ) _title_4.addContent ( u'Ja/Nein' ) _table_titles.addContent ( _title_4 ) _title_5 = HtmlTemplate.Tag ( "th" ) _title_5.addContent ( u'Gewichtung' ) _table_titles.addContent ( _title_5 ) _table.addContent ( _table_titles ) _odd = 0 _line_count = 1 for row in cur: if _last_kat != row[1] : _table.addContent ( u'''<tr><td class="category" colspan="4"> ''' + unicode ( row[1] ) + u'''</th></tr>''' ) _last_kat = unicode ( row[1] ) _rowTag = HtmlTemplate.Tag ( "tr" ) if _odd == 1: _rowTag.setAttribute ( "class", "oddrow" ) _odd = 0 else: _odd = 1 # column: number _col_1 = HtmlTemplate.Tag ( "td" ) _col_1.addContent ( unicode(_line_count) ) _rowTag.addContent ( _col_1 ) _line_count = _line_count + 1 # column: question _col_3 = HtmlTemplate.Tag ( "td" ) _tooltip = HtmlTemplate.Tag ( "a" ) _tooltip.setAttribute ( "href", "#hint" ) _tooltip.setAttribute ( "class", "tooltip" ) _tooltip.addContent ( unicode( row[2] ) ) _info = HtmlTemplate.Tag ( "span" ) _info.setAttribute ( "class", "info" ) _info.addContent ( u'<b>Erläuterung:</b> ') _info.addContent ( unicode ( row[3] ) ) _tooltip.addContent ( _info ) _col_3.addContent ( _tooltip ) _rowTag.addContent ( _col_3 ) # column: answer _col_4 = HtmlTemplate.Tag ( "td" ) _select = HtmlTemplate.Tag ( "select" ) _select.setAttribute ( "name", u'answer_' + unicode ( row[0] ) ) _select.setAttribute ( "size", "1" ) for _optionenline in _answer_optionen : _option = HtmlTemplate.Tag ( "option" ) _option.setAttribute ( "value", unicode ( _optionenline[0] ) ) _option.addContent ( _optionenline[1] ) _select.addContent ( _option ) _col_4.addContent ( _select ) _rowTag.addContent ( _col_4 ) # column: wight _col_5 = HtmlTemplate.Tag ( "td" ) _select_wight = HtmlTemplate.Tag ( "select" ) _select_wight.setAttribute ( "name", u'wichtung_' + unicode ( row[0] ) ) _select_wight.setAttribute ( "size", "1" ) for _key in _weightings.keys () : _option_1 = HtmlTemplate.Tag ( "option" ) _option_1.setAttribute ( "value", unicode ( _weightings[_key] ) ) _option_1.addContent ( unicode ( _key ) ) _select_wight.addContent ( _option_1 ) _col_5.addContent ( _select_wight ) _rowTag.addContent ( _col_5 ) _table.addContent ( _rowTag ) #_appbox.addContent ( _table ) _form.addContent ( _table ) _p_form = HtmlTemplate.Tag ( "p" ) #_p_form.addContent ( _table ) _p_form.addContent ( u'<br>' ) _button = HtmlTemplate.Tag ( "button" ) _button.addContent ( u'Auswerten' ) _button.setAttribute ( "id", "okay" ) _button.setAttribute ( "name", "okay" ) _p_form.addContent ( _button ) #_p_form.addContent ( form.Button('Auswerten').render() ) _form.addContent ( _p_form ) _appbox.addContent ( _form ) _htmlcode = self.htemp.getCompleteSite( "belieftest", _appbox ) web.header('Content-Type','text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar( _htmlcode ) def POST(self): _ip = unicode ( web.ctx['ip'] ) VisitLog.VisitLog().write ( _ip, 'Testergebnis' ) _appbox = HtmlTemplate.Tag ( "div" ) _appbox.setAttribute ( "class", "appbox" ) _table = self.matchingTable() _appbox.addContent ( _table ) _htmlcode = self.htemp.getCompleteSite( "belieftest", _appbox ) web.header('Content-Type','text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar( _htmlcode )
def GET(self): _ip = unicode ( web.ctx['ip'] ) VisitLog.VisitLog().write ( _ip, 'Teststart' ) _sqlBackend = SQLBackend.SQLBackend() _answer_optionen = self.getAnswers() _last_kat = "" weightingsDict = self.getWeightings () conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() _weightings = _sqlBackend.getDictOfWeightings() cur.execute( ''' SELECT question_id, kat, question, commentary FROM questions ORDER BY kat; ''') _appbox = HtmlTemplate.Tag ( "div" ) _appbox.setAttribute ( "class", "appbox" ) _section_1 = HtmlTemplate.Tag ( "h2" ) _section_1.addContent ( u'''Selbsttest''') _appbox.addContent ( _section_1 ) _section_glossar = HtmlTemplate.Tag ( "h3" ) _section_glossar.addContent ( u'''Glossar - Erleuterung zu den Aussagen.''') _appbox.addContent ( _section_glossar ) _list = HtmlTemplate.Tag ( "ul" ) for _row in _sqlBackend.getAnswersDescriptions () : _item = HtmlTemplate.Tag ( "li" ) _item.addContent ( u'<b>' + unicode(_row[1]) + ':</b> ') _item.addContent ( unicode(_row[2]) ) _list.addContent ( _item ) _appbox.addContent ( _list ) _appbox.addContent ( u'''<p>Mit <b><i>Heilsrelevant</i></b> ist gemeint, das eine Aussage als <b><i>zentrale Glaubensaussage</i></b> verstanden wird. Und das deren Beantwortung (positiv oder negativ) entscheidend dafür ist, ob man sich vor Gott gerechtfertigt glaubt und sich damit die Erlösung verspricht. Ohne zu konkretisieren, was unter <i>Erlösung, Rechtfertigung, Errettung, bzw. Verdammnis, Verwerfung </i> oder der gleichen Wörter zu verstehen ist. Hier wurde <i>"Heilsrelevant"</i> verwendet. Es hätte aber auch durch eine andere Begrifflichkeit ausgedrückt werden können. Auch durch abgemilderte bzw. neutralere Begriffe wie: <i>"entscheidend"</i> und <i>"nicht entscheidend"</i>. Da es sich hier aber um ausschließlich christliche oder christlichen Ursprüngen entstammenden Glaubensgemeinschaften handelt, wurden hier bewusst kein <i>weltanschaulich neutraler"</i> Begriff verwandt.</p>''' ) _form = HtmlTemplate.Tag ( "form" ) _form.setAttribute ( "method", "POST" ) _form.setAttribute ( "name", "belieftest" ) _form.setAttribute ( "action", "belieftest" ) _table = HtmlTemplate.Tag ( "table" ) _table_titles = HtmlTemplate.Tag ( "tr" ) _title_1 = HtmlTemplate.Tag ( "th" ) _title_1.addContent ( u'Nr.' ) _table_titles.addContent ( _title_1 ) _title_3 = HtmlTemplate.Tag ( "th" ) _title_3.addContent ( u'Überzeugnung' ) _table_titles.addContent ( _title_3 ) _title_4 = HtmlTemplate.Tag ( "th" ) _title_4.addContent ( u'Ja/Nein' ) _table_titles.addContent ( _title_4 ) _title_5 = HtmlTemplate.Tag ( "th" ) _title_5.addContent ( u'Gewichtung' ) _table_titles.addContent ( _title_5 ) _table.addContent ( _table_titles ) _odd = 0 _line_count = 1 for row in cur: if _last_kat != row[1] : _table.addContent ( u'''<tr><td class="category" colspan="4"> ''' + unicode ( row[1] ) + u'''</th></tr>''' ) _last_kat = unicode ( row[1] ) _rowTag = HtmlTemplate.Tag ( "tr" ) if _odd == 1: _rowTag.setAttribute ( "class", "oddrow" ) _odd = 0 else: _odd = 1 # column: number _col_1 = HtmlTemplate.Tag ( "td" ) _col_1.addContent ( unicode(_line_count) ) _rowTag.addContent ( _col_1 ) _line_count = _line_count + 1 # column: question _col_3 = HtmlTemplate.Tag ( "td" ) _tooltip = HtmlTemplate.Tag ( "a" ) _tooltip.setAttribute ( "href", "#hint" ) _tooltip.setAttribute ( "class", "tooltip" ) _tooltip.addContent ( unicode( row[2] ) ) _info = HtmlTemplate.Tag ( "span" ) _info.setAttribute ( "class", "info" ) _info.addContent ( u'<b>Erläuterung:</b> ') _info.addContent ( unicode ( row[3] ) ) _tooltip.addContent ( _info ) _col_3.addContent ( _tooltip ) _rowTag.addContent ( _col_3 ) # column: answer _col_4 = HtmlTemplate.Tag ( "td" ) _select = HtmlTemplate.Tag ( "select" ) _select.setAttribute ( "name", u'answer_' + unicode ( row[0] ) ) _select.setAttribute ( "size", "1" ) for _optionenline in _answer_optionen : _option = HtmlTemplate.Tag ( "option" ) _option.setAttribute ( "value", unicode ( _optionenline[0] ) ) _option.addContent ( _optionenline[1] ) _select.addContent ( _option ) _col_4.addContent ( _select ) _rowTag.addContent ( _col_4 ) # column: wight _col_5 = HtmlTemplate.Tag ( "td" ) _select_wight = HtmlTemplate.Tag ( "select" ) _select_wight.setAttribute ( "name", u'wichtung_' + unicode ( row[0] ) ) _select_wight.setAttribute ( "size", "1" ) for _key in _weightings.keys () : _option_1 = HtmlTemplate.Tag ( "option" ) _option_1.setAttribute ( "value", unicode ( _weightings[_key] ) ) _option_1.addContent ( unicode ( _key ) ) _select_wight.addContent ( _option_1 ) _col_5.addContent ( _select_wight ) _rowTag.addContent ( _col_5 ) _table.addContent ( _rowTag ) #_appbox.addContent ( _table ) _form.addContent ( _table ) _p_form = HtmlTemplate.Tag ( "p" ) #_p_form.addContent ( _table ) _p_form.addContent ( u'<br>' ) _button = HtmlTemplate.Tag ( "button" ) _button.addContent ( u'Auswerten' ) _button.setAttribute ( "id", "okay" ) _button.setAttribute ( "name", "okay" ) _p_form.addContent ( _button ) #_p_form.addContent ( form.Button('Auswerten').render() ) _form.addContent ( _p_form ) _appbox.addContent ( _form ) _htmlcode = self.htemp.getCompleteSite( "belieftest", _appbox ) web.header('Content-Type','text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar( _htmlcode )
def getIntro(self, _preSelect): _sqlBackend = SQLBackend.SQLBackend() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute(''' SELECT denomination_id, denomination FROM denominations ORDER BY denomination;''') _intro = HtmlTemplate.Tag("div") _intro.setAttribute("class", "intro") _section_1 = HtmlTemplate.Tag("h2") _section_1.addContent(u'''Datenbasis des Test''') _intro.addContent(_section_1) _p_1 = HtmlTemplate.Tag("p") _p_1.addContent(u'''Hier kannst du sehen, welche Glaubensgemeinschaften in der Datenbank erfasst sind, und mit welchen Überzeugungen. Gut möglich das du einen Fehler entdeckst, oder du noch Daten über eine noch fehlende Glaubensgemeinschaft hinterlegen willst. Dann nimmt mit mir Kontakt auf: <a href="mailto:[email protected]">[email protected]</a>''' ) _intro.addContent(_p_1) _section_glossar = HtmlTemplate.Tag("h3") _section_glossar.addContent( u'''Glossar - Erleuterung zu den Aussagen.''') _intro.addContent(_section_glossar) _list = HtmlTemplate.Tag("ul") for _row in _sqlBackend.getAnswersDescriptions(): _item = HtmlTemplate.Tag("li") _item.addContent(u'<b>' + unicode(_row[3]) + ':</b> ') _item.addContent(unicode(_row[4])) _list.addContent(_item) _intro.addContent(_list) _section_2 = HtmlTemplate.Tag("h2") _section_2.addContent(u'''Hinterlegte Datensätze ansehen''') _intro.addContent(_section_2) #_p_2 = HtmlTemplate.Tag ( "p" ) _form = HtmlTemplate.Tag("form") _form.setAttribute("method", "POST") _form.setAttribute("name", "databaseview") _form.setAttribute("action", "databaseview") _p_3 = HtmlTemplate.Tag("p") _p_3.addContent(u'''Wähle die Glaubensgemeinschaft:''') _select = HtmlTemplate.Tag("select") _select.setAttribute("name", "glaubensgemeinschaft") _select.setAttribute("size", "1") for row in cur: if int(_preSelect) == int(row[0]): _option = u'<option ' _option += u' value="' + unicode(row[0]) + '" ' _option += u' selected >' _option += row[1] _option += u'</option>' else: _option = HtmlTemplate.Tag("option") _option.setAttribute("value", unicode(row[0])) _option.addContent(row[1]) _select.addContent(_option) _p_3.addContent(_select) _p_3.addContent(form.Button('anzeigen').render()) _form.addContent(_p_3) _intro.addContent(_form) conn.close() return _intro
def getEditForm(self, _widgetlist): _id = _widgetlist['edit_denomination'] conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute( ''' SELECT questions.question_id, questions.question, questions.kat, questions.commentary, denomination_answers.answer_nr, denomination_answers.commentary FROM denomination_answers, questions WHERE denomination_answers.denomination_id = ? AND denomination_answers.question_id = questions.question_id ORDER BY questions.kat, denomination_answers.answer_nr; ''', (_id, )) htmlcode = "" _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _section_1 = HtmlTemplate.Tag("h2") _section_1.addContent(u'''SQL-Code-Generator für ''') _section_1.addContent(self.getDenominationName(_id)) _appbox.addContent(_section_1) _form = HtmlTemplate.Tag("form") _form.setAttribute("method", "POST") _form.setAttribute("name", "test") _form.setAttribute("action", "databaseedit") _table = HtmlTemplate.Tag("table") _table_titles = HtmlTemplate.Tag("tr") _title_1 = HtmlTemplate.Tag("th") _title_1.addContent(u'ID') _table_titles.addContent(_title_1) _title_3 = HtmlTemplate.Tag("th") _title_3.addContent(u'Kommentar zu Aussage') _table_titles.addContent(_title_3) _title_4 = HtmlTemplate.Tag("th") _title_4.addContent(u'Ja/Nein') _table_titles.addContent(_title_4) _table.addContent(_table_titles) # loop with exist answers _odd = 0 _count = 1 _last_kat = u'' for _row_array in cur: if _last_kat != _row_array[2]: _table.addContent(u'''<tr><td class="category" colspan="3"> ''' + unicode(_row_array[2]) + u'''</td></tr>''') _last_kat = unicode(_row_array[2]) _count += 1 if _odd == 1: _odd = 0 else: _odd = 1 _rowTag = self.getEditRow(_odd, _row_array) _table.addContent(_rowTag) # loop with not exist answers _cur = self.getNoAnswers(_id) if len(_cur) > 0: _table.addContent( u'<tr><th colspan="4">Bisher nicht hinterlegte Aussagen:</th></tr>' ) _odd = 0 _count = 1 for _row_array in _cur: if _last_kat != _row_array[2]: _table.addContent(u'''<tr><td class="category" colspan="3"> ''' + unicode(_row_array[2]) + u'''</td></tr>''') _last_kat = unicode(_row_array[2]) _count += 1 if _odd == 1: _odd = 0 else: _odd = 1 _rowTag = self.getEditRow(_odd, _row_array) _table.addContent(_rowTag) _form.addContent(_table) _p_editdb = HtmlTemplate.Tag("p") _p_editdb.addContent(u'''<br>''') _button = HtmlTemplate.Tag("button") _button.addContent(u'SQL-Code generieren') _button.setAttribute("id", "gen_sql") _button.setAttribute("name", "gen_sql") _button.setAttribute("value", _id) _p_editdb.addContent(_button) _form.addContent(_p_editdb) _appbox.addContent(_form) return _appbox
def GET(self): _ip = unicode(web.ctx['ip']) VisitLog.VisitLog().write(_ip, 'index') SQLBackend.SQLBackend().getVisitStatistic() conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute(''' SELECT denomination_id, denomination, url FROM denominations ORDER BY denomination; ''') _deno_list = cur.fetchall() htmlcode = "" _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _h2 = HtmlTemplate.Tag("h2") _h2.addContent(u'Willkommen auf dem BELIEF MATCHING') _appbox.addContent(_h2) _h3_aboud = HtmlTemplate.Tag("h3") _h3_aboud.addContent(u'Über dieser Projekt') _appbox.addContent(_h3_aboud) _p_1 = HtmlTemplate.Tag("p") _p_1.addContent( u'''Dieses Programm ist ein Tool, um herauszufinden mit welchen Glaubensgemeinschaften deine eigene Überzeugeng am meisten übereinstimmt. Inspiriert ist das Projekt von dem ''') _link = HtmlTemplate.Tag("a") _link.setAttribute( "href", "http://www.beliefnet.com/Entertainment/Quizzes/BeliefOMatic.aspx") _link.addContent(u'<i>Belief-O-Matic</i>') _link.addContent(" (einer eingetragenen Marke).") _p_1.addContent(_link) _appbox.addContent(_p_1) _p_2 = HtmlTemplate.Tag("p") _p_2.addContent(u'''Es gibt bekanntlich <i>sehr</i> viele verschiedene Glaubensgemeinschaften. Dieses Programm konzentriert sich auf die christlichen Konfessionen, die im deutschsprachigem Raum anzutreffen sind. Und auch das dürften schon viele Dutzende sein.''') _appbox.addContent(_p_2) _p_3 = HtmlTemplate.Tag("p") _p_3.addContent(u'Bisher wurden die folgenden ') _p_3.addContent(unicode(len(_deno_list))) _p_3.addContent(u' Konfessionen in die Datenbank eingepflegt:') _appbox.addContent(_p_3) _list = HtmlTemplate.Tag("ol") for row in _deno_list: _item_link = HtmlTemplate.Tag("a") _item_link.setAttribute("href", row[2]) _item_link.addContent(row[1]) _item = HtmlTemplate.Tag("li") _item.addContent(_item_link) _list.addContent(_item) _appbox.addContent(_list) _p_4 = HtmlTemplate.Tag("p") _p_4.addContent(u'''<b>Bitte nimm das Ergebnis des Test nicht all zu ernst!</b> Ein Computer-Programm' kann nur ein sehr begrenztes Spektrum der realen Welt abstrahieren. Selbstverständlich ist eine (Glaubens-)Gemeinschaft mehr als die Summe ihre Grundsätze. Das Programm soll viel mehr anregen, über die eigenen Anschauungen und die der anderen nachzudenken; Gemeinsamkeiten aber auch Unterschiede zu entdecken.''') _appbox.addContent(_p_4) _h3_todo = HtmlTemplate.Tag("h3") _h3_todo.addContent(u'Stand der Arbeit') _appbox.addContent(_h3_todo) _p_5 = HtmlTemplate.Tag("p") _p_5.addContent(u'''Es wird noch einige Zeit brauchen, bis alle - oder die meisten - Konfessionen in die Datenbank eingepflegt sind. Du kannst aber mithelfen den Prozess zu beschleunigen und die Quallität zu verbessern, indem du deine Anmerkungen und Vorschläge an mich schickst (<a href="mailto:[email protected]"> [email protected]</a>. Oder du Machst ein so genanntes <i>Ticket</i> auf unter: <a href="http://sourceforge.net/p/belief-matching/tickets/"> http://sourceforge.net/p/belief-matching/tickets/</a> Hier werden Änderungswünsche gesammelt und bearbeitet. Da kannst du (und andere) verfolgen, was deinen Änderungswünsche geworden ist. <br><br> Oder wenn du sogar mit SQL umgehen kannst, kannst du auch direkt über <a href="https://github.com/OlafRadicke/belief-matching">GitHub</a> am Code mitarbeiten. Die Software steht unter der <a href="http://de.wikipedia.org/wiki/GNU_Affero_General_Public_License"> GNU Affero General Public License</a>, also also eine freie Software, die du benutzen, verändern und weitergeben darfst. Vorausgesetzt, das du allen Anderen die selben Rechte einräumst.''') _appbox.addContent(_p_5) _p_6 = HtmlTemplate.Tag("p") _p_6.addContent( u'''Der Name des Projektes <i>belief-matching</i> ist nur ein vorläufiger Arbeitstitel. Die Suche nach einem geeigneten Namen ist noch nicht abgeschlossen. Für Vorschläge hierzu bin ich dankbar.''') _appbox.addContent(_p_6) htmlcode += self.htemp.getCompleteSite("home", _appbox) #return self.htemp.convertGermanChar( htmlcode ) #print htmlcode web.header('Content-Type', 'text/html; charset=utf-8', unique=True) return htmlcode
def POST(self): _ip = unicode(web.ctx['ip']) VisitLog.VisitLog().write(_ip, 'Datenbasisabfrage') widgetlist = web.input(groups=[]) _id = widgetlist['glaubensgemeinschaft'] conn = sqlite3.connect('belief-matching.sqlite') cur = conn.cursor() cur.execute( ''' SELECT questions.question, denomination_answers.answer_nr, denomination_answers.commentary, answers.deno_statement, questions.kat FROM denomination_answers, questions, answers WHERE denomination_answers.denomination_id = ? AND denomination_answers.question_id = questions.question_id AND denomination_answers.answer_nr = answers.answers_nr ORDER BY questions.kat, denomination_answers.answer_nr, questions.question; ''', (_id, )) htmlcode = "" _appbox = HtmlTemplate.Tag("div") _appbox.setAttribute("class", "appbox") _intro = self.getIntro(_id) _appbox.addContent(_intro) _appbox.addContent(u'<br/>') _table = HtmlTemplate.Tag("table") _table_titles = HtmlTemplate.Tag("tr") _title = HtmlTemplate.Tag("th") _title.addContent(u'Aussage zum Glauben (Mehr Infos unter ') _titleLink = HtmlTemplate.Tag("a") _titleLink.setAttribute("href", self.getUrlOfDenomination(_id)) _titleLink.addContent(self.getUrlOfDenomination(_id)) _title.addContent(_titleLink) _table_titles.addContent(_title) _title.addContent(u")") _table.addContent(_table_titles) _last_kat = u'' for row in cur: if _last_kat != row[4]: _table.addContent(u'''<tr><td class="category"> ''' + unicode(row[4]) + u'''</td></tr>''') _last_kat = unicode(row[4]) _row = HtmlTemplate.Tag("tr") _col = HtmlTemplate.Tag("td") if int(row[1]) == 0: _row.setAttribute("class", "no") _col.addContent(u'<b>' + unicode(row[3]) + ':</b> ') elif int(row[1]) == 1: _row.setAttribute("class", "yes") _col.addContent(u'<b>' + unicode(row[3]) + ':</b> ') elif int(row[1]) == 2: _row.setAttribute("class", "void") _col.addContent(u'<b>' + unicode(row[3]) + ':</b> ') else: _row.setAttribute("class", "void") _col.addContent(u'<b>' + unicode(row[3]) + ':</b> ') #_tooltip = HtmlTemplate.Tag ( "a" ) #_tooltip.setAttribute ( "href", "#hint" ) #_tooltip.setAttribute ( "class", "tooltip" ) #_tooltip.addContent ( unicode(row[0] ) ) #_info = HtmlTemplate.Tag ( "span" ) #_info.setAttribute ( "class", "info" ) #_info.addContent ( u'<b>Erläuterung:</b> ') #_info.addContent ( unicode(row[2]) ) #_tooltip.addContent ( _info ) #_col.addContent ( _tooltip ) _col.addContent(unicode(row[0])) _wbox = HtmlTemplate.Tag("div") _wbox.setAttribute("class", "whitebox") _small = HtmlTemplate.Tag("small") _small.addContent(u'<b>Erleuterung:</b> ' + unicode(row[2])) _wbox.addContent(_small) _col.addContent(_wbox) _row.addContent(_col) _table.addContent(_row) _appbox.addContent(_table) _form = HtmlTemplate.Tag("form") _form.setAttribute("method", "POST") _form.setAttribute("name", "databaseedit") _form.setAttribute("action", "databaseedit") _noAnswersCount = self.getNoAnswersCount(_id) if _noAnswersCount > 0: _infoBox = HtmlTemplate.Tag("div") _infoBox.setAttribute("class", "infobox") if _noAnswersCount > 1: _infoBox.addContent(u'Es gibt noch ') _infoBox.addContent(unicode(_noAnswersCount)) _infoBox.addContent(u''' Aussagen zu der noch keine Antworten hinterlegt wurde.''') else: _infoBox.addContent(u'''Es gibt noch eine Aussage zu der noch keine Antwort hinterlegt wurde.''') _form.addContent(_infoBox) _h2_editdb = HtmlTemplate.Tag("h2") _h2_editdb.addContent(u'Änderungswünsche') _form.addContent(_h2_editdb) _p_editdb = HtmlTemplate.Tag("p") _p_editdb.addContent( u'''<b>Du bist nicht mit allen Punkten einverstanden?</b> oder es gibt noch Aussage zu denen noch keine Antwort hinterlegt wurde. Dann sende mir deine Liste mit den Änderungswünsche: ''') _button = HtmlTemplate.Tag("button") _button.addContent(u'Jetzt erstellen') _button.setAttribute("id", "edit_denomination") _button.setAttribute("name", "edit_denomination") _button.setAttribute("value", _id) _p_editdb.addContent(_button) _form.addContent(_p_editdb) _appbox.addContent(_form) htmlcode += self.htemp.getCompleteSite("databaseview", _appbox) web.header('Content-Type', 'text/html; charset=utf-8', unique=True) return self.htemp.convertGermanChar(htmlcode)