コード例 #1
0
def log_history_new(cls , cid, num, user_id=0, day=None):
    if day is None:
        day = today_days()
    c = LogHistory.raw_sql(
        'select num from log_history where cid=%s and day<%s order by day desc limit 1',
        cid, day
    )
    pre_num = c.fetchone()
    if pre_num:
        pre_num = pre_num[0]

    if pre_num:
        incr = num - pre_num
    else:
        incr = 0

    max_id = cls.raw_sql('select max(id) from %s'%cls.Meta.table).fetchone()
    if max_id:
        max_id = max_id[0]
    else:
        max_id = 0

    #print "'insert into log_history (day,num,incr,cid, max_id, user_id) values (%s,%s,%s,%s,%s,%s) on duplicate key update num=%s, incr=%s, max_id=%s'"%(day , num, incr, cid, max_id,user_id, num, incr, max_id)
    LogHistory.raw_sql(
'insert into log_history (day,num,incr,cid, max_id, user_id) values (%s,%s,%s,%s,%s,%s) on duplicate key update num=%s, incr=%s, max_id=%s',
    day , num, incr, cid, max_id, user_id, num, incr, max_id
    )
コード例 #2
0
ファイル: log_history.py プロジェクト: xqk/42qu_github_mirror
def log_history_new(cls, cid, num, user_id=0, day=None):
    if day is None:
        day = today_days()
    c = LogHistory.raw_sql(
        'select num from log_history where cid=%s and day<%s order by day desc limit 1',
        cid, day)
    pre_num = c.fetchone()
    if pre_num:
        pre_num = pre_num[0]

    if pre_num:
        incr = num - pre_num
    else:
        incr = 0

    max_id = cls.raw_sql('select max(id) from %s' % cls.Meta.table).fetchone()
    if max_id:
        max_id = max_id[0]
    else:
        max_id = 0

    #print "'insert into log_history (day,num,incr,cid, max_id, user_id) values (%s,%s,%s,%s,%s,%s) on duplicate key update num=%s, incr=%s, max_id=%s'"%(day , num, incr, cid, max_id,user_id, num, incr, max_id)
    LogHistory.raw_sql(
        'insert into log_history (day,num,incr,cid, max_id, user_id) values (%s,%s,%s,%s,%s,%s) on duplicate key update num=%s, incr=%s, max_id=%s',
        day, num, incr, cid, max_id, user_id, num, incr, max_id)
コード例 #3
0
def zsite_book_lib_browse(id, user_id, days, admin_id):
    zsite_book_lib = ZsiteBookLib.mc_get(id)
    b = ZsiteBookBrowse.get_or_create(id=id)
    b.begin_days = today_days()
    b.expire = b.begin_days+days
    b.admin_id = admin_id
    b.save()
    if zsite_book_lib.is_exist:
        zsite_book_lib.owner_id = user_id
        zsite_book_lib.state = ZSITE_BOOK_LIB_STATE_BROWSE
        zsite_book_lib.save()
コード例 #4
0
ファイル: zsite_book.py プロジェクト: xqk/42qu_github_mirror
def zsite_book_lib_browse(id, user_id, days, admin_id):
    zsite_book_lib = ZsiteBookLib.mc_get(id)
    b = ZsiteBookBrowse.get_or_create(id=id)
    b.begin_days = today_days()
    b.expire = b.begin_days + days
    b.admin_id = admin_id
    b.save()
    if zsite_book_lib.is_exist:
        zsite_book_lib.owner_id = user_id
        zsite_book_lib.state = ZSITE_BOOK_LIB_STATE_BROWSE
        zsite_book_lib.save()
コード例 #5
0
def re_send_verify():
    today = today_days() * ONE_DAY
    ago = today - ONE_DAY * 6
    week_ago = ago - ONE_DAY
    for i in Verify.where('create_time>%s and create_time<%s', week_ago, ago):
        user_id = i.user_id
        user = Zsite.mc_get(user_id)
        if user and user.state == ZSITE_STATE_APPLY:
            name = user.name
            mail = mail_by_user_id(user_id)
            id = i.id
            ck = i.value
            template = '/mail/auth/verify/miss.txt'
            rendermail(template, mail, name, id=id, ck=ck)
コード例 #6
0
ファイル: zsite_book.py プロジェクト: xqk/42qu_github_mirror
def zsite_book_lib_return(id, admin_id):
    zsite_book_lib = ZsiteBookLib.mc_get(id)
    if not zsite_book_lib.is_exist:

        browse = ZsiteBookBrowse.mc_get(id)
        if browse:
            ZsiteBookBrowseHistory(book_lib_id=id,
                                   begin_days=browse.begin_days,
                                   end_days=today_days(),
                                   user_id=zsite_book_lib.owner_id,
                                   admin_id=admin_id).save()
            browse.delete()
        zsite_book_lib.owner_id = 0
        zsite_book_lib.state = ZSITE_BOOK_LIB_STATE_EXIST
        zsite_book_lib.save()
コード例 #7
0
def zsite_book_lib_return(id, admin_id):
    zsite_book_lib = ZsiteBookLib.mc_get(id)
    if not zsite_book_lib.is_exist:

        browse = ZsiteBookBrowse.mc_get(id)
        if browse:
            ZsiteBookBrowseHistory(
                book_lib_id = id,
                begin_days  = browse.begin_days,
                end_days    = today_days(),
                user_id     = zsite_book_lib.owner_id,
                admin_id    = admin_id
            ).save()
            browse.delete()
        zsite_book_lib.owner_id = 0
        zsite_book_lib.state = ZSITE_BOOK_LIB_STATE_EXIST
        zsite_book_lib.save()
コード例 #8
0
 def expired_days(self):
     now = today_days()
     if self.expire < now:
         return now - self.expire 
     return 0
コード例 #9
0
ファイル: job.py プロジェクト: immissile/42qu_github_mirror
def _job_save(self, job=None, add=None):
    errtip = Errtip()
    department_id = self.get_argument('depart', None)
    title = self.get_argument('title', None)
    kinds = self.get_argument('kinds', None)
    stock_option = self.get_argument('share', None)
    priority = self.get_argument('more', None)
    job_type = self.get_arguments('type', None)
    require = self.get_argument('require', None)
    txt = self.get_argument('txt', None)
    welfare = self.get_argument('other', None)
    salary_from = self.get_argument('salary1', None)
    salary_to = self.get_argument('salary2', None)
    salary_type = self.get_argument('sal_type', None)
    dead_line = self.get_argument('deadline', None)
    pids = self.get_arguments('addr', None)
    quota = self.get_argument('quota', None)

    if not department_id:
        errtip.department_id = '请选择部门'
    if not title:
        errtip.title = '请输入职位头衔'
    if not kinds:
        errtip.kinds = '请选择行业'
    if not job_type:
        errtip.job_type = '请选择工作种类'
    if not pids:
        errtip.addr = '请选择工作地址'
    if not quota.isdigit():
        errtip.quota = '请设定人数'
    if not (salary_from and salary_to):
        errtip.salary = '必须设定薪水'
    if not(salary_from.isdigit() and salary_to.isdigit()):
        errtip.salary = '请输入正确的薪水'
    else:
        salary_from = int(salary_from)
        salary_to = int(salary_to)
        if salary_from > salary_to:
            salary_to, salary_from = salary_from, salary_to

    if not txt:
        errtip.txt = '请填写职位描述'
    if not dead_line:
        errtip.dead_line = '必须选择过期时间'
    if not salary_type:
        errtip.salary_type = '必须选择工资类型'

    if not errtip:
        cj = job_new(
                self.zsite_id,
                department_id,
                title,
                today_days(),
                salary_from,
                salary_to,
                salary_type,
                int(dead_line)+today_days(),
                quota,
                txt,
                require, stock_option, welfare, priority,
                pids,
                job_type,
                kinds.split('-'),
                job
            )
        if add:
            return self.redirect('/job/admin')
        elif not job:
            return self.redirect('/job/next')
        else:
            return self.redirect('/job/admin')
    else:
        self.render(
                errtip=errtip,
                title=title,
                stock_option=stock_option,
                kinds=kinds.split('-'),
                priority=priority,
                job_type=job_type,
                require=require,
                txt=txt,
                welfare=welfare,
                salary_type=salary_type,
                salary1=salary_from,
                salary2=salary_to,
                dead_line=dead_line,
                addr=pids,
                quota=quota,
        )
コード例 #10
0
def event_ready_mail(begin):
    end = (today_days() + 3) * ONE_DAY_MINUTE
    for event in ormiter(Event, 'state=%s and begin_time>%s and begin_time<=%s' % (EVENT_STATE_BEGIN, begin, end)):
        event_ready(event)
    return end
コード例 #11
0
def _job_save(self, job=None, add=None):
    errtip = Errtip()
    department_id = self.get_argument('depart', None)
    title = self.get_argument('title', None)
    kinds = self.get_argument('kinds', None)
    stock_option = self.get_argument('share', None)
    priority = self.get_argument('more', None)
    job_type = self.get_arguments('type', None)
    require = self.get_argument('require', None)
    txt = self.get_argument('txt', None)
    welfare = self.get_argument('other', None)
    salary_from = self.get_argument('salary1', None)
    salary_to = self.get_argument('salary2', None)
    salary_type = self.get_argument('sal_type', None)
    dead_line = self.get_argument('deadline', None)
    pids = self.get_arguments('addr', None)
    quota = self.get_argument('quota', None)

    if not department_id:
        errtip.department_id = '请选择部门'
    if not title:
        errtip.title = '请输入职位头衔'
    if not kinds:
        errtip.kinds = '请选择行业'
    if not job_type:
        errtip.job_type = '请选择工作种类'
    if not pids:
        errtip.addr = '请选择工作地址'
    if not quota.isdigit():
        errtip.quota = '请设定人数'
    if not (salary_from and salary_to):
        errtip.salary = '必须设定薪水'
    if not (salary_from.isdigit() and salary_to.isdigit()):
        errtip.salary = '请输入正确的薪水'
    else:
        salary_from = int(salary_from)
        salary_to = int(salary_to)
        if salary_from > salary_to:
            salary_to, salary_from = salary_from, salary_to

    if not txt:
        errtip.txt = '请填写职位描述'
    if not dead_line:
        errtip.dead_line = '必须选择过期时间'
    if not salary_type:
        errtip.salary_type = '必须选择工资类型'

    if not errtip:
        cj = job_new(self.zsite_id, department_id, title, today_days(),
                     salary_from, salary_to, salary_type,
                     int(dead_line) + today_days(), quota, txt, require,
                     stock_option, welfare, priority, pids, job_type,
                     kinds.split('-'), job)
        if add:
            return self.redirect('/job/admin')
        elif not job:
            return self.redirect('/job/next')
        else:
            return self.redirect('/job/admin')
    else:
        self.render(
            errtip=errtip,
            title=title,
            stock_option=stock_option,
            kinds=kinds.split('-'),
            priority=priority,
            job_type=job_type,
            require=require,
            txt=txt,
            welfare=welfare,
            salary_type=salary_type,
            salary1=salary_from,
            salary2=salary_to,
            dead_line=dead_line,
            addr=pids,
            quota=quota,
        )
コード例 #12
0
ファイル: zsite_book.py プロジェクト: xqk/42qu_github_mirror
 def expired_days(self):
     now = today_days()
     if self.expire < now:
         return now - self.expire
     return 0