def work(): if len(sys.argv) != 3: sys.exit(1) name = sys.argv[1] rev = sys.argv[2] print svn.ADMIN_REPOS(name) o = svn.LOG(svn.ADMIN_REPOS(name), rev) msg = o.log.logentry.msg author = getattr(o.log.logentry, 'author', None) if author is None: print 'author is None', author return u = q_get(User, name=str(author)) if u is None: print 'user not exist!', author return prj = q_get(Project, name=name) if prj is None: print 'prj is None', name return activity.new_commit(prj, u, rev, str(msg))
def work(): if len(sys.argv) != 3: sys.exit(1) name = sys.argv[1] rev = sys.argv[2] print svn.ADMIN_REPOS(name) o = svn.LOG(svn.ADMIN_REPOS(name), rev) msg = o.log.logentry.msg author = getattr(o.log.logentry, 'author', None) if author is None: print 'author is None',author return u = q_get(User, name = str(author)) if u is None: print 'user not exist!',author return prj = q_get(Project, name = name) if prj is None: print 'prj is None',name return activity.new_commit(prj, u, rev, str(msg))
def format_activity(act): cmd, m = act.act_type.split('_') act.cmd = cmd act.act_text = ACT_TEXTS.get(act.act_type, act.act_type) if m == 'issue': act.issue = q_get(Issue, pk=int(act.content)) elif m == 'comment' and cmd != 'del': act.comment = q_get(IssueComment, pk=int(act.content)) elif m == 'commit': #print "commit",act.content rev, msg = act.content.split(' ', 1) act.commit = {'rev': rev, 'msg': msg} return act
def format_activity(act): cmd, m = act.act_type.split('_') act.cmd = cmd act.act_text = ACT_TEXTS.get(act.act_type, act.act_type) if m == 'issue': act.issue = q_get(Issue, pk=int(act.content)) elif m == 'comment' and cmd != 'del': act.comment = q_get(IssueComment, pk=int(act.content)) elif m == 'commit': rev, msg = act.content.split(' ', 1) act.commit = {'rev':rev, 'msg':msg} return act
def img_resolver(self, target): if self.wiki is None: return target vals = target.split(':', 2) files = [] if len(vals) == 1 and self.wiki is not None: files = q_gets(ProjectAttachment, project=self.prj, ftid=self.wiki.id, ftype='wiki', orig_name=target, status=consts.FILE_ENABLE) elif len(vals) == 2: return target elif len(vals) == 3: if vals[0].lower() != 'wiki': return target wiki = q_get(WikiContent, project=self.prj, path=vals[1]) if wiki is not None: files = q_gets(ProjectAttachment, project=self.prj, ftid=wiki.id, ftype='wiki', orig_name=vals[2], status=consts.FILE_ENABLE) if len(files) > 0: f = files[0] return '%sfile/%s/%s' % (f.project.url(), f.id, f.orig_name) return target
def img_resolver(self, target): if self.wiki is None: return target vals = target.split(':',2) files = [] if len(vals) == 1 and self.wiki is not None: files = q_gets(ProjectAttachment,project = self.prj, ftid = self.wiki.id, ftype = 'wiki', orig_name = target, status = consts.FILE_ENABLE) elif len(vals) == 2: return target elif len(vals) == 3: if vals[0].lower() != 'wiki': return target wiki = q_get(WikiContent, project = self.prj, path = vals[1]) if wiki is not None: files = q_gets(ProjectAttachment,project = self.prj, ftid = wiki.id, ftype = 'wiki', orig_name = vals[2], status = consts.FILE_ENABLE) if len(files) > 0: f = files[0] return '%sfile/%s/%s'%(f.project.url(), f.id, f.orig_name) return target
def clean_email(self): email = self.cleaned_data["email"] self.cache_user = q_get(User, email__iexact=email, status=consts.USER_ENABLE) if self.cache_user is None: raise forms.ValidationError(gettext("That e-mail address doesn't have an associated user account. Are you sure you've registered?")) return email
def put(project, name, val): v = q_get(ProjectProfile, project = project , name__iexact = name) if v is None: v = ProjectProfile(project = project, name = name) v.value = marshal.dumps(val) v.save()
def open_user_login(request, openId, platform, ip, pic=None, password=None): user = q_get(User, openId=openId, openPlatform=platform) if user is not None: user.last_login_ip = ip user.last_login = datetime.now() user.save() if password is not None: auser = authenticate(username=user.name, password=password) else: auser = user auser.backend = "%s.%s" % ("apps.user.auth", "UserAuthBackend") auth_login(request, auser) return True else: return False
def open_user_login(request,openId,platform,ip,pic=None,password=None): user=q_get(User,openId=openId,openPlatform=platform) if user is not None: user.last_login_ip=ip user.last_login=datetime.now() user.save() if password is not None: auser = authenticate(username=user.name,password=password) else: auser = user auser.backend = "%s.%s" % ("apps.user.auth","UserAuthBackend") auth_login(request, auser) return True else: return False
def link_resolver(self, ns, target): if ns != 'wiki': return None v = target.split(' ', 1) if len(v) == 2: target = v[0] wiki = q_get(WikiContent, project=self.prj, path=target) if wiki is not None: return True, wiki.url() return False, reverse('apps.wiki.views.wiki_content', args=[self.prj.name, target])
def link_resolver(self, ns, target): if ns != 'wiki': return None v = target.split(' ', 1) if len(v) == 2: target = v[0] wiki = q_get(WikiContent, project = self.prj, path = target) if wiki is not None: return True, wiki.url() return False, reverse('apps.wiki.views.wiki_content', args=[self.prj.name, target])
def open_new_user_checkin(openId,username,email,platform,ip=None,pic=None,password=None): user=q_get(User, Q(name__iexact=username) | Q(email__iexact=email)) if user is not None: return user user=User(name=username,email=email) user.openId=openId user.openPlatform=platform user.last_login_ip=ip user.last_login=datetime.now() user.set_password(password) user.status=consts.USER_ENABLE user.sex=consts.USER_UNKNOWN user.save() return True
def open_new_user_checkin(openId, username, email, platform, ip=None, pic=None, password=None): user = q_get(User, Q(name__iexact=username) | Q(email__iexact=email)) if user is not None: return user user = User(name=username, email=email) user.openId = openId user.openPlatform = platform user.last_login_ip = ip user.last_login = datetime.now() user.set_password(password) user.status = consts.USER_ENABLE user.sex = consts.USER_UNKNOWN user.save() return True
def get(project, name, default = None): v = q_get(ProjectProfile, project = project, name__iexact = name) if v is None: return default return marshal.loads(v.value)