class Resource models Model url models URLField verbose_name URL ratin

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class Resource(models.Model):
url = models.URLField(verbose_name='URL')
rating = models.PositiveIntegerField(verbose_name='rating', default=0)
approved = models.BooleanField(verbose_name='approved', default=False)
article = models.ForeignKey(Article, on_delete=models.CASCADE, related_name='resources')
who_added = models.ForeignKey(User, related_name='added_blog_posts', on_delete=models.CASCADE)
users = models.ManyToManyField(User, 'resources', through='ResourceUser')
class BlogPost(Resource):
title = models.CharField(verbose_name='title', max_length=300, default=None, null=True)
description = models.TextField(verbose_name='description', default=None, null=True)
image = models.URLField(verbose_name='image_url', default=None, null=True)
@property
def type(self):
return 'blogpost'
class GitHub(Resource):
title = models.CharField(verbose_name='title', max_length=300)
description = models.TextField(verbose_name='description', default='')
topics = TaggableManager()
n_stars = models.PositiveIntegerField(verbose_name='stars', default=0)
language = models.CharField(verbose_name='language', max_length=100, default='')
framework = models.CharField(verbose_name='language', max_length=100, default='')
languages = HStoreField(default=dict)
is_official = models.BooleanField(verbose_name='is_official', default=False)
@property
def type(self):
return 'github'
class Reddit(Resource):
title = models.CharField(verbose_name='title', max_length=300, default=None, null=True)
description = models.TextField(verbose_name='description', default=None, null=True)
image = models.URLField(verbose_name='image_url', default=None, null=True)
@property
def type(self):
return 'reddit'
class YouTube(Resource):
title = models.CharField(verbose_name='title', max_length=300, default=None, null=True)
description = models.TextField(verbose_name='description', default=None, null=True)
image = models.URLField(verbose_name='image_url', default=None, null=True)
@property
def type(self):
return 'youtube'