This repository was archived by the owner on May 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 347
Expand file tree
/
Copy pathuser.py
More file actions
70 lines (52 loc) · 2.35 KB
/
Copy pathuser.py
File metadata and controls
70 lines (52 loc) · 2.35 KB
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
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from django.contrib.auth.models import User
from vilya.libs.gravatar import gravatar_url
from vilya.models.inbox import Inbox
class UserProfile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
# TODO(xutao) gravatar
# TODO(xutao) trello token
# TODO(xutao) team
# TODO(xutao) project
# TODO(xutao) notification
# TODO(xutao) badge
# TODO(xutao) setting
def get_gravatar_url(self, size=80):
return gravatar_url(self.email, size)
@property
def inbox(self):
return Inbox.get(user=self.name)
@property
def unread_notification_count(self):
from vilya.models.notification import Notification
return Notification.unread_count(self.name)
class UserFollower(models.Model):
follower = models.ForeignKey(User, db_constraint=False, related_name='follower')
followee = models.ForeignKey(User, db_constraint=False, related_name='followee')
created_at = models.DateTimeField('created at', auto_now_add=True)
updated_at = models.DateTimeField('updated at', auto_now=True)
class UserEmail(models.Model):
user = models.ForeignKey(User, db_constraint=False)
email = models.CharField(max_length=100)
created_at = models.DateTimeField('created at', auto_now_add=True)
updated_at = models.DateTimeField('updated at', auto_now=True)
class UserKey(models.Model):
title = models.CharField(max_length=128)
text = models.CharField(max_length=1024)
fingerprint = models.CharField(max_length=48)
user = models.ForeignKey(User, db_constraint=False)
created_at = models.DateTimeField('created at', auto_now_add=True)
updated_at = models.DateTimeField('updated at', auto_now=True)
# TODO(xutao) support kind for activity?
class Badge(models.Model):
desc = models.CharField(max_length=1024)
created_at = models.DateTimeField('created at', auto_now_add=True)
updated_at = models.DateTimeField('updated at', auto_now=True)
class UserBadge(models.Model):
user = models.ForeignKey(User, db_constraint=False)
badge = models.ForeignKey(Badge, db_constraint=False)
desc = models.CharField(max_length=1024)
created_at = models.DateTimeField('created at', auto_now_add=True)
updated_at = models.DateTimeField('updated at', auto_now=True)