Commit 2e2a953d authored by Alexander B. Ustinov's avatar Alexander B. Ustinov
Browse files

get templates from module

parent 56f9e186
......@@ -9,14 +9,17 @@ import operator
import pickle
import base64
import pydirector_templates
from . import cursor
from .documents import _compile
from petrovich.main import Petrovich
from petrovich.enums import Case, Gender
from conf import BADMARKS
TEMPLATE_DIR='/home/builder/phnteur/tmp/pydirector-templates/old_templates'
TEMPLATE_DIR=pathlib.Path(pydirector_templates.__file__).resolve().parent
loader = jinja2.PackageLoader('pydirector_templates', '.')
lajinja=jinja2.Environment(
block_start_string='\BLOCK{',
block_end_string='}',
......@@ -28,7 +31,7 @@ line_statement_prefix='%%',
line_comment_prefix='%#',
trim_blocks=True,
autoescape=False,
loader=jinja2.FileSystemLoader(TEMPLATE_DIR))
loader=loader)
dir=tempfile.TemporaryDirectory()
basepath=dir.name+'/'
......@@ -107,14 +110,14 @@ def printfinals(id, fromweb=False, html=False, rss=False, tex=False):
if html:
finals = 'finalsrss' if rss else 'finals'
template = htjinja.get_template(f'{finals}.html')
template = htjinja.get_template(f'old_templates/{finals}.html')
return template.render(exam=exam,whenexam=whenexam,students=students,discipline=discipline,date=date,resolution=resolution,dateexam=dateexam,whereexam=whereexam,teacherss=teachers,written=written, director=director, dirtitle=dirtitle,online=online)
elif tex:
template = lajinja.get_template('finals.tex')
template = lajinja.get_template('old_templates/finals.tex')
return template.render(exam=exam,whenexam=whenexam,students=students.replace('/','\slash\hspace{0pt}'),discipline=discipline,date=date,resolution=resolution,dateexam=dateexam,whereexam=whereexam,teacherss=teachers,written=written, director=director, dirtitle=dirtitle, online=online)
else:
template = lajinja.get_template('finals.tex')
template = lajinja.get_template('old_templates/finals.tex')
filename = 'finals'
with open(basepath+filename + '.tex', 'w') as f:
f.write(template.render(exam=exam,whenexam=whenexam,students=students.replace('/','\slash\hspace{0pt}'),discipline=discipline,date=date,resolution=resolution,dateexam=dateexam,whereexam=whereexam,teacherss=teachers,written=written, director=director, dirtitle=dirtitle, online=online))
......@@ -152,7 +155,7 @@ def finalsdocs(finalsid,fromweb=False):
dpt += parts[0].capitalize()
teachers.append((post.capitalize()+dpt,firstname+' '+(middlename[0]+'.' if len(middlename)>0 else '')+(lastname[0]+'.' if len(lastname)>0 else '')))
template = lajinja.get_template('deductiontemplate.tex')
template = lajinja.get_template('old_templates/deductiontemplate.tex')
filename = 'deductions'
with open(basepath+filename + '.tex', 'w') as f:
f.write(template.render(ress=res,curr=cur,stuu=stu,finn=fin,teacherss=teachers,case=Case.ACCUSATIVE,written=written, director=director, dirtitle=dirtitle))
......@@ -214,7 +217,7 @@ def printtable(discipline, groups, exam, teacher='', date='', fromweb=False, sem
global basepath
try:
template = lajinja.get_template('table.tex')
template = lajinja.get_template('old_templates/table.tex')
except:
template = lajinja.get_template('phnteur/pypuminer/templates/table.tex')
numbered = []
......@@ -245,7 +248,7 @@ def printdeduct(idlist, fromweb=False):
cur.execute("SELECT name,grp,course FROM students where active and spbstuid = any (%s);" , (idlist, ))
global basepath
template = lajinja.get_template('deductnotes.tex')
template = lajinja.get_template('old_templates/deductnotes.tex')
filename = 'deductnotes'
......
from setuptools import setup, find_packages
setup(
name="pydirector",
version="0.0.1",
version="0.1.0",
packages=find_packages(),
scripts=[],
......@@ -10,4 +10,5 @@ setup(
author="Alexander B. Ustinov",
author_email="ustinov@phys-el.ru",
description="Object-oriented approach to solving directorate problems"
install_requires=['pydirector-templates @ git+https://gitlab.phys-el.ru/ustinov/pydirector-templates.git']
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment