Example #1
0
def formatSubscribeTransactionToText(fab, transaction):
    oldVal = transaction['oldValue']
    newVal = transaction['newValue']
    oldVal = UserInfo().getUsersRealName(oldVal)
    newVal = UserInfo().getUsersRealName(newVal)
    if type(oldVal) == list:
        oldVal = reduce(lambda x, y: x + u' ' + y, oldVal, u"")
    if type(newVal) == list:
        newVal = reduce(lambda x, y: x + u' ' + y, newVal, u"")
    return u"cc:" + oldVal + u" => " + newVal
Example #2
0
def formatReassignTransactionToText(fab, transaction):
    oldVal = transaction['oldValue']
    newVal = transaction['newValue']
    if oldVal != None:
        oldVal = UserInfo().getUsersRealName([oldVal])
    else:
        oldVal = u''
    if newVal != None:
        newVal = UserInfo().getUsersRealName([newVal])
    else:
        newVal = u''
    if type(oldVal) == list:
        oldVal = reduce(lambda x, y: x + ' ' + y, oldVal, u"")
    if type(newVal) == list:
        newVal = reduce(lambda x, y: x + ' ' + y, newVal, u"")
    return u"任务分配:" + oldVal + u" => " + newVal
Example #3
0
 def owner(self, tid):
     tif = self.info(tid)
     ui = UserInfo()
     ownerPHID = tif['ownerPHID']
     if None == ownerPHID:
         return u""
     ret = ui.getUsersRealName([ownerPHID])
     if len(ret) == 0:
         return u""
     return ret[0]
Example #4
0
 def saveUpdate(self, evt):
     judge = 1
     '''保存修改后的信息'''
     password = self.password.GetValue().strip()  # 获得修改后的值
     confirmpd = self.confirmpd.GetValue().strip()
     name = self.XingMing.GetValue().strip()
     certNo = self.certNo.GetValue().strip()
     gender = self.gender
     #
     birthday = self.birth.GetValue()
     birthday_time = self.datetime_to_str(str(birthday))
     #
     job = self.data_translate(self.job.GetValue(), 1)  # 职业
     graduschool = self.data_translate(self.school.GetValue(), 2)
     degree = self.data_translate(self.degreeType.GetValue(), 3)
     danwei = self.data_translate(self.danwei.GetValue(), 4)
     #
     zhicheng = self.zhicheng.GetValue()
     shoujihao = self.phone.GetValue().strip()
     qq = self.QQ.GetValue().strip()
     email = self.email.GetValue().strip()
     # 判断注册时输入的格式是否正确
     password_test = re.search(r"^[a-zA-Z0-9]{4,10}$", password)  # 密码
     true_name = re.search(r"^[\u4E00-\u9FA5]{2,4}$", name)  # 姓名
     shenfenzheng = re.search(
         r"^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$", certNo)  # 身份证号
     if name == "":
         warn = wx.MessageDialog(self,
                                 message="姓名不能为空!!!",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif true_name == None:
         # 消息对话框
         warn = wx.MessageDialog(self,
                                 message="真实姓名填写有误",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif certNo == "":
         warn = wx.MessageDialog(self,
                                 message="身份证号不能为空!!!",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif shenfenzheng == None:
         # 消息对话框
         warn = wx.MessageDialog(self,
                                 message="身份证输入不合法",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif password == "":
         # 消息对话框
         warn = wx.MessageDialog(self,
                                 message="登录密码不能为空!!!",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif password_test == None:
         # 消息对话框
         warn = wx.MessageDialog(self,
                                 message="密码不能含有非法字符,长度在4-10之间",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif confirmpd == "":
         # 消息对话框
         warn = wx.MessageDialog(self,
                                 message="确认密码不能为空!!!",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     elif password != confirmpd:
         # 消息对话框
         warn = wx.MessageDialog(self,
                                 message="两次密码不同,请重新输入",
                                 caption="温馨提示",
                                 style=wx.OK | wx.ICON_INFORMATION)
         warn.ShowModal()  # 提示错误
         warn.Destroy()
         judge = 0
     if shoujihao != '':
         phone = re.search(r"^1[3-9]\d{9}$", shoujihao)  # 验证手机号
         if phone == None:
             warn = wx.MessageDialog(self,
                                     message="手机号码不正确,请重新输入",
                                     caption="温馨提示",
                                     style=wx.OK | wx.ICON_INFORMATION)
             warn.ShowModal()  # 提示错误
             warn.Destroy()
             judge = 0
     if qq != '':
         QQ = re.search(r"^[1-9][0-9]{4,11}$", qq)  # 验证QQ号
         if QQ == None:
             warn = wx.MessageDialog(self,
                                     message="QQ号不正确,例如843278021",
                                     caption="温馨提示",
                                     style=wx.OK | wx.ICON_INFORMATION)
             warn.ShowModal()  # 提示错误
             warn.Destroy()
             judge = 0
     if email != '':
         email_test = re.search(r"^\w+@\w+(\.[a-zA-Z]{2,3}){1,2}$",
                                email)  # 验证邮箱
         if email_test == None:
             warn = wx.MessageDialog(self,
                                     message="Email格式不正确,例如[email protected]",
                                     caption="温馨提示",
                                     style=wx.OK | wx.ICON_INFORMATION)
             warn.ShowModal()  # 提示错误
             warn.Destroy()
             judge = 0
     if password != "" and name != "" and certNo != "" and judge == 1:
         print("开始将修改后的数据保存到数据库中")
         applicant = UserInfo('', password, name, certNo, gender,
                              birthday_time, job[0][0], graduschool[0][0],
                              degree[0][0], danwei[0][0], zhicheng,
                              shoujihao, qq, email)
         try:
             param_2 = (applicant.getpassword(),
                        applicant.getApplicantName(),
                        applicant.getApplicantID(), applicant.getgender(),
                        applicant.getbirthday(), applicant.getprofession(),
                        applicant.getgraduationschool(),
                        applicant.getdegree(), applicant.getdepartment(),
                        applicant.getzhicheng(),
                        applicant.getCellPhoneNumber(), applicant.getQQ(),
                        applicant.getzhicheng(), applicant.getemail(),
                        applicant.getApplicantID())
             sql_2 = "update user_info set Password=%s, TrueName=%s, IDCard=%s, Gender=%s, Birthday=%s, " \
                     "Job=%s,School=%s, Degree=%s, Unit=%s, Title=%s, Phone=%s , QQ=%s, Title=%s, Email=%s" \
                     " where IDCard=%s"
             self.dbhelper.UpdateData(sql_2, param_2)
             # 对话框
             warn = wx.MessageDialog(self,
                                     message="提交成功",
                                     caption="温馨提示",
                                     style=wx.OK | wx.ICON_INFORMATION)
             warn.ShowModal()  # 提示
             warn.Destroy()
         except Exception as e:
             print("查询记录失败:", e)
Example #5
0
                r4vByAuthors[author] = set()
            r4vByAuthors[author].add(tid)
    print status + ':'
    for a in r4vByAuthors:
        print a, len(r4vByAuthors[a])


searchCriterias = [{
    'desc':
    '5月31号以后所有任务',
    'args':
    dict(
        constraints={
            #"projects": ["儿童脑适能"],
            #"statuses":["open", "r4v"],
            "modifiedStart":
            int(
                datetime.strptime('2017-05-31 00:00',
                                  '%Y-%m-%d %H:%M').strftime("%s")),
        }),
}]
criteria = searchCriterias[0]
resp = fab.maniphest.search(**criteria['args']).data
resp = fab.maniphest.gettasktransactions(
    ids=map(lambda x: x['id'], resp)).response
users = getUsers(fab)
with CacheUsers(users):
    ui = UserInfo()
    reportStatus(resp, 'r4v', ui)
    reportStatus(resp, 'resolved', ui)
Example #6
0
def updateTask(fab, **args):
    # 获取 tid
    tid = args.pop('tid')
    if None == tid:
        return

    title = args.pop('task')
    description = args.pop('description', u"")
    priority = args.pop('priority', u"Needs Triage")
    status = args.pop('status', u"Open")
    owner = args.pop('assigned', u"")
    projectsStr = unicode(args.pop('tags', u""))
    deadline = args.pop('deadline').strip()
    kickoff = args.pop('kickoff')
    points = args.pop('points')

    projectNames = map(lambda x: x.strip(), projectsStr.split(','))

    if tid[0] == 'T':
        tid = int(tid[1:])
    else:
        tid = int(tid)
    tf = TaskInfoFactory()
    tif = tf.info(tid)
    if tif == None:
        print 'invalid task {tid}'.format(tid=tid)

    if deadline == 'TBD':
        deadline = ''

    pif = ProjectInfoFactory()
    projects = pif.projectsByName(projectNames)
    projectPHIDs = map(lambda x: x['phid'], projects)

    ui = UserInfo()
    ownerPhid = ui.getUserByRealName(owner)['phid']

    updateArgs = {}
    editArgs = {'objectIdentifier': tif['phid'], 'transactions': []}
    if title != tif['title']:
        updateArgs['title'] = title
    if description != tif['description']:
        updateArgs['description'] = description
    if ownerPhid != tif['ownerPHID']:
        updateArgs['ownerPHID'] = ownerPhid
    if priority != tif['priority']:
        updateArgs['priority'] = settings.PRIORITY_VALUES[priority]
    # 更新 project
    newProjects = set(projectPHIDs)
    oldProjects = set(tif['projectPHIDs'])
    # 整理要添加的project
    addingProjects = list(newProjects - oldProjects)
    # 整理要删除的project
    removingProjects = list(oldProjects - newProjects)
    if len(addingProjects) > 0:
        editArgs['transactions'].append({
            'type': 'projects.add',
            'value': addingProjects
        })
    if len(removingProjects) > 0:
        editArgs['transactions'].append({
            'type': 'projects.remove',
            'value': removingProjects
        })
        pass
    if len(removingProjects) > 0:
        pass
    if status != tif['statusName']:
        try:
            updateArgs['status'] = settings.STATUS_NAMES[status]
        except Exception, e:
            if status != tif['status']:
                updateArgs['status'] = status
            pass
Example #7
0
#!/usr/bin/python
# coding: utf8

from __future__ import unicode_literals
import cgi, cgitb
cgitb.enable()

import sys
import bddHeader
from user import UserInfo
import detectBingo
to_page = bddHeader.to_page

bdd = bddHeader.bdd()
cursor = bdd.getCursor()
user = UserInfo(cursor)

#Récupération et typage des paramètres
grid_name = cgi.FieldStorage().getvalue('name')
grid_x = cgi.FieldStorage().getvalue('x')
grid_y = cgi.FieldStorage().getvalue('y')
grid_set = cgi.FieldStorage().getvalue('set')
if not grid_name or not grid_x or not grid_y or not grid_set:
    to_page(
        "Content-type: text/html; charset=utf-8\n\nErreur : paramètres manquants"
    )
    sys.exit()
grid_name = grid_name.decode('utf8')
grid_x = int(grid_x)
grid_y = int(grid_y)
if grid_set != '1':
Example #8
0
    def savePatent(self, evt):
        judge = 1
        '''第一步:获取text中文本;第二步,连接数据库;第三步插入并获得主键;第四步添加到系统中'''
        password = self.password.GetValue().strip()
        confirmpd = self.confirmpd.GetValue().strip()
        name = self.XingMing.GetValue().strip()
        certNo = self.certNo.GetValue().strip()
        gender = self.gender
        #
        birthday = self.birth.GetValue()
        birthday_time = self.datetime_to_str(str(birthday))
        #
        job = self.data_translate(self.job.GetValue(), 1)  # 职业
        graduschool = self.data_translate(self.school.GetValue(), 2)  # 毕业学校
        degree = self.data_translate(self.degreeType.GetValue(), 3)  # 学历/学位
        danwei = self.data_translate(self.danwei.GetValue(), 4)  # 单位
        #
        zhicheng = self.zhicheng.GetValue().strip()
        shoujihao = self.phone.GetValue().strip()
        qq = self.QQ.GetValue().strip()
        email = self.Email.GetValue().strip()
        print('电子邮箱', email)
        #
        userState = self.data_translate(self.user_state, 5)
        userClass = self.data_translate(self.user_class, 6)
        # 判断注册时输入的格式是否正确
        true_name = re.search(r"^[\u4E00-\u9FA5]{2,4}$", name)  # 姓名
        password_test = re.search(r"^[a-zA-Z0-9]{4,10}$", password)  # 密码
        shenfenzheng = re.search(
            r"^(\d{6})(\d{4})(\d{2})(\d{2})(\d{3})([0-9]|X)$", certNo)  # 身份证号
        if name == "":
            warn = wx.MessageDialog(self,
                                    message="姓名不能为空!!!",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif true_name == None:
            # 消息对话框
            warn = wx.MessageDialog(self,
                                    message="真实姓名填写有误",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif certNo == "":
            warn = wx.MessageDialog(self,
                                    message="身份证号不能为空!!!",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif shenfenzheng == None:
            # 消息对话框
            warn = wx.MessageDialog(self,
                                    message="身份证输入不合法",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif password == "":
            # 消息对话框
            warn = wx.MessageDialog(self,
                                    message="登录密码不能为空!!!",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif password_test == None:
            # 消息对话框
            warn = wx.MessageDialog(self,
                                    message="密码不能含有非法字符,长度在4-10之间",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif confirmpd == "":
            # 消息对话框
            warn = wx.MessageDialog(self,
                                    message="确认密码不能为空!!!",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        elif password != confirmpd:
            # 消息对话框
            warn = wx.MessageDialog(self,
                                    message="两次密码不同,请重新输入",
                                    caption="温馨提示",
                                    style=wx.OK | wx.ICON_INFORMATION)
            warn.ShowModal()  # 提示错误
            warn.Destroy()
            judge = 0
        #
        if shoujihao != "":
            phone = re.search(r"^1[3-9]\d{9}$", shoujihao)  # 验证手机号
            if phone == None:
                warn = wx.MessageDialog(self,
                                        message="手机号码不正确,请重新输入",
                                        caption="温馨提示",
                                        style=wx.OK | wx.ICON_INFORMATION)
                warn.ShowModal()  # 提示错误
                warn.Destroy()
                judge = 0
        if qq != "":
            QQ = re.search(r"^[1-9][0-9]{4,11}$", qq)  # 验证QQ号
            if QQ == None:
                judge = 0
                warn = wx.MessageDialog(self,
                                        message="QQ号不正确,例如843278021",
                                        caption="温馨提示",
                                        style=wx.OK | wx.ICON_INFORMATION)
                warn.ShowModal()  # 提示错误
                warn.Destroy()
        if email != "":
            email_test = re.search(
                r"^[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?$",
                email)  # 验证邮箱
            if email_test == None:
                judge = 0
                warn = wx.MessageDialog(self,
                                        message="Email格式不正确,例如[email protected]",
                                        caption="温馨提示",
                                        style=wx.OK | wx.ICON_INFORMATION)
                warn.ShowModal()  # 提示错误
                warn.Destroy()

        if password != "" and name != "" and certNo != "" and judge == 1:
            print('进来了')
            # 对Applicant进行实例化
            user = UserInfo('', password, name, certNo, gender, birthday_time,
                            job[0][0], graduschool[0][0], degree[0][0],
                            danwei[0][0], zhicheng, shoujihao, qq, email)
            # 判断是否能找到相同身份证号
            try:
                param_1 = (certNo, )
                sql_1 = "select IDCard from user_info where IDCard=%s"
                i = self.dbhelper.SelectRecord(sql_1, param_1)
                print(i)
                if i != ():
                    print(i)
                    if i[0][0] == certNo:
                        warn = wx.MessageDialog(self,
                                                message="身份证号已存在,请重新输入",
                                                caption="温馨提示",
                                                style=wx.OK
                                                | wx.ICON_INFORMATION)
                        warn.ShowModal()  # 提示
                        warn.Destroy()
                else:
                    print("开始将用户注册信息插入到数据库中")
                    # 进行数据库的插入
                    try:
                        param_2 = (userClass[0][0], user.getpassword(),
                                   user.getApplicantName(),
                                   user.getApplicantID(), user.getgender(),
                                   user.getbirthday(), user.getprofession(),
                                   user.getgraduationschool(),
                                   user.getdegree(), user.getdepartment(),
                                   user.getzhicheng(),
                                   user.getCellPhoneNumber(), user.getQQ(),
                                   user.getemail(), userState[0][0])
                        sql_2 = "insert into user_info(UserCategory,Password,TrueName,IDCard, Gender, Birthday, Job, School,\
                                              Degree, Unit, Title, Phone, QQ, Email, UserStatus) \
                                        values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"

                        self.dbhelper.AddRecord(sql_2, param_2)
                        warn = wx.MessageDialog(self,
                                                message="注册成功",
                                                caption="温馨提示",
                                                style=wx.OK
                                                | wx.ICON_INFORMATION)
                        warn.ShowModal()  # 提示
                        warn.Destroy()
                        self.parent.notebook.DeleteAllPages()
                        self.parent._mgr.Update()
                        self.parent.register_state = 0
                    except Exception as e:
                        print("添加记录失败:", e)
            except Exception as e:
                print("查询记录失败:", e)
Example #9
0
# Imports #
###########

import csv
import sys
import os
from operator import itemgetter

sys.path.append("..")
from user import UserInfo

###########
# Globals #
###########

user_info = UserInfo()

# flag to determine whether the user passed in a teams csv
teams_csv_flag = 0

default = {
    "teams": "teams.csv",
    "orgs": "orgs.csv",
    "powerindices": "powerindices.csv",
    "rooms": "rooms.csv",
    "month": "feb",
    "indiv_room": "10^250"
}

passed_in = {
    "teams": None,