예제 #1
0
import db
import templater
import utils
Monad.getUtils()['impt'](globals(), 'db', 'utils', 'templater')
inv, template = globals()['inv'], globals()['template']


def make_fields():
    initial_date = datetime.utcnow().replace(tzinfo=pytz.utc)
    initial_date = datetime(initial_date.year, initial_date.month, 1)
    return {'initial_date': initial_date}

sess = None
try:
    sess = db.session()
    if inv.getRequest().getMethod() == 'GET':
        templater.render(inv, template, make_fields())
    else:
        db.set_read_write(sess)
        name = inv.getString('name')
        is_core = inv.getBoolean('is_core')
        start_date = utils.form_date(inv, 'start')
        contract = db.Contract.insert_non_core(
            sess, is_core, name, '{}', '{}', start_date, None, '{}')
        sess.commit()
        inv.sendSeeOther(
            '/reports/267/output/?non_core_contract_id=' + str(contract.id))
finally:
    if sess is not None:
        sess.close()
예제 #2
0
파일: script.py 프로젝트: chanoch/chellow
from sqlalchemy import or_
from sqlalchemy.sql.expression import null, true
import db
import utils
import computer

Monad.getUtils()["impt"](globals(), "db", "utils", "templater", "computer")
inv = globals()["inv"]

Supply, Era, Site, SiteEra = db.Supply, db.Era, db.Site, db.SiteEra
HH, hh_format = utils.HH, utils.hh_format

caches = {}

supply_id = inv.getLong("supply_id")
start_date = utils.form_date(inv, "start")
finish_date = utils.form_date(inv, "finish")
file_name = "supply_virtual_bills_hh_" + str(supply_id) + ".csv"


def content():
    sess = None
    try:
        sess = db.session()
        supply = Supply.get_by_id(sess, supply_id)

        forecast_date = computer.forecast_date()

        prev_titles = None

        hh_start = start_date
예제 #3
0
from sqlalchemy.sql.expression import null, true
import db
import utils
import zipfile
import threading
import os
import dloads

Monad.getUtils()['impt'](globals(), 'db', 'utils', 'templater', 'dloads')
HhDatum, Channel, Era, Supply = db.HhDatum, db.Channel, db.Era, db.Supply
Site, SiteEra = db.Site, db.SiteEra
hh_format, UserException = utils.hh_format, utils.UserException
form_str, form_bool = utils.form_str, utils.form_bool
inv = globals()['inv']

start_date = utils.form_date(inv, 'start')
finish_date = utils.form_date(inv, 'finish')

method = inv.getRequest().getMethod()

if inv.hasParameter('supply_id'):
    supply_id = inv.getLong('supply_id')
else:
    supply_id = None

if inv.hasParameter('mpan_cores'):
    mpan_cores_str = form_str(inv, 'mpan_cores')
    mpan_cores = mpan_cores_str.splitlines()
    if len(mpan_cores) == 0:
        mpan_cores = None
    else:
예제 #4
0
from net.sf.chellow.monad import Monad
import db
import templater
import utils
Monad.getUtils()['impt'](globals(), 'db', 'utils', 'templater')
Snag, Site = db.Snag, db.Site
render = templater.render
inv, template = globals()['inv'], globals()['template']

sess = None
try:
    sess = db.session()
    if inv.getRequest().getMethod() == 'GET':
        render(inv, template, {})
    else:
        db.set_read_write(sess)
        finish_date = utils.form_date(inv, 'ignore')
        sess.execute(
            "update snag set is_ignored = true "
            "where snag.site_id is not null and "
            "snag.finish_date < :finish_date", {'finish_date': finish_date})
        sess.commit()
        inv.sendSeeOther('/reports/39/output/')
except utils.UserException, e:
        render(inv, template, {'messages': [str(e)]}, 400)
finally:
    if sess is not None:
        sess.close()