Пример #1
0
def addUpdateLog(request,name,objectId,comment,olddict,newdict,category,status):
    try:
        changedata = getChangeInfo(olddict,newdict)
        sys_comment = '<p class=currdata>%s</p><p class=olddata>%s</p>'%(changedata['new'],changedata['old']) 
        user = request.META.get('ADFS_FULLNAME','')     
        log = ChangeLog(category=category,object_id=objectId,name=name,operation='update',comment=comment,sys_comment=sys_comment,user=user,status=status)
        log.save()
        return True
    except Exception :
        print traceback.format_exc()
        return False
Пример #2
0
def addLog(request,name,comment,oldCategObj,newCategObj,category,operation,status):
    try:        
        object_id = oldCategObj.id
        if category =='group':
            if operation == 'add':
                sys_comment = "<p class=currdata>Added Group '%s'</p>"%oldCategObj.name
            elif operation == 'delete':
                sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getGroupInfo(oldCategObj))
        elif category == 'resourcetype':
            if operation == 'add':
                sys_comment = "<p class=currdata>Added ResourceType '%s'</p>" %oldCategObj.name
            elif operation == 'delete':
                sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getResourceTypeInfo(oldCategObj))
        elif category =='region':
            if operation == 'add':
                sys_comment = "<p class=currdata>Added Region '%s'</p>"%oldCategObj.name
            elif operation == 'delete':
                sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getRegionInfo(oldCategObj))
        elif category =='zone':
            if operation == 'add':
                sys_comment = "<p class=currdata>Added Zone '%s'</p>"%oldCategObj.name
            elif operation == 'delete':
                sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getZoneInfo(oldCategObj))
        elif category =='project':
            if operation == 'add':
                sys_comment = "<p class=currdata>Added Project '%s'</p>" %oldCategObj.name
            elif operation == 'delete':
                sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getProjectInfo(oldCategObj))
        elif category =='topallocation':
            if operation == 'add':
                sys_comment = "<p class=currdata>Added TopLevelAllocation '%s'</p>" %oldCategObj.name
            elif operation == 'delete':
                sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getTopAllocationInfo(oldCategObj))
        elif category =='projectallocation':
            if operation == 'add':
                sys_comment = "<p class=currdata>Added ProjectAllocation '%s'</p>" %oldCategObj.name
            elif operation == 'delete':
                sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getProjectAllocationInfo(oldCategObj))
        elif category =='groupallocation':
            if operation == 'add':
                sys_comment = "<p class=currdata>Added GroupAllocation '%s'</p>" %oldCategObj.name
            elif operation == 'delete':
                sys_comment = '<p class=olddata>%s</p>'%formatObjectInfo(getGroupAllocationInfo(oldCategObj))

        user = request.META.get('ADFS_FULLNAME','')     
        log = ChangeLog(category=category,object_id=object_id,name=name,operation=operation,comment=comment,sys_comment=sys_comment,user=user,status=status)
        log.save()
        return True
    except Exception :
        print traceback.format_exc()
        return False
Пример #3
0
  def get(self, id, board_no, ns_pair, ew_pair):
    ''' Returns the complete change log for a hand to tournament owners.
    ''' 
    tourney = GetTourneyWithIdAndMaybeReturnStatus(self.response, id)
    if not tourney:
      return

    if not CheckUserOwnsTournamentAndMaybeReturnStatus(self.response, 
        users.get_current_user(), tourney):
      return

    if not CheckValidHandPlayersCombinationAndMaybeSetStatus(
        self.response, tourney, board_no, ns_pair, ew_pair):
      return

    change_logs = ChangeLog._query(
        ancestor=HandScore.CreateKey(tourney, board_no, ns_pair, ew_pair)).order(
            -ChangeLog.key).fetch()

    change_dict = { 'changes' : [] }
    for cl in change_logs:
      change_dict['changes'].append(cl.to_dict())

    self.response.headers['Content-Type'] = 'application/json'
    self.response.set_status(200)
    self.response.out.write(json.dumps(change_dict, indent=2))
Пример #4
0
def addEgroupLog(request,egroup,category,operation,comment,status):
    try:
        if category =='egroup':
            if operation == 'update':
                sys_comment = "<p class=currdata>'%s'</p>"%comment
            elif operation == 'deleteCERN':
                sys_comment = '<p class=olddata>Egroup %s Deleted in CERN Egroup</p>'%egroup
            elif operation =='deleteCLOUDMAN':
                sys_comment = '<p class=olddata>Egroup %s Deleted in CLOUDMAN</p>'%egroup
            elif operation == 'emptyEgroup':
                sys_comment = "<p class=currdata>'%s'</p>"%comment
        user='******'
        if request :
            user = request.META.get('ADFS_FULLNAME','')
        log = ChangeLog(category=category,object_id=1,user=user,name=egroup,operation=operation,comment=comment,sys_comment=sys_comment,status=status)
        log.save()
        return True
    except Exception:
        print traceback.format_exc()
        return False
Пример #5
0
    def get(self, name):
        name = name.lower()
        rules = RuleList.getList(name)
        if rules is None:
            self.error(404)
            return

        # Conditional redirect to FeedBurner
        # @see: http://www.google.com/support/feedburner/bin/answer.py?hl=en&answer=78464
        if (self.request.get('raw', None) is None
                and  # http://host/path/name.rss?raw
                'FeedBurner'
                not in self.request.user_agent):  # FeedBurner fetcher
            self.redirect('http://feeds.feedburner.com/%s' % name,
                          permanent=False)
            return

        self.lastModified(rules.date)

        start = int(self.request.get('start', 0))
        fetchNum = start + int(self.request.get('num', 20))
        if fetchNum > 1000:
            self.error(412)
            return

        logs = memcache.get('changelog/%s' % name)
        if logs is None or len(logs) < fetchNum:
            diff = ChangeLog.gql("WHERE ruleList = :1 ORDER BY date DESC",
                                 rules).fetch(fetchNum)
            logs = map(generateLogFromDiff, diff)
            memcache.add('changelog/%s' % name, logs)

        self.response.headers['Content-Type'] = Feed.mime_type

        f = Feed(title="%s 更新记录" % name,
                 link=self.request.relative_url(name),
                 description="beta",
                 language="zh")

        for item in logs:
            f.add_item(title="%d月%d日 %s 更新: 增加 %d 条, 删除 %d 条" %
                       (item['timestamp'].month, item['timestamp'].day, name,
                        len(item['block']), len(item['unblock'])),
                       link='',
                       description=template.render('changelogRssItem.html',
                                                   **item),
                       author_name="gfwlist",
                       pubdate=item['timestamp'])

        f.write(self.response.out, 'utf-8')
Пример #6
0
    def get(self, name):
        name = name.lower()
        rules = RuleList.getList(name)
        if rules is None:
            self.error(404)
            return

        # Conditional redirect to FeedBurner
        # @see: http://www.google.com/support/feedburner/bin/answer.py?hl=en&answer=78464
        if(self.request.get('raw', None) is None and        # http://host/path/name.rss?raw
           'FeedBurner' not in self.request.user_agent):    # FeedBurner fetcher
            self.redirect('http://feeds.feedburner.com/%s' % name, permanent=False)
            return

        self.lastModified(rules.date)

        start = int(self.request.get('start', 0))
        fetchNum = start + int(self.request.get('num', 20))
        if fetchNum > 1000:
            self.error(412)
            return

        logs = memcache.get('changelog/%s' % name)
        if logs is None or len(logs) < fetchNum:
            diff = ChangeLog.gql("WHERE ruleList = :1 ORDER BY date DESC", rules).fetch(fetchNum)
            logs = map(generateLogFromDiff, diff)
            memcache.add('changelog/%s' % name, logs)

        self.response.headers['Content-Type'] = Feed.mime_type

        f = Feed(title="%s 更新记录" % name,
                 link=self.request.relative_url(name),
                 description="beta",
                 language="zh")

        for item in logs:
            f.add_item(title="%d月%d日 %s 更新: 增加 %d 条, 删除 %d 条" % (item['timestamp'].month, item['timestamp'].day, name, len(item['block']), len(item['unblock'])),
                       link='',
                       description=template.render('changelogRssItem.html', **item),
                       author_name="gfwlist",
                       pubdate=item['timestamp'])

        f.write(self.response.out, 'utf-8')