Commit f07c9ee4 authored by BERJON Matthieu's avatar BERJON Matthieu

Update of the model

I updated the app model by:

- removing all uncessary fields in the user table (that now resides in
    the django auth_user table)
- update the other models by doing the same
- reorder the fields to have something more logical to read
- update the docstring to fit the updated description
Signed-off-by: BERJON Matthieu's avatarMatthieu Berjon <matthieu.berjon@inria.fr>
parent e306b23f
from __future__ import unicode_literals
from django.contrib.auth.models import User
from django.db import models
......@@ -16,9 +17,27 @@ class TimeStampModel(models.Model):
abstract = True
class DockerOs(models.Model):
class AllgoUser(models.Model):
"""
Docstring to update
Class linked to the Django user management. If there is a need to add a
field related to a user, it should be added here and not in the auth_user
table.
"""
sshkey = models.CharField(max_length=40)
# Relationships
user = models.OneToOneField(
User, on_delete=models.CASCADE, related_name="allgouser")
class Meta:
db_table = 'allgo_user'
class DockerOs(TimeStampModel):
"""
Contains the different Operating Systems that a user can choose from to
build its container.
"""
# Fields
......@@ -30,6 +49,20 @@ class DockerOs(models.Model):
db_table = 'docker_os'
class JobQueue(TimeStampModel):
"""
Data regarding the type of queues available for the system.
"""
# Fields
name = models.CharField(max_length=255)
timeout = models.IntegerField(blank=True, null=True)
is_default = models.IntegerField()
class Meta:
db_table = 'job_queues'
class Webapp(TimeStampModel):
"""
Webapp model related to the creation and management of a particular web
......@@ -56,9 +89,6 @@ class Webapp(TimeStampModel):
# Default quota
default_quota = models.IntegerField(blank=True, null=True)
# A webapp has one docker os type
docker_os = models.ForeignKey(DockerOs)
# Docker and parameters related stuff
docker_name = models.CharField(max_length=255, blank=True)
readme = models.IntegerField(blank=True, null=True)
......@@ -67,21 +97,28 @@ class Webapp(TimeStampModel):
private = models.IntegerField(blank=True, null=True)
access_token = models.CharField(max_length=255, blank=True, null=True)
sandbox_state = models.IntegerField(null=True)
# Not integrated in this model yet
sandbox_version_id = models.IntegerField(blank=True, null=True)
default_job_queue_id = models.IntegerField(null=True)
# Not integrated in this model yet
# sandbox_version_id = models.IntegerField(blank=True, null=True)
memory_limit = models.BigIntegerField(blank=True, null=True)
# Relationships
# A webapp has one docker os type
docker_os = models.OneToOneField(DockerOs, related_name="webappdockeros")
user = models.ForeignKey(
User, on_delete=models.CASCADE, related_name="webappuser")
job_queue = models.OneToOneField(
JobQueue, on_delete=models.CASCADE, related_name="webappjobqueue")
class Meta:
db_table = 'webapps'
class WebappParameter(models.Model):
class WebappParameter(TimeStampModel):
"""
Docstring to update
Given parameters for a specific webapp
"""
# Fields
......@@ -91,7 +128,7 @@ class WebappParameter(models.Model):
# Relationships
# a Webapp parameters corresponds to one webapp
webapp = models.ForeignKey(Webapp)
webapp = models.OneToOneField(Webapp, related_name="webappparameters")
class Meta:
db_table = 'webapp_parameters'
......@@ -99,144 +136,84 @@ class WebappParameter(models.Model):
class WebappVersion(TimeStampModel):
"""
Docstring to update
Version of a given webapp
"""
# Fields
number = models.CharField(max_length=255, blank=True)
changelog = models.CharField(max_length=255, blank=True)
webapp = models.ForeignKey(Webapp)
docker_image_size = models.FloatField(blank=True, null=True)
state = models.IntegerField(null=True)
published = models.IntegerField()
class Meta:
db_table = 'webapp_versions'
class User(TimeStampModel):
"""
User model regrouping information related to its email, password hash,
token, SSH key, ...
"""
# Fields
email = models.CharField(unique=True, max_length=255)
## Password management
encrypted_password = models.CharField(max_length=255)
reset_password_token = models.CharField(unique=True, null=True, max_length=255)
reset_password_sent_at = models.DateTimeField(blank=True, null=True)
remember_created_at = models.DateTimeField(blank=True, null=True)
# Signin/out
"""
These fields should be updated through the database and a method.
I don't see the difference between the last_sign_in_at and
current_sign_in_at fields. For me, they the same purpose
"""
sign_in_count = models.IntegerField()
current_sign_in_at = models.DateTimeField(blank=True, null=True)
last_sign_in_at = models.DateTimeField(blank=True, null=True)
# IP data
current_sign_in_ip = models.CharField(max_length=255, blank=True, null=True)
last_sign_in_ip = models.CharField(max_length=255, blank=True, null=True)
# Is admin
admin = models.IntegerField(default=False)
# Token information
confirmation_token = models.CharField(unique=True, max_length=255, blank=True, null=True)
confirmed_at = models.DateTimeField(blank=True, null=True)
confirmation_sent_at = models.DateTimeField(blank=True, null=True)
sshkey = models.TextField(blank=True, null=True)
auth_token = models.CharField(max_length=255, blank=True, null=True)
# Relationships
"""
- A user can possess several webapps
- A webapp can possess several users (not only one admin)
"""
webapp = models.ManyToManyField(Webapp, through='Quota')
webapp = models.ForeignKey(Webapp, related_name="webappversion")
class Meta:
db_table = 'users'
db_table = 'webapp_versions'
class Quota(TimeStampModel):
"""
Docstring to update
"""
Quota given to a certain user for a given webapp.
user = models.ForeignKey(User, on_delete=models.CASCADE)
webapp = models.ForeignKey(Webapp, on_delete=models.CASCADE)
Todo
- write a function that calculates the quota left to the user
"""
# Fields
quantity = models.BigIntegerField(blank=True, null=True)
# Relationships
user = models.ForeignKey(
User, on_delete=models.CASCADE, related_name="quotauser")
webapp = models.ForeignKey(
Webapp, on_delete=models.CASCADE, related_name="quotawebapp")
class Meta:
db_table = 'quotas'
class JobQueue(TimeStampModel):
"""
Docstring to edit
"""
# Fields
name = models.CharField(max_length=255)
timeout = models.IntegerField(blank=True, null=True)
is_default = models.IntegerField()
class Meta:
db_table = 'job_queues'
class Job(TimeStampModel):
"""
Docstring to update
Jobs ran with the specific data (user, webapp, queue type, ...)
"""
webapp = models.ForeignKey(Webapp)
user = models.ForeignKey(User)
# Fields
param = models.CharField(max_length=255, blank=True, null=True)
datasize = models.IntegerField(blank=True, null=True)
version = models.CharField(max_length=255, blank=True, null=True)
exec_time = models.IntegerField(blank=True, null=True)
size_generated_data = models.IntegerField(blank=True, null=True)
ipaddress = models.CharField(max_length=255, blank=True, null=True)
access_token = models.CharField(max_length=255, blank=True, null=True)
state = models.IntegerField()
# Not in use
container_id = models.IntegerField(blank=True, null=True)
queue = models.ForeignKey(JobQueue)
result = models.IntegerField()
# Relationships
queue = models.ForeignKey(JobQueue, related_name="jobqueue")
webapp = models.ForeignKey(Webapp, related_name="jobwebapp")
user = models.ForeignKey(AllgoUser, related_name="jobuser")
# Not in use because I don't have any related table yet
container_id = models.IntegerField(blank=True, null=True)
class Meta:
db_table = 'jobs'
class JobUploads(models.Model):
class JobUploads(TimeStampModel):
"""
Docstring to edit
Data uploaded by the user to feed a given webapp
"""
# Fields
job_file_file_name = models.CharField(max_length=255, blank=True)
job_file_content_type = models.CharField(max_length=255, blank=True)
job_file_file_size = models.IntegerField(blank=True, null=True)
job_file_updated_at = models.DateTimeField(blank=True, auto_now_add=True, null=True)
type = models.CharField(max_length=255, null=True)
job_file_updated_at = models.DateTimeField(
blank=True, auto_now_add=True, null=True)
# Relationships
# A job upload corresponds to one job
job = models.ForeignKey(Job)
job = models.ForeignKey(Job, related_name="jobuploadjob")
class Meta:
db_table = 'job_uploads'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment