blob: b0a9fc3f2cd0b08bd74dddc4332e6761db42705d (
plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
from django.conf import settings
from django.db import models
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
class FossCategory(models.Model):
name = models.CharField(max_length=100)
description = models.TextField()
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
def __unicode__(self):
return self.name
class Issue(models.Model):
name = models.CharField(max_length=100)
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
def __unicode__(self):
return self.name
class Question(models.Model):
user = models.ForeignKey(User)
category = models.ForeignKey(FossCategory)
title = models.CharField(max_length=200)
body = models.TextField()
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
views = models.IntegerField(default=1)
userUpVotes = models.ManyToManyField(User, blank=True, related_name='postUpVotes')
userDownVotes = models.ManyToManyField(User, blank=True, related_name='postDownVotes')
num_votes = models.IntegerField(default=0)
def __unicode__(self):
return '%s' % (self.user)
class Meta:
get_latest_by = "date_created"
class QuestionVote(models.Model):
uid = models.IntegerField()
question = models.ForeignKey(Question)
class QuestionComment(models.Model):
uid = models.IntegerField()
question = models.ForeignKey(Question)
body = models.TextField()
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
class Answer(models.Model):
uid = models.IntegerField()
question = models.ForeignKey(Question)
body = models.TextField()
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
#userUpVotes = models.ManyToManyField(User, blank=True, related_name='postUpVotes')
#userDownVotes = models.ManyToManyField(User, blank=True, related_name='postDownVotes')
upvotes = models.IntegerField(default=0)
num_votes = models.IntegerField(default=0)
def user(self):
user = User.objects.get(id=self.uid)
return user.username
class AnswerVote(models.Model):
uid = models.IntegerField()
answer = models.ForeignKey(Answer)
class AnswerComment(models.Model):
uid = models.IntegerField()
answer = models.ForeignKey(Answer)
body = models.TextField(blank=False)
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(auto_now=True)
def user(self):
user = User.objects.get(id=self.uid)
return user.username
class Notification(models.Model):
uid = models.IntegerField()
pid = models.IntegerField()
qid = models.IntegerField()
aid = models.IntegerField(default=0)
cid = models.IntegerField(default=0)
date_created = models.DateTimeField(auto_now_add=True)
def poster(self):
user = User.objects.get(id=self.pid)
return user.username
class Profile(models.Model):
user = models.ForeignKey(User)
confirmation_code = models.CharField(max_length=255)
phone = models.CharField(max_length=20, null=True)
address = models.TextField(null=True)
created = models.DateTimeField(auto_now_add=True)
class Meta:
app_label = 'website'
|