Ejemplo n.º 1
0
    def _process(self):
        stats = CategoryStatistics(self._target).getStatistics()
        if stats is not None:
            stats = stats.copy()
        if request.accept_mimetypes.best_match(("application/json", "text/html")) == "application/json":
            if stats is None:
                stats = {"events": None, "contributions": None, "files": None, "updated": None}
            else:
                stats = dict(stats)

            if stats["updated"]:
                stats["updated"] = stats["updated"].isoformat()
            return jsonify(stats)
        else:
            if stats is not None:
                plots, values, updated = _process_stats(stats, root=self._target.isRoot())
            else:
                plots = values = updated = None
            return WPCategoryStatistics.render_template(
                "category_statistics.html",
                self._target,
                cat=self._target,
                plots=plots,
                values=values,
                updated=updated,
                has_stats=(stats is not None),
            )
Ejemplo n.º 2
0
 def _process(self):
     if request.accept_mimetypes.best_match(
         ('application/json', 'text/html')) == 'application/json':
         return redirect(
             url_for('categories.statistics_json',
                     category_id=self.category.id))
     return WPCategoryStatistics.render_template('category_statistics.html',
                                                 self.category)
Ejemplo n.º 3
0
 def _get_stats_html(self, stats):
     plots, values, updated = self._process_stats(
         stats, root=self.category.is_root)
     return WPCategoryStatistics.render_template('category_statistics.html',
                                                 self.category,
                                                 plots=plots,
                                                 values=values,
                                                 updated=updated,
                                                 has_stats=True)
Ejemplo n.º 4
0
 def _process(self):
     stats = get_category_stats(int(self._target.getId()))
     if request.accept_mimetypes.best_match(('application/json', 'text/html')) == 'application/json':
         data = {'events': stats['events_by_year'], 'contributions': stats['contribs_by_year'],
                 'files': stats['attachments'], 'updated': stats['updated'].isoformat()}
         if self._target.isRoot():
             data['users'] = _count_users()
         return jsonify(data)
     else:
         plots, values, updated = _process_stats(stats, root=self._target.isRoot())
         return WPCategoryStatistics.render_template('category_statistics.html', self._target,
                                                     cat=self._target,
                                                     plots=plots,
                                                     values=values,
                                                     updated=updated,
                                                     has_stats=True)
Ejemplo n.º 5
0
    def _process(self):
        stats = CategoryStatistics(self._target).getStatistics().copy()
        if request.accept_mimetypes.best_match(('application/json', 'text/html')) == 'application/json':
            if stats is None:
                stats = {'events': None, 'contributions': None, 'files': None, 'updated': None}
            else:
                stats = dict(stats)

            if stats['updated']:
                stats['updated'] = stats['updated'].isoformat()
            return jsonify(stats)
        else:
            plots, values, updated = _process_stats(stats, root=self._target.isRoot())
            return WPCategoryStatistics.render_template('category_statistics.html', self._target,
                                                        cat=self._target,
                                                        plots=plots,
                                                        values=values,
                                                        updated=updated)
Ejemplo n.º 6
0
 def _process(self):
     stats = get_category_stats(int(self._target.getId()))
     if request.accept_mimetypes.best_match(
         ('application/json', 'text/html')) == 'application/json':
         data = {
             'events': stats['events_by_year'],
             'contributions': stats['contribs_by_year'],
             'files': stats['attachments'],
             'updated': stats['updated'].isoformat()
         }
         if self._target.isRoot():
             data['users'] = _count_users()
         return jsonify(data)
     else:
         plots, values, updated = _process_stats(stats,
                                                 root=self._target.isRoot())
         return WPCategoryStatistics.render_template(
             'category_statistics.html',
             self._target,
             cat=self._target,
             plots=plots,
             values=values,
             updated=updated,
             has_stats=True)
Ejemplo n.º 7
0
    def _process(self):
        stats = CategoryStatistics(self._target).getStatistics()
        if stats is not None:
            stats = stats.copy()
        if request.accept_mimetypes.best_match(('application/json', 'text/html')) == 'application/json':
            if stats is None:
                stats = {'events': None, 'contributions': None, 'files': None, 'updated': None}
            else:
                stats = dict(stats)

            if stats['updated']:
                stats['updated'] = stats['updated'].isoformat()
            return jsonify(stats)
        else:
            if stats is not None:
                plots, values, updated = _process_stats(stats, root=self._target.isRoot())
            else:
                plots = values = updated = None
            return WPCategoryStatistics.render_template('category_statistics.html', self._target,
                                                        cat=self._target,
                                                        plots=plots,
                                                        values=values,
                                                        updated=updated,
                                                        has_stats=(stats is not None))
Ejemplo n.º 8
0
 def _get_stats_html(self, stats):
     plots, values, updated = self._process_stats(stats, root=self.category.is_root)
     return WPCategoryStatistics.render_template('category_statistics.html', self.category,
                                                 plots=plots, values=values, updated=updated, has_stats=True)