示例#1
0
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))
示例#2
0
文件: first.py 项目: Pycz/PyImgBoard
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))
示例#3
0
文件: first.py 项目: Pycz/PyImgBoard
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)
示例#4
0
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)
示例#5
0
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)
示例#6
0
文件: first.py 项目: Pycz/PyImgBoard
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)
示例#7
0
文件: first.py 项目: Pycz/PyImgBoard
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))
示例#8
0
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))
示例#9
0
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})))

          
示例#10
0
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)))
示例#11
0
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)))
示例#12
0
    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)
示例#13
0
文件: first.py 项目: Pycz/PyImgBoard
def faq(request):
    template = Template('faq.html')
    context = Context({'s': 'gogog ogogog'})
    result = template.render(context)
    return HttpResponse(result)
示例#14
0
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)
示例#15
0
def test(request):
    template = Template('addtread.html')
    context = Context({})
    result = template.render(context)
    return HttpResponse(result)
示例#16
0
文件: first.py 项目: Pycz/PyImgBoard
def test(request):
    template = Template('addtread.html')
    context = Context({})
    result = template.render(context)
    return HttpResponse(result)
示例#17
0
def ip(request):
    return HttpResponse(Template('ip.html').render(Context({})))
示例#18
0
def faq(request):
    template = Template('faq.html')
    context = Context({'s': 'gogog ogogog'})
    result = template.render(context)
    return HttpResponse(result)
示例#19
0
#!/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