Пример #1
0
    def settings(self, **kw):
        require_access(c.project, "admin")

        self.user = c.project.user_project_of
        if not self.user:
            return dict(user=None)
        if not self.user.stats:
            UserStats.create(self.user)
        return dict(user=self.user, form=StatsPreferencesForm(action=c.project.url() + "userstats/change_settings"))
Пример #2
0
    def change_settings(self, **kw):
        require_access(c.project, 'admin')

        self.user = c.project.user_project_of
        if not self.user:
            return dict(user=None)
        if not self.user.stats:
            UserStats.create(self.user)
        visible = kw.get('visible')
        self.user.stats.visible = visible
        redirect(c.project.url() + 'userstats/settings')
Пример #3
0
    def settings(self, **kw):
        require_access(c.project, 'admin')

        self.user = c.project.user_project_of
        if not self.user:
            return dict(user=None)
        if not self.user.stats:
            UserStats.create(self.user)
        return dict(user=self.user,
                    form=StatsPreferencesForm(action=c.project.url() +
                                              'userstats/change_settings'))
Пример #4
0
    def change_settings(self, **kw):
        require_access(c.project, "admin")

        self.user = c.project.user_project_of
        if not self.user:
            return dict(user=None)
        if not self.user.stats:
            UserStats.create(self.user)
        visible = kw.get("visible")
        self.user.stats.visible = visible
        redirect(c.project.url() + "userstats/settings")
Пример #5
0
    def tickets(self, **kw):
        self.user = c.project.user_project_of
        if not self.user:
            return dict(user=None)
        if not self.user.stats:
            UserStats.create(self.user)
        stats = self.user.stats

        if (not stats.visible) and (c.user != self.user):
            return dict(user=self.user)

        artifacts = self.user.stats.getTicketsByCategory()
        return dict(user=self.user, data=artifacts)
Пример #6
0
    def tickets(self, **kw):
        self.user = c.project.user_project_of
        if not self.user:
            return dict(user=None)
        if not self.user.stats:
            UserStats.create(self.user)
        stats = self.user.stats

        if (not stats.visible) and (c.user != self.user):
            return dict(user=self.user)

        artifacts = self.user.stats.getTicketsByCategory()
        return dict(user=self.user, data=artifacts)
Пример #7
0
 def stats(self):
     if 'userstats' in g.entry_points['stats']:
         from forgeuserstats.model.stats import UserStats
         if self.stats_id:
             return UserStats.query.get(_id=self.stats_id)
         return UserStats.create(self)
     else:
         return None
Пример #8
0
 def stats(self):
     if 'userstats' in g.entry_points['stats']:
         from forgeuserstats.model.stats import UserStats
         if self.stats_id:
             return UserStats.query.get(_id=self.stats_id)
         return UserStats.create(self)
     else:
         return None
Пример #9
0
    def index(self, **kw):
        self.user = c.project.user_project_of
        if not self.user:
            return dict(user=None)
        if not self.user.stats:
            UserStats.create(self.user)

        stats = self.user.stats
        if (not stats.visible) and (c.user != self.user):
            return dict(user=self.user)

        ret_dict = _getDataForCategory(None, stats)
        ret_dict['user'] = self.user

        ret_dict['registration_date'] = stats.registration_date

        ret_dict['totlogins'] = stats.tot_logins_count
        ret_dict['last_login'] = stats.last_login
        if stats.last_login:
            ret_dict['last_login_days'] = \
                (datetime.utcnow() - stats.last_login).days

        categories = {}
        for p in self.user.my_projects():
            for cat in p.trove_topic:
                cat = M.TroveCategory.query.get(_id=cat)
                if categories.get(cat):
                    categories[cat] += 1
                else:
                    categories[cat] = 1
        categories = sorted(list(categories.items()),
                            key=lambda x_y: x_y[1],
                            reverse=True)

        ret_dict['lastmonth_logins'] = stats.getLastMonthLogins()
        ret_dict['categories'] = categories
        days = ret_dict['days']
        if days >= 30:
            ret_dict['permonthlogins'] = \
                round(stats.tot_logins_count * 30.0 / days, 2)
        else:
            ret_dict['permonthlogins'] = 'n/a'

        return ret_dict
Пример #10
0
    def index(self, **kw):
        self.user = c.project.user_project_of
        if not self.user:
            return dict(user=None)
        if not self.user.stats:
            UserStats.create(self.user)

        stats = self.user.stats
        if (not stats.visible) and (c.user != self.user):
            return dict(user=self.user)

        ret_dict = _getDataForCategory(None, stats)
        ret_dict['user'] = self.user

        ret_dict['registration_date'] = stats.registration_date

        ret_dict['totlogins'] = stats.tot_logins_count
        ret_dict['last_login'] = stats.last_login
        if stats.last_login:
            ret_dict['last_login_days'] = \
                (datetime.utcnow() - stats.last_login).days

        categories = {}
        for p in self.user.my_projects():
            for cat in p.trove_topic:
                cat = M.TroveCategory.query.get(_id=cat)
                if categories.get(cat):
                    categories[cat] += 1
                else:
                    categories[cat] = 1
        categories = sorted(categories.items(),
                            key=lambda (x, y): y, reverse=True)

        ret_dict['lastmonth_logins'] = stats.getLastMonthLogins()
        ret_dict['categories'] = categories
        days = ret_dict['days']
        if days >= 30:
            ret_dict['permonthlogins'] = \
                round(stats.tot_logins_count * 30.0 / days, 2)
        else:
            ret_dict['permonthlogins'] = 'n/a'

        return ret_dict