当前位置: 首页>>代码示例>>Python>>正文


Python conference.CategoryManager类代码示例

本文整理汇总了Python中MaKaC.conference.CategoryManager的典型用法代码示例。如果您正苦于以下问题:Python CategoryManager类的具体用法?Python CategoryManager怎么用?Python CategoryManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CategoryManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _process_DELETE

 def _process_DELETE(self):
     category = CategoryManager().getById(request.view_args['category_id'])
     if category in self.user.favorite_categories:
         self.user.favorite_categories.remove(category)
         if redis_write_client:
             suggestions.unsuggest(self.user, 'category', category.getId())
     return jsonify(success=True)
开发者ID:k3njiy,项目名称:indico,代码行数:7,代码来源:controllers.py

示例2: _getAnswer

    def _getAnswer(self):

        import MaKaC.common.indexes as indexes
        nameIdx = indexes.IndexesHolder().getIndex('conferenceTitle')

        query = ' '.join(map(lambda y: "*%s*" % y, self._searchString.split()))
        foundEntries = nameIdx.search(query)

        number = len(foundEntries)

        # get only the first 10 results
        foundEntries = foundEntries[:7]

        entryTitles = []

        for (confId, value) in foundEntries:
            conference = CategoryManager().getById(confId)
            entryTitles.append({
                'title': conference.getTitle(),
                'url': str(urlHandlers.UHConferenceDisplay.getURL(conference))
                })

        return {
            "list": entryTitles,
            "number": number
            }
开发者ID:Json-Andriopoulos,项目名称:indico,代码行数:26,代码来源:search.py

示例3: get_suggested_categories

def get_suggested_categories(user):
    """Gets the suggested categories of a user for the dashboard"""
    from MaKaC.conference import CategoryManager

    if not redis_write_client:
        return []
    related = user.favorite_categories | user.get_linked_objects('category', 'manager')
    res = []
    for id_, score in suggestions.get_suggestions(user, 'category').iteritems():
        try:
            categ = CategoryManager().getById(id_)
        except KeyError:
            suggestions.unsuggest(user, 'category', id_)
            continue
        if not categ or categ.isSuggestionsDisabled() or categ in related:
            continue
        if any(p.isSuggestionsDisabled() for p in categ.iterParents()):
            continue
        if not categ.canAccess(AccessWrapper(user.as_avatar)):
            continue
        res.append({
            'score': score,
            'categ': categ,
            'path': truncate_path(categ.getCategoryPathTitles()[:-1], chars=50)
        })
    return res
开发者ID:belokop,项目名称:indico_bare,代码行数:26,代码来源:util.py

示例4: main

def main():
    DBMgr.getInstance().startRequest()
    im = indexes.IndexesHolder()
    im.removeById("calendar")
    DBMgr.getInstance().commit()
    ch = CategoryManager()
    list = ch.getList()
    totnum = len(list)
    curnum = 0
    curper = 0
    for cat in list:
        committed = False
        DBMgr.getInstance().sync()
        calindex = im.getIndex("calendar")
        while not committed:
            try:
                del cat._calIdx
            except:
                pass
            for conf in cat.getConferenceList():
                calindex.indexConf(conf)
            try:
                DBMgr.getInstance().commit()
                committed = True
            except:
                DBMgr.getInstance().abort()
                print "retry %s" % cat.getId()
        curnum += 1
        per = int(float(curnum) / float(totnum) * 100)
        if per != curper:
            curper = per
            if per in [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]:
                print "done %s%%" % per
    DBMgr.getInstance().endRequest()
开发者ID:k3njiy,项目名称:indico,代码行数:34,代码来源:reindexcalendars.py

示例5: _checkParams

    def _checkParams(self, params):

        base.RHProtected._checkParams(self, params)
        self._statusValue = "OK"
        self._message = ""
        try:
            self._title = params.get( "title", "" ).strip()
            self._startdate = params.get( "startdate", "" ).strip()
            self._enddate = params.get( "enddate", "" ).strip()
            self._place = params.get( "place", "" ).strip()
            self._room = params.get( "room", "" ).strip()
            self._accessPassword = params.get( "an", "" ).strip()
            self._modifyPassword = params.get( "mp", "" ).strip()
            self._style = params.get( "style", "" ).strip()
            self._fid = params.get( "fid", "" ).strip()
            self._description = params.get( "description", "" ).strip()
            self._stime = params.get( "stime", "" ).strip()
            self._etime = params.get( "etime", "" ).strip()
            self._speaker = params.get( "speaker", "" ).strip()
            self._speakeremail = params.get( "email", "" ).strip()
            self._speakeraffiliation = params.get( "affiliation", "" ).strip()
            if not self._title or not self._startdate or not self._enddate or not self._fid or not self._stime or not self._etime:
                raise MaKaCError( _("mandatory parameter missing"))
            ch = CategoryManager()
            try:
                self._cat = ch.getById(self._fid)
            except:
                raise MaKaCError( _("unknown category"))
        except MaKaCError, e:
          self._statusValue = "ERROR"
          self._message = e.getMsg()
开发者ID:lukasnellen,项目名称:indico,代码行数:31,代码来源:xmlGateway.py

示例6: main

def main():
    """This script deletes existing category indexes and recreates them."""
    db.DBMgr.getInstance().startRequest()
    im = indexes.IndexesHolder()
    im.removeById('category')
    catIdx = im.getIndex('category')
    ch = CategoryManager()
    totnum = len(ch.getList())
    curnum = 0
    curper = 0
    for cat in ch.getList():
        while 1:
            try:
                for conf in cat.getConferenceList():
                    catIdx.indexConf(conf)
                transaction.commit()
                break
            except:
                db.DBMgr.getInstance().sync()
        curnum += 1
        per = int(float(curnum)/float(totnum)*100)
        if per != curper:
            curper = per
            print "%s%%" % per
    db.DBMgr.getInstance().endRequest()
开发者ID:bubbas,项目名称:indico,代码行数:25,代码来源:reindexcategories.py

示例7: main

def main():
    """
    This script deletes existing category indexes and recreates them.
    """

    dbi = DBMgr.getInstance()
    dbi.startRequest()

    im = indexes.IndexesHolder()
    im.removeById('categoryDate')
    catIdx = im.getIndex('categoryDate')

    cm = CategoryManager()
    num_categs = len(cm._getIdx())
    cur_num = cur_percent = 0

    for cat in cm._getIdx().itervalues():
        for conf in cat.conferences.itervalues():
            catIdx.indexConf(conf)
        dbi.commit()

        cur_num += 1
        percent = int(float(cur_num) / num_categs * 100)
        if percent != cur_percent:
            cur_percent = percent
            print "{0}%".format(percent)
    dbi.endRequest()
开发者ID:NIIF,项目名称:indico,代码行数:27,代码来源:reindexcategorydateindex.py

示例8: _getAnswer

    def _getAnswer(self):

        import MaKaC.common.indexes as indexes
        nameIdx = indexes.IndexesHolder().getIndex('categoryName')

        try:
            query = ' AND '.join(map(lambda y: "*%s*" % y, filter(lambda x: len(x) > 0, self._searchString.split(' '))))
            foundEntries = nameIdx.search(query)
        except parsetree.ParseError:
            foundEntries = []

        number = len(foundEntries)

        # get only the first 10 results
        foundEntries = foundEntries[:7]

        entryNames = []

        for (categId, value) in foundEntries:
            categ = CategoryManager().getById(categId)
            entryNames.append({
                'title': categ.getTitle(),
                'path': self._getPath(categ),
                'url': str(urlHandlers.UHCategoryDisplay.getURL(categ))
                })

        return {
            "list": entryNames,
            "number": number
            }
开发者ID:aninhalacerda,项目名称:indico,代码行数:30,代码来源:search.py

示例9: main

def main(argv):
    category = -1
    meeting = -1
    show = 0

    try:
        opts, args = getopt.getopt(argv, "hm:c:s", ["help", "meeting=", "category=", "show"])
    except getopt.GetoptError:
        usage()
        sys.exit(2)
    for opt, arg in opts:
        if opt in ("-h", "--help"):
            usage()
            sys.exit()
        elif opt in ("-s", "--show"):
            show = 1
        elif opt in ("-m", "--meeting"):
            meeting = arg
        elif opt in ("-c", "--category"):
            category = arg

    # Create database instance and open trashcan manager object
    DBMgr.getInstance().startRequest()
    t = TrashCanManager()
    conf = None
    if show:
        for i in t.getList():
            if isinstance(i, Conference):
                if meeting != -1 and i.getId() == meeting:
                    print "[%s]%s" % (i.getId(), i.getTitle())
                elif meeting == -1:
                    print "[%s]%s" % (i.getId(), i.getTitle())
        sys.exit()
    if meeting != -1 and category != -1:
        print "Meeting:%s" % meeting
        print "Category:%s" % category
        for i in t.getList():
            if isinstance(i, Conference):
                if i.getId() == meeting:
                    conf = i
                    break

        if conf:
            # Remove the meeting from conference
            t.remove(conf)
            # Attach meeting to desired category
            cat = CategoryManager().getById(category)
            ConferenceHolder().add(conf)
            cat._addConference(conf)

            # Add Evaluation
            c = ConferenceHolder().getById(meeting)
            from MaKaC.evaluation import Evaluation

            c.setEvaluations([Evaluation(c)])

            DBMgr.getInstance().endRequest()
开发者ID:lukasnellen,项目名称:indico,代码行数:57,代码来源:restore_meeting.py

示例10: _checkParams

 def _checkParams(self):
     if 'confId' in request.view_args:
         self.obj = self._conf = ConferenceHolder().getById(request.view_args['confId'])
         self.obj_type = 'event'
     elif 'categId' in request.view_args:
         self.obj = CategoryManager().getById(request.view_args['categId'])
         self.obj_type = 'category' if not self.obj.isRoot() else None
     else:
         self.obj = CategoryManager().getRoot()
         self.obj_type = None
开发者ID:florv,项目名称:indico-plugins,代码行数:10,代码来源:controllers.py

示例11: _process_PUT

 def _process_PUT(self):
     category = CategoryManager().getById(request.view_args['category_id'])
     if category not in self.user.favorite_categories:
         if not category.canAccess(AccessWrapper(self.user.as_avatar)):
             raise Forbidden()
         self.user.favorite_categories.add(category)
         if redis_write_client:
             suggestions.unignore(self.user, 'category', category.getId())
             suggestions.unsuggest(self.user, 'category', category.getId())
     return jsonify(success=True)
开发者ID:k3njiy,项目名称:indico,代码行数:10,代码来源:controllers.py

示例12: call

 def call(self):
     categ1 = CategoryManager().getById('1') #target category here
     for i in xrange(1, 0 + 1): #number of conferences to create here
         c = categ1.newConference(AvatarHolder().getById('1')) #creator of event
         c.setTitle("event " + str(i))
         c.setTimezone('UTC')
         c.setDates(nowutc() - timedelta(hours = i), nowutc() - timedelta(hours = i - 1))
         for j in xrange(1, 0+1): #number of bookings per event
             Catalog.getIdx("cs_bookingmanager_conference").get(c.getId()).createBooking("Vidyo", {"roomName":"room_"+str(i)+"_"+str(j),
                                                             "roomDescription": "test",
                                                             "owner":{"_type": "Avatar", "id":"1"}})
开发者ID:Ictp,项目名称:indico,代码行数:11,代码来源:actions.py

示例13: main

def main():
    """This script deletes existing category indexes and recreates them."""
    db.DBMgr.getInstance().startRequest()
    ch = CategoryManager()
    for cat in ch.getList():
      for conf in cat.getConferenceList():
        chconf(conf)
      get_transaction().commit()
    # Tasks
    htl = timerExec.HelperTaskList.getTaskListInstance()
    for task in htl.getTasks():
        chtask(task)
    db.DBMgr.getInstance().endRequest()
开发者ID:davidmorrison,项目名称:indico,代码行数:13,代码来源:chdatetime.py

示例14: get_excluded_categories

def get_excluded_categories():
    """Get all excluded category IDs"""
    from indico_livesync.plugin import LiveSyncPlugin
    todo = {x['id'] for x in LiveSyncPlugin.settings.get('excluded_categories')}
    excluded = set()
    while todo:
        category_id = todo.pop()
        try:
            category = CategoryManager().getById(category_id)
        except KeyError:
            continue
        excluded.add(category.getId())
        todo.update(category.subcategories)
    return excluded
开发者ID:florv,项目名称:indico-plugins,代码行数:14,代码来源:util.py

示例15: _process

    def _process(self):
        matches = IndexesHolder().getIndex('categoryName').search(request.args['term'])
        results = []
        for category_id in matches[:7]:
            try:
                categ = CategoryManager().getById(category_id)
            except KeyError:
                continue
            results.append({
                'title': to_unicode(categ.getTitle()),
                'path': map(to_unicode, categ.getCategoryPathTitles()[1:-1]),
                'url': unicode(UHCategoryDisplay.getURL(categ))
            })

        return jsonify(success=True, results=results, count=len(matches))
开发者ID:florv,项目名称:indico-plugins,代码行数:15,代码来源:controllers.py


注:本文中的MaKaC.conference.CategoryManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。