Commit b998c7bb authored by Stefano Alberto Russo's avatar Stefano Alberto Russo
Browse files

Added base Web App functionalities and models. Minor fixes.

parent 554e0d58
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -24,6 +24,9 @@ services:
    privileged: true
    volumes:
      - ./data/shared:/shared
    ports:
      - "8591:8590"
      - "5901:5900"

  dregistry:
    container_name: dregistry
@@ -44,9 +47,13 @@ services:
      - ROSETTA_LOG_LEVEL=DEBUG
    ports:
      - "8080:8080"
      - "8000:8590"
      - "8592:8592"
      - "7000-7005:7000-7005"
    volumes:
      - ./data_rosetta/webapp/data:/data
      - ./data_rosetta/webapp/log:/var/log/webapp
      - /var/run/docker.sock:/var/run/docker.sock
      #- ./images/webapp/code:/opt/webapp_code


+3 −2
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ RUN apt-get install python3-dev -y
# Install postgres driver required for psycopg2
RUN apt-get install libpq-dev -y

# Docker
RUN apt-get install docker.io -y

#------------------------------
# Install Django project
@@ -72,6 +74,7 @@ RUN mkdir /var/log/webapp/ && chown rosetta:rosetta /var/log/webapp/
COPY run_webapp.sh /etc/supervisor/conf.d/
RUN chmod 755 /etc/supervisor/conf.d/run_webapp.sh
COPY supervisord_webapp.conf /etc/supervisor/conf.d/
COPY supervisord_dregistrytunnel.conf /etc/supervisor/conf.d/


#------------------------------
@@ -86,5 +89,3 @@ COPY prestartup_webapp.sh /prestartup/



+6 −0
Original line number Diff line number Diff line

class ErrorMessage(Exception):
    pass

class ConsistencyException(Exception):
    pass
 No newline at end of file
+1 −1
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ class Command(BaseCommand):
            print('Not creating admin user as it already exist')
        except User.DoesNotExist:
            print('Creating admin user with default password')
            admin = User.objects.create_superuser('admin', 'admin@example.com', 'a')
            admin = User.objects.create_superuser('admin', 'admin@example.com', 'admin')
            Profile.objects.create(user=admin)

        try:
+28 −0
Original line number Diff line number Diff line
import uuid
from django.db import models
from django.contrib.auth.models import User
from django.utils import timezone


#=========================
@@ -21,6 +22,33 @@ class Profile(models.Model):
        return str('Profile of user "{}"'.format(self.user.username))


#=========================
#  Login Token 
#=========================

class LoginToken(models.Model):
    user  = models.OneToOneField(User, on_delete=models.CASCADE)
    token = models.CharField('Login token', max_length=36)


#=========================
#  Tasks 
#=========================
class Task(models.Model):
    user     = models.ForeignKey(User, related_name='+', on_delete=models.CASCADE)
    tid      = models.CharField('Task ID', max_length=64, blank=False, null=False)
    uuid     = models.CharField('Task UUID', max_length=36, blank=False, null=False)
    name     = models.CharField('Task name', max_length=36, blank=False, null=False)
    type     = models.CharField('Task type', max_length=36, blank=False, null=False)
    status   = models.CharField('Task status', max_length=36, blank=True, null=True)
    created  = models.DateTimeField('Created on', default=timezone.now)

    def __str__(self):
        return str('Task "{}" of user "{}" in status "{}" (TID "{}")'.format(self.name, self.user.email, self.status, self.tid))







Loading