forked from vitorfs/bootcamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
executable file
·58 lines (45 loc) · 2.24 KB
/
Copy pathmodels.py
File metadata and controls
executable file
·58 lines (45 loc) · 2.24 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
from django.contrib.auth.models import AbstractUser
from django.contrib.auth.signals import user_logged_in, user_logged_out
from django.db import models
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
from bootcamp.notifications.models import Notification, notification_handler
class User(AbstractUser):
# First Name and Last Name do not cover name patterns around the globe.
name = models.CharField(_("User's name"), blank=True, max_length=255)
picture = models.ImageField(
_('Profile picture'), upload_to='profile_pics/', null=True, blank=True)
location = models.CharField(
_('Location'), max_length=50, null=True, blank=True)
job_title = models.CharField(
_('Job title'), max_length=50, null=True, blank=True)
personal_url = models.URLField(
_('Personal URL'), max_length=555, blank=True, null=True)
facebook_account = models.URLField(
_('Facebook profile'), max_length=255, blank=True, null=True)
twitter_account = models.URLField(
_('Twitter account'), max_length=255, blank=True, null=True)
github_account = models.URLField(
_('GitHub profile'), max_length=255, blank=True, null=True)
linkedin_account = models.URLField(
_('LinkedIn profile'), max_length=255, blank=True, null=True)
short_bio = models.CharField(
_('Describe yourself'), max_length=60, blank=True, null=True)
bio = models.CharField(
_('Short bio'), max_length=280, blank=True, null=True)
def __str__(self):
return self.username
def get_absolute_url(self):
return reverse('users:detail', kwargs={'username': self.username})
def get_profile_name(self):
if self.name:
return self.name
return self.username
def broadcast_login(sender, user, request, **kwargs):
"""Handler to be fired up upon user login signal to notify all users."""
notification_handler(user, "global", Notification.LOGGED_IN)
def broadcast_logout(sender, user, request, **kwargs):
"""Handler to be fired up upon user logout signal to notify all users."""
notification_handler(user, "global", Notification.LOGGED_OUT)
# user_logged_in.connect(broadcast_login)
# user_logged_out.connect(broadcast_logout)