Esempio n. 1
0
def dashboard(request, template="pages/dashboard.html"):
    my_username = request.user.username
    user = User.objects.get(username=my_username)
    my_recent = Variable.recent_resources(user, days=60, n_resources=5)

    context = {'recent': my_recent}
    return render(request, template, context)
Esempio n. 2
0
    def test_view(self):
        """ a view gets recorded """

        response = self.client.get(
            self.resource_url.format(res_id=self.holes.short_id))

        self.assertEqual(response.status_code, status.HTTP_200_OK)
        stuff = Variable.recent_resources(self.dog)
        self.assertEqual(stuff.count(), 1)
        r = stuff[0]
        self.assertEqual(r.short_id, self.holes.short_id)
        self.assertEqual(r.public, False)
        self.assertEqual(r.published, False)
        self.assertEqual(r.discoverable, False)

        # there's only one record!
        stuff = Variable.objects.filter(resource=self.holes)
        one = stuff[0]
        # the record describes the request above
        self.assertEqual(one.last_resource_id, self.holes.short_id)
        self.assertEqual(one.landing, True)
        self.assertEqual(one.rest, False)
Esempio n. 3
0
    def handle(self, *args, **options):
        username = options['username']
        days = options['days']
        n_resources = options['n_resources']

        try:
            user = User.objects.get(username=username)
        except User.DoesNotExist:
            print("username '{}' not found".format(username))
            exit(1)

        recent = Variable.recent_resources(user,
                                           days=days,
                                           n_resources=n_resources)
        for v in recent:
            print("last_access={} short_id={}".format(
                v.last_accessed.strftime("%Y-%m-%d %H:%M:%S"), v.short_id))
            print("  title={}".format(v.title))
            print("  created={} updated={}".format(
                v.created.strftime("%Y-%m-%d %H:%M:%S"),
                v.last_updated.strftime("%Y-%m-%d %H:%M:%S")))
            print("  published={} public={} discoverable={} first author={}".
                  format(v.published, v.public, v.discoverable,
                         v.first_creator))
Esempio n. 4
0
    def test_blank(self):
        """ nothing in tracking database at beginning """

        stuff = Variable.recent_resources(self.dog)
        self.assertEqual(stuff.count(), 0)