Ejemplo n.º 1
0
    def create_latest_additions_info(self, rg=CFG_WEBSEARCH_INSTANT_BROWSE, ln=CFG_SITE_LANG):
        """
        Create info about latest additions that will be used for
        create_instant_browse() later.
        """
        self.latest_additions_info = []
        if self.nbrecs and self.reclist:
            # firstly, get last 'rg' records:
            recIDs = list(self.reclist)
            of = 'hb'
            # CERN hack begins: tweak latest additions for selected collections:
            if CFG_CERN_SITE:
                # alter recIDs list for some CERN collections:
                this_year = time.strftime("%Y", time.localtime())
                if self.name in ['CERN Yellow Reports','Videos']:
                    last_year = str(int(this_year) - 1)
                    # detect recIDs only from this and past year:
                    recIDs = list(self.reclist & \
                                  search_pattern_parenthesised(p='year:%s or year:%s' % \
                                                 (this_year, last_year)))
                elif self.name in ['VideosXXX']:
                    # detect recIDs only from this year:
                    recIDs = list(self.reclist & \
                                  search_pattern_parenthesised(p='year:%s' % this_year))
                elif self.name == 'CMS Physics Analysis Summaries' and \
                         1281585 in self.reclist:
                    # REALLY, REALLY temporary hack
                    recIDs = list(self.reclist)
                    recIDs.remove(1281585)
                # apply special filters:
                if self.name in ['Videos']:
                    # select only videos with movies:
                    recIDs = list(intbitset(recIDs) & \
                                  search_pattern_parenthesised(p='collection:"PUBLVIDEOMOVIE"'))
                    of = 'hvp'
                # sort some CERN collections specially:
                if self.name in ['Videos',
                                 'Video Clips',
                                 'Video Movies',
                                 'Video News',
                                 'Video Rushes',
                                 'Webcast',
                                 'ATLAS Videos',
                                 'Restricted Video Movies',
                                 'Restricted Video Rushes',
                                 'LHC First Beam Videos',
                                 'CERN openlab Videos']:
                    recIDs = sort_records(None, recIDs, '269__c')
            # CERN hack ends.

            total = len(recIDs)
            to_display = min(rg, total)

            for idx in range(total-1, total-to_display-1, -1):
                recid = recIDs[idx]
                self.latest_additions_info.append({'id': recid,
                                                   'format': format_record(recid, of, ln=ln),
                                                   'date': get_creation_date(recid, fmt="%Y-%m-%d<br />%H:%i")})
        return
Ejemplo n.º 2
0
    def calculate_reclist(self):
        """Calculate, set and return the (reclist, reclist_with_nonpublic_subcolls) tuple for given collection."""
        if self.calculate_reclist_run_already or str(self.dbquery).startswith("hostedcollection:"):
            # do we have to recalculate?
            return (self.reclist, self.reclist_with_nonpublic_subcolls)
        write_message("... calculating reclist of %s" % self.name, verbose=6)
        reclist = intbitset() # will hold results for public sons only; good for storing into DB
        reclist_with_nonpublic_subcolls = intbitset() # will hold results for both public and nonpublic sons; good for deducing total
                                                   # number of documents
        if not self.dbquery:
            # A - collection does not have dbquery, so query recursively all its sons
            #     that are either non-restricted or that have the same restriction rules
            for coll in self.get_sons():
                coll_reclist, coll_reclist_with_nonpublic_subcolls = coll.calculate_reclist()
                if ((coll.restricted_p() is None) or
                    (coll.restricted_p() == self.restricted_p())):
                    # add this reclist ``for real'' only if it is public
                    reclist.union_update(coll_reclist)
                reclist_with_nonpublic_subcolls.union_update(coll_reclist_with_nonpublic_subcolls)
        elif self.dbquery and self.get_sons():
            # A - collection does not have dbquery, so query recursively all its sons
            #     that are either non-restricted or that have the same restriction rules
            for coll in self.get_sons():
                coll_reclist, coll_reclist_with_nonpublic_subcolls = coll.calculate_reclist()
                if ((coll.restricted_p() is None) or
                    (coll.restricted_p() == self.restricted_p())):
                    # add this reclist ``for real'' only if it is publicf
                    reclist.union_update(coll_reclist)
                reclist_with_nonpublic_subcolls.union_update(coll_reclist_with_nonpublic_subcolls)

            # B - collection does have dbquery, so compute it:
            #     (note: explicitly remove DELETED records)
            reclist_self = None
            if CFG_CERN_SITE:
                reclist_self = search_pattern_parenthesised(None, self.dbquery + \
                                         ' -980__:"DELETED" -980__:"DUMMY"')
            else:
                reclist_self = search_pattern_parenthesised(None, self.dbquery + ' -980__:"DELETED"')
            reclist.union_update(reclist_self)
            self_reclist_with_nonpublic_subcolls = copy.deepcopy(reclist_self)
            reclist_with_nonpublic_subcolls.union_update(self_reclist_with_nonpublic_subcolls)
        else:
            # B - collection does have dbquery, so compute it:
            #     (note: explicitly remove DELETED records)
            if CFG_CERN_SITE:
                reclist = search_pattern_parenthesised(None, self.dbquery + \
                                         ' -980__:"DELETED" -980__:"DUMMY"')
            else:
                reclist = search_pattern_parenthesised(None, self.dbquery + ' -980__:"DELETED"')
            reclist_with_nonpublic_subcolls = copy.deepcopy(reclist)
        # store the results:
        self.nbrecs = len(reclist_with_nonpublic_subcolls)
        self.reclist = reclist
        self.reclist_with_nonpublic_subcolls = reclist_with_nonpublic_subcolls
        # last but not least, update the speed-up flag:
        self.calculate_reclist_run_already = 1
        # return the two sets:
        return (self.reclist, self.reclist_with_nonpublic_subcolls)
Ejemplo n.º 3
0
 def zenodo_curated(reclist, length=10, reverse=True, open_only=False):
     """
     Show only curated publications from reclist
     """
     if open_only:
         p = "(980__a:curated OR 980__a:user-zenodo) AND (542__l:open OR 542__l:embargoed)"
     else:
         p = "980__a:curated OR 980__a:user-zenodo"
     reclist = (reclist & search_pattern_parenthesised(p=p))
     if reverse:
         reclist = reclist[-length:]
         return reversed(reclist)
     else:
         return reclist[:length]
    def tmpl_user_list(self, ln=CFG_SITE_LANG): #TP: cele..
        """
        Generates a list of available collections statistics.
        """
        assignedUsers = list()
        out = ""

        #TP: nakreslim oddil pro kazdeho strukturatora
        for supervisor in cfg_supervisors_groups:
          out += """<h3>Supervisor %s (#%s)</h3><ul class="supervisor_usersOverview">""" % (get_email(supervisor),supervisor)
          assignedUsers.append(supervisor)

          #TP: nakreslim linky a hlavni info pro kazdeho uzivatele
          for user in cfg_supervisors_groups[int(supervisor)]:
            assignedUsers.append(user)
#            &timespan=last+month&s_date=01%2F29%2F2013+00%3A00&f_date=01%2F29%2F2013+09%3A28&format=flot&ids=cardStructured&cols0=UID&col_value0=tomas&action_gen=Generate
            out += """<li><a class="uNameLink" href="%(site_url)s/supervisors/customevent?ln=%(ln)s&timespan=last+month&format=flot&ids=cardStructured&cols0=UID&col_value0=%(user)s&action_gen=Generate">%(email)s</a>"""  \
                        % {'site_url': CFG_SITE_URL, 'email': get_email(user), 'ln': CFG_SITE_LANG, 'user': user}
            actionInfo = acc_find_possible_actions_user(user, 22)
            collInfo = ""
            for aInfo in actionInfo:
              temp = aInfo[2].split()
              if len(temp[0]) == 4:
                for coll in temp:
                  p_total = "980__a:%s" % coll
                  res_total = search_pattern(p=p_total)
                  p_done = "980__a:%s and (950__s:%s or 950__s:2)" % (coll, "p*")
                  res_done = search_pattern_parenthesised(p=p_done)
                  p_check = "980__a:%s and (950__s:na* or 950__s:3)" % (coll)
                  res_check = search_pattern_parenthesised(p=p_check)

                  collLink_main = """<a href="%(site_url)s/search?cc=%(coll)s&ln=%(ln)s&jrec=1&so=a">%(coll)s</a>
                        """ % {'coll': coll, 'site_url': CFG_SITE_URL, 'ln': CFG_SITE_LANG }

                  strProgress = ""

                  if len(res_done)+len(res_check) != 0:
                    if len(res_done) == len(res_total):
                      strProgress = """<span class="supervisor_prog_done">completed</span>: %i""" % (len(res_total))
                    else:
                      collLink_done = """<span class="supervisor_prog_started">in progress</span>:&nbsp;<a href="%(site_url)s/search?cc=%(coll)s&ln=%(ln)s&&p=950__s:2+or+950__s:p*&jrec=1&so=a">%(res_done)i</a>
                              """ % {'coll': coll, 'site_url': CFG_SITE_URL, 'ln': CFG_SITE_LANG, 'res_done': len(res_done) }
                      strProgress = "%s / %i" % (collLink_done, len(res_total))
                      if len(res_check) > 0:
                        collLink_check = """<span class="supervisor_prog_review"><a href="%(site_url)s/search?cc=%(coll)s&ln=%(ln)s&p=950__s:3+or+950__s:na*&jrec=1&so=a">%(res_check)i</span></a>
                              """ % {'coll': coll, 'site_url': CFG_SITE_URL, 'ln': CFG_SITE_LANG, 'res_check': len(res_check) }
                        if len(res_done)>0:
                          strProgress = "%s+ %s / %i" % (collLink_done, collLink_check, len(res_total))
                        else:
                          strProgress = "%s / %i" % (collLink_check, len(res_total))
                  else:
                    strProgress = """<span class="supervisor_prog_notStarted">waiting</span>: %s""" % len(res_total)
  

                  collInfo += """ %s <small class="nbdoccollz">(%s)</small>""" % (collLink_main, strProgress)

            if collInfo != "":
              out += """<span class="supervisor_usercolls">""" + collInfo + """</span>"""
            out += """</li>"""
          out += """</ul>"""

        #TP: nakreslim seznam neprirazenych uzivatelu
        out += """<h3>Unassigned users</h3><p>You may want to consider attaching one of the unassigned users to an supervisor. If so, please contact your administrator.</p><ul>"""
        for user in list_registered_users():
          str_user_info = get_user_info(user[0])
          if user[0] not in assignedUsers:
            out += """<li>%s</li>"""  \
                        % (get_email(user[0]))
        out += """</ul>"""

        return out