예제 #1
0
 def list_launched(cls):
     """Returns a list of the launched (listed in menu) repository names."""
     return [
         name for name in Repo.list()
         if config.get_for_repo(name, 'launched')
         and not config.get_for_repo(name, 'deactivated')
     ]
예제 #2
0
 def list_launched(cls):
     """Returns a list of the launched (listed in menu) repository names."""
     return [
         name
         for name in Repo.list()
         if config.get_for_repo(name, "launched") and not config.get_for_repo(name, "deactivated")
     ]
예제 #3
0
def get_repo_options(request, lang):
    """Returns a list of the names and titles of the launched repositories."""
    options = []
    for repo in model.Repo.list_launched():
        titles = config.get_for_repo(repo, 'repo_titles', {})
        default_title = (titles.values() or ['?'])[0]
        title = titles.get(lang, titles.get('en', default_title))
        url = utils.get_repo_url(request, repo)
        test_mode = config.get_for_repo(repo, 'test_mode')
        options.append(
            utils.Struct(repo=repo, title=title, url=url, test_mode=test_mode))
    return options
예제 #4
0
def get_repo_options(request, lang):
    """Returns a list of the names and titles of the launched repositories."""
    options = []
    for repo in model.Repo.list_launched():
        titles = config.get_for_repo(repo, 'repo_titles', {})
        default_title = (titles.values() or ['?'])[0]
        title = titles.get(lang, titles.get('en', default_title))
        url = utils.get_repo_url(request, repo)
        test_mode = config.get_for_repo(repo, 'test_mode')
        options.append(utils.Struct(repo=repo, title=title, url=url,
                                    test_mode=test_mode))
    return options
예제 #5
0
 def get_latest_updated_date(self, repos):
     latest_updated_date = 0
     for repo in repos:
         updated_date = config.get_for_repo(repo, 'updated_date', '')
         if updated_date > latest_updated_date:
             latest_updated_date = updated_date
     return latest_updated_date
예제 #6
0
 def get(self, request, *args, **kwargs):
     del request, args, kwargs  # Unused.
     if self.env.repo == 'global':
         data = []
         repos = model.Repo.all().filter('activation_status =',
                                         model.Repo.ActivationStatus.ACTIVE)
         for repo in repos:
             repo_id = repo.key().name()
             # TODO(nworden): Move this data onto the Repo object, like we
             # did for activation status. It'd be more efficient, and IMO the
             # code would be cleaner.
             repo_title = self._select_repo_title(
                 config.get_for_repo(repo_id, 'repo_titles'),
                 config.get_for_repo(repo_id, 'language_menu_options'))
             data.append({
                 'repoId': repo_id,
                 'title': repo_title,
                 'recordCount': self._get_person_count(repo_id),
             })
     else:
         repo = model.Repo.get(self.env.repo)
         if not repo:
             return self.error(404)
         # We permit requests for staging repos so that admins can preview
         # the repo. In the future we might consider requiring admin status
         # to see them, though we'd need to provide some kind of login flow
         # for that.
         if (repo.activation_status ==
                 model.Repo.ActivationStatus.DEACTIVATED):
             return self.error(404)
         repo_title = self._select_repo_title(
             self.env.config.get('repo_titles'),
             self.env.config.get('language_menu_options'))
         data = {
             'repoId': self.env.repo,
             'title': repo_title,
             'recordCount': self._get_person_count(self.env.repo),
             'mapDefaultCenter': self.env.config.get('map_default_center'),
             'mapDefaultZoom': self.env.config.get('map_default_zoom'),
         }
     return self._json_response(data)
예제 #7
0
    def get_effective_expiry_date(self):
        """Gets the expiry_date, or if no expiry_date is present, returns the
        source_date plus the configurable default_expiration_days interval.

        If there's no source_date, we use original_creation_date.
        Returns:
          A datetime date (not None).
        """
        if self.expiry_date:
            return self.expiry_date
        else:
            expiration_days = config.get_for_repo(self.repo, "default_expiration_days") or (DEFAULT_EXPIRATION_DAYS)
            # in theory, we should always have original_creation_date, but since
            # it was only added recently, we might have legacy
            # records without it.
            start_date = self.source_date or self.original_creation_date or utils.get_utcnow()
            return start_date + timedelta(expiration_days)
예제 #8
0
    def get_effective_expiry_date(self):
        """Gets the expiry_date, or if no expiry_date is present, returns the
        source_date plus the configurable default_expiration_days interval.

        If there's no source_date, we use original_creation_date.
        Returns:
          A datetime date (not None).
        """
        if self.expiry_date:
            return self.expiry_date
        else:
            expiration_days = config.get_for_repo(
                self.repo,
                'default_expiration_days') or (DEFAULT_EXPIRATION_DAYS)
            # in theory, we should always have original_creation_date, but since
            # it was only added recently, we might have legacy
            # records without it.
            start_date = self.original_creation_date or utils.get_utcnow()
            return start_date + timedelta(expiration_days)
예제 #9
0
def get_latest_repo_updated_date(repos):
    dates = [config.get_for_repo(repo, 'updated_date') for repo in repos]
    return dates and max(dates) or utils.get_utcnow()
예제 #10
0
 def list_active(cls):
     """Returns a list of the active (non-deactivated) repository names."""
     return [
         name for name in Repo.list()
         if not config.get_for_repo(name, 'deactivated')
     ]
예제 #11
0
 def list_active(cls):
     """Returns a list of the active (non-deactivated) repository names."""
     return [name for name in Repo.list()
             if not config.get_for_repo(name, 'deactivated')]
예제 #12
0
 def list_launched(cls):
     """Returns a list of the launched (listed in menu) repository names."""
     return [name for name in config.get('launched_repos', [])
             if not config.get_for_repo(name, 'deactivated')]
예제 #13
0
def get_latest_repo_updated_date(repos):
    dates = [config.get_for_repo(repo, 'updated_date') for repo in repos]
    return dates and max(dates) or utils.get_utcnow()
예제 #14
0
 def list_launched(cls):
     """Returns a list of the launched (listed in menu) repository names."""
     return [
         name for name in config.get('launched_repos', [])
         if not config.get_for_repo(name, 'deactivated')
     ]