1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 import datetime
20
21 from django.db import models
22 from omeroweb.webpublic.baseconv import base62
23
24 -class Link(models.Model):
25 """
26 Model that represents a shortened URL
27
28 # Initialize by deleting all Link objects
29 >>> Link.objects.all().delete()
30
31 # Create some Link objects
32 >>> link1 = Link.objects.create(url="http://www.google.com/")
33 >>> link2 = Link.objects.create(url="http://www.nileshk.com/")
34
35 # Get base 62 representation of id
36 >>> link1.to_base62()
37 'B'
38 >>> link2.to_base62()
39 'C'
40
41 # Get short URL's
42 >>> link1.short_url()
43 'http://uu4.us/B'
44 >>> link2.short_url()
45 'http://uu4.us/C'
46
47 # Test usage_count
48 >>> link1.usage_count
49 0
50 >>> link1.usage_count += 1
51 >>> link1.usage_count
52 1
53 """
54
57
58 url = models.URLField(max_length=2048)
59 owner = models.IntegerField()
60 group = models.IntegerField()
61 submitted = models.DateTimeField(default=datetime.datetime.now())
62
65
68