-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathmodels.py
65 lines (45 loc) · 1.84 KB
/
models.py
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
54
55
56
57
58
59
60
61
62
63
64
65
from django.db import models
class Movie(models.Model):
movieid = models.CharField(max_length=20, primary_key=True)
title = models.CharField(max_length=30)
year = models.CharField(max_length=4)
length = models.CharField(max_length=10)
genres = models.CharField(max_length=100)
rate = models.IntegerField(default=0)
poster = models.URLField(default='')
plot = models.CharField(max_length=500)
trailer = models.URLField(default='')
def __str__(self):
return self.movieid + '|' + self.title
@staticmethod
def get_name():
return 'movie'
class Actor(models.Model):
actorid = models.CharField(max_length=20, primary_key=True)
name = models.CharField(max_length=30)
photo = models.URLField()
def __str__(self):
return self.actorid + '|' + self.name
@staticmethod
def get_name():
return 'actor'
class Act(models.Model):
movieid = models.ForeignKey('Movie', default=1, on_delete=models.CASCADE)
actorid = models.ForeignKey('Actor', default=1, on_delete=models.CASCADE)
def __str__(self):
return self.actorid.actorid + '|' + self.movieid.movieid
class Seen(models.Model):
username = models.CharField(max_length=150)
movieid = models.ForeignKey('Movie', default=1, on_delete=models.CASCADE)
def __str__(self):
return self.username + '|' + self.movieid.movieid
class Expect(models.Model):
username = models.CharField(max_length=150)
movieid = models.ForeignKey('Movie', default=1, on_delete=models.CASCADE)
def __str__(self):
return self.username + '|' + self.movieid.movieid
class Popularity(models.Model):
movieid = models.ForeignKey('Movie', default=' ', on_delete=models.CASCADE)
weight = models.IntegerField(default=0)
def __str__(self):
return self.movieid.movieid + '|' + str(self.weight)