Beispiel #1
0
 def get_context_data(self, **kwargs):
     context = super(ReportView, self).get_context_data()
     # A Manager can view Reports of number of Users
     context['count'] = UserDataView.get_active_user_count()
     # A Manager can view Reports of growth of number of Users
     context['growth_by_day'] = UserDataView.get_active_users_by_day(
         time_span=self.time_span)
     # A Manager can View a Report of the Rate of Growth of Users
     total = 0
     for item in context['growth_by_day']:
         total += item['created_count']
     context['growth_rate_per_day'] = round((1.0 * total) / self.time_span,
                                            2)
     return context
Beispiel #2
0
    def get_context_data(self, **kwargs):
        context = super(ReportView, self).get_context_data()

        context['users'] = UserDataView.alert_count(
            alert_count=self.alert_count)
        context['n'] = self.alert_count

        return context
Beispiel #3
0
    def get_context_data(self, **kwargs):
        context = super(WallList, self).get_context_data(**kwargs)
        own_wall = (int(self.user_id) == self.request.user.id)
        if not own_wall:
            target_user = UserDataView.by_id(user_id=self.user_id)
        else:
            target_user = self.request.user
            WallPostDataView.add_readstatus_to_posts(posts=context['object_list'], author_id=self.user_id)

        context.update({
            'suggestions': SuggestionsQuery().get(),
            'target_user': target_user,
            'own_wall': own_wall,
            'wall': target_user,
        })

        # if on own wall, the sharing person should be added to the post
        # so you can see the reason this post is on your wall
        if own_wall:
            WallPostDataView.add_share_source_to_posts(posts=context['object_list'], author_id=self.user_id)

        return context
Beispiel #4
0
 def get_user(self):
     username = self.get_cleaned_data_for_step('username').get('username')
     return UserDataView.by_username(username)
Beispiel #5
0
 def get_object(self):
     self.object = UserDataView.by_id(self.request.user.id)
     return self.object
Beispiel #6
0
 def save(self, request):
     logout(request)
     UserDataView.delete(self.user)
Beispiel #7
0
    def clean_username(self):
        username = self.cleaned_data.get('username')
        if not UserDataView.username_exists(username):
            raise forms.ValidationError("That username does not exist.")

        return username