def ProjectUpdate(self,dic): if isinstance(dic,dict): user = User(dic['belongu']) dic['belongu'] = user.GetUser() id = dic['id'] del dic['id'] project.objects.filter(id=id).update(**dic)
def ProjectSave(self,dic): if isinstance(dic,dict): #handle the user user = User(dic['belongu']) dic['belongu'] = user.GetUser() rs = project(**dic) id = rs.save()
def InitUserPowerLink(self): gp = Group() power = Permission() user = User(self.__uid) if (user.GetUserPermission().count() == 0 or user.GetUserGroup().count() == 0 ) and self.__uid: link_dict = { 'group':[gp.GetId(u'超级管理员')], 'ownpe':power.GetAllId() } user.UserGroupUpdate(link_dict)
def ProjectAdd(request): ret = public(request, 'app-pro', '应用', '新增') if request.method == 'POST': form_key = ['name', 'belongu', 'devu', 'examu', 'remark'] form_value = GetFormPost(request, form_key) app = Application() app.ProjectSave(form_value) return redirect('/application/app/list/') else: users = User() ret['users'] = users.GetUserList() return render_to_response('application/project_add.html', ret)
def ProjectEdit(request, projectid): ret = public(request, 'app-pro', '应用', '编辑') if request.method == 'POST': form_key = ['name', 'belongu', 'devu', 'examu', 'remark'] form_value = GetFormPost(request, form_key) form_value['id'] = projectid app = Application() app.ProjectUpdate(form_value) return redirect('/application/app/list/') else: users = User() ret['users'] = users.GetUserList() ret['project'] = project.objects.get(id=projectid) return render_to_response('application/project_edit.html', ret)
def InitCreateUser(self): ''' @生成默认用户及密码 ''' users = User() depart = Department() webconfig = websetting() if users.UserNum() == 0: form_value = {'name':u'mianbao', 'password':u'mianbao.cn.com', 'password2':u'mianbao.cn.com', 'tel':u'18888888888', 'department':u'%s' % depart.GetId(u'运维部')} form_value['register_time'] = time.time() form_value['last_login'] = time.time() form_value['mail'] = str(form_value['name']) + str(webconfig.GetMailAdd()) form_value['active'] = u'0' #the mail no active self.__uid = users.Add(form_value) users.ActiveMianbao()
def _DicHandle(self,dic): #handle the user if dic.has_key('belongu'): user = User(dic['belongu']) dic['belongu'] = user.GetUser() #handle the env dic['toenv'] = env.objects.get(id=dic['toenv']) #handle the department dic['department'] = department.objects.get(id=dic['department']) #handle the where dic['towhere'] = where.objects.get(id=dic['towhere']) #handle the room dic['toroom'] = room.objects.get(id=dic['toroom']) return dic
def Regect0(reject, form_value, uid): save_reject_rs = order_remark(**form_value).save() users = User(uid) new = dict() new['order'] = reject new['key'] = 'reject' new['rs'] = 0 new['remark'] = save_reject_rs new['uid'] = users.GetUser() new['time'] = time.time() order_flow(**new).save() reject.status = 200 reject.save() mail_object = u"【通知】虚拟申请被驳回" html_dict = { 'title': u'驳回通知', 'content': u'驳回原因:%s <br><br><br><br>**订单详情: %s(单号) %s **<br>' % (form_value.get('remark', None), reject.id, reject.project) } rs = sendmail([reject.uid.mail], mail_object, html_dict) return True