Merge "Add User-ID Field in Booking API Serializer"
[pharos-tools.git] / dashboard / src / account / models.py
1 ##############################################################################
2 # Copyright (c) 2016 Max Breitenfeldt and others.
3 #
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
9
10
11 from django.contrib.auth.models import User
12 from django.db import models
13
14
15 def upload_to(object, filename):
16     return object.user.username + '/' + filename
17
18 class UserProfile(models.Model):
19     user = models.OneToOneField(User, on_delete=models.CASCADE)
20     timezone = models.CharField(max_length=100, blank=False, default='UTC')
21     ssh_public_key = models.FileField(upload_to=upload_to, null=True, blank=True)
22     pgp_public_key = models.FileField(upload_to=upload_to, null=True, blank=True)
23     email_addr = models.CharField(max_length=300, blank=False, default='email@mail.com')
24     company = models.CharField(max_length=200, blank=False)
25
26     oauth_token = models.CharField(max_length=1024, blank=False)
27     oauth_secret = models.CharField(max_length=1024, blank=False)
28
29     jira_url = models.CharField(max_length=100, default='')
30     full_name = models.CharField(max_length=100, default='')
31
32     class Meta:
33         db_table = 'user_profile'
34
35     def __str__(self):
36         return self.user.username
37
38 class Lab(models.Model):
39     lab_user = models.OneToOneField(User, on_delete=models.CASCADE)
40     name = models.CharField(max_length=200, primary_key=True, unique=True, null=False, blank=False)
41     contact_email = models.EmailField(max_length=200, null=True, blank=True)
42     contact_phone = models.CharField(max_length=20, null=True, blank=True)
43
44     def __str__(self):
45         return self.name