def board(request, name): model = models.Model() all_categorys = model.get_all_categorys() all_boards = [] for category in all_categorys: boards_from = model.get_all_boards_from_category(category) all_boards += boards_from board = model.get_board_by_adr(adr=name) all_treads = model.get_all_treads_by_date(board) class obert(): def __init__(self, mid, name): self.id = mid self.name = name id_all_treads = [x.id for x in all_treads] treads = [] for tread in all_treads: treads.append(obert(tread.id, model.get_all_records_from(tread, board))) template = Template('boards.html') context = Context({'treads': treads, 'board': board, 'all_boards': all_boards}) return HttpResponse(template.render(context))
def b(request): template = Template('b.html') test = models.Model() tread = models.Tread(1, now_timestamp()) testlist = test.get_all_records_from(tread) context = Context({'lol': testlist}) result = template.render(context) return HttpResponse(result)
def index(request): model = models.Model() categ = model.get_all_categorys() newcateg = [] for cat in categ: catboard = model.get_all_boards_from_category(cat) newcateg.append({cat.name: catboard}) template = Template('index.html') con = {"categorys": categ, "categ_list": newcateg, 'welcome_text': 'Welcome back. Again.'} context = Context(con) result = template.render(context) return HttpResponse(result)
def tread(request, board_adr, tread_id): model = models.Model() all_categorys = model.get_all_categorys() all_boards = [] for category in all_categorys: boards_from = model.get_all_boards_from_category(category) all_boards += boards_from board = model.get_board_by_adr(adr=board_adr) tread = model.get_tread_by_id(tread_id, board=board) posts = model.get_all_records_from(tread, board) template = Template('tread.html') context = Context({'board': board,'tread': tread, 'posts': posts, 'all_boards': all_boards}) return HttpResponse(template.render(context))
def adminum(request): model = models.Model() if request.method == 'POST': try: if request.POST.has_key('cname'): model.add_new_category(models.get_simple_category( lib.utils.get_normal_string(request.POST["cname"]))) else: model.add_new_board_to_category( models.get_simple_board( lib.utils.get_normal_string(request.POST["bname"]), lib.utils.get_normal_string(request.POST["badr"]), request.POST["cat"]) , model.get_category_by_id(request.POST["cat"])) except KeyError as e: return HttpResponse(str(request.POST)+str(request.POST.has_key('cname'))) categ = model.get_all_categorys() newcateg = [] for cat in categ: catboard = model.get_all_boards_from_category(cat) newcateg.append({cat.name: catboard}) return HttpResponse(Template('admin.html').render(Context({ "categorys": categ, "categ_list": newcateg})))
def handle_new_tread(request): #lib.utils.get_board_name_from_referer(request['HTTP_REFERER']) request.POST["pname"] = wakaba(strip_tags(request.POST["pname"])) request.POST["pmail"] = wakaba(strip_tags(request.POST["pmail"])) request.POST["ptitle"] = wakaba(strip_tags(request.POST["ptitle"])) request.POST["ppost"] = wakaba(strip_tags(request.POST["ppost"])) model = models.Model() if request.POST["pname"] == '': request.POST["pname"] = "Anonymous" NewRecord = models.get_simple_record(name=request.POST["pname"], email=request.POST["pmail"], title=request.POST["ptitle"], post=request.POST["ppost"]) MyBoard = models.get_simple_board( adr=lib.utils.get_board_name_from_referer(request['HTTP_REFERER'])) model.add_new_tread_to_board_by_record(NewRecord, MyBoard) newstr = str(lib.utils.get_board_name_from_referer( request['HTTP_REFERER'])) + ", " + str(request.POST["pname"]) con = { "lol": newstr, "boardname": lib.utils.get_board_name_from_referer(request['HTTP_REFERER']) } return HttpResponse(Template('treadcreated.html').render(Context(con)))
def handle_new_record(request): model = models.Model() request.POST["pname"] = wakaba(strip_tags(request.POST["pname"])) request.POST["pmail"] = wakaba(strip_tags(request.POST["pmail"])) request.POST["ptitle"] = wakaba(strip_tags(request.POST["ptitle"])) request.POST["ppost"] = wakaba(strip_tags(request.POST["ppost"])) if request.POST["pname"] == '': request.POST["pname"] = "Anonymous" NewRecord = models.get_simple_record(name=request.POST["pname"], email=request.POST["pmail"], title=request.POST["ptitle"], post=request.POST["ppost"]) MyBoard = models.get_simple_board(adr=request.POST["boardadr"]) MyTread = model.get_tread_by_id(request.POST["treadid"], MyBoard) model.insert_record_into(MyTread, NewRecord, MyBoard) newstr = str(request.POST["boardadr"]) + ", в треде " + str( request.POST["treadid"]) + ", " + str(request.POST["pname"]) con = { "lol": newstr, "treadname": request.POST["treadid"], "boardname": request.POST["boardadr"] } return HttpResponse(Template('recordcreated.html').render(Context(con)))
def _init_attributes(self): for attr, value in self.etree.attrib.items(): callback = getattr(self, 'attribute_%s' % attr) assert callback, 'Unsupported attribute: %s' % attr if attr == 'iter': self.actions.append(Variable(value, callback)) elif attr == 'showif': self.actions.append(TruthTemplate(value, callback)) elif re.findall(Template.REGEX, value): self.actions.append(Template(value, callback)) else: callback(value)
def faq(request): template = Template('faq.html') context = Context({'s': 'gogog ogogog'}) result = template.render(context) return HttpResponse(result)
from lib.optomate import Optomate from lib.template import Template ot = Optomate() customers = ot.getScriptPx() c = customers[0] tpl = Template('script') tpl.process(c) print(tpl.template)
def test(request): template = Template('addtread.html') context = Context({}) result = template.render(context) return HttpResponse(result)
def ip(request): return HttpResponse(Template('ip.html').render(Context({})))
#!/usr/bin/env python3 import os import sys import subprocess import json from lib.logger import logger as log from lib.config import Config from lib.template import Template # Set working directory os.chdir(os.path.dirname(os.path.realpath(__file__))) # Init renderer = Template() # Log the configuration for debuging. OBS! The password is visible. Do not run in a production environment log.debug(json.dumps(Config.pdns_conf, indent=2)) log.debug(json.dumps(Config.autosecondary, indent=2)) def gen_pdns_version(): result = None name = str(Config.powerdns_app_version) result = f'{name[0]}.{name[1]}.0' return result def gpgsql(): from lib.migrations.gpgsql import install, migrate, execute_sql_schema, wait_for_db