Skip to content

Commit

Permalink
Merge pull request #2 from C3BI-pasteur-fr/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DamCorreia authored Jun 2, 2017
2 parents c479e58 + 9ccc3c8 commit 8bfd3a5
Show file tree
Hide file tree
Showing 70 changed files with 7,615 additions and 642 deletions.
25 changes: 21 additions & 4 deletions NGPhylogeny_fr/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
"""

import os
from galaxyconf import *

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

LOGIN_URL = '/account/login'
LOGIN_URL = '/galaxy/login'
LOGIN_REDIRECT_URL = '/'
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/
Expand All @@ -27,7 +26,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ["127.0.0.1",]

CRISPY_TEMPLATE_PACK = "bootstrap4"

Expand All @@ -44,6 +43,7 @@
'formtools',
'crispy_forms',
'account',
'galaxy',
'data',
'tools',
'workflows',
Expand Down Expand Up @@ -141,4 +141,21 @@
# Don't forget to use absolute paths, not relative paths.
os.path.join(BASE_DIR, 'static'),

)
)


LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': os.getenv('DJANGO_LOG_LEVEL', 'INFO'),
},
},
}
4 changes: 3 additions & 1 deletion NGPhylogeny_fr/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@

from account import urls as account_urls
from data import urls as data_urls
from galaxy import urls as galaxy_urls
from tools import urls as tool_urls
from workflows import urls as workflows_urls
from workspace import urls as workspace_urls

urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^admin/', admin.site.urls, name='admin'),
url(r'^documentation$', TemplateView.as_view(template_name="documentation.html"), name="documentation"),
url(r'^analysis$', TemplateView.as_view(template_name="phylogeny_analysis_choices.html"), name="analysis_list"),
url(r'^galaxy/', include(galaxy_urls)),
url(r'^account/', include(account_urls)),
url(r'^tools/', include(tool_urls)),
url(r'^data/', include(data_urls)),
Expand Down
47 changes: 0 additions & 47 deletions account/admin.py

This file was deleted.

53 changes: 0 additions & 53 deletions account/decorator.py

This file was deleted.

85 changes: 0 additions & 85 deletions account/models.py
Original file line number Diff line number Diff line change
@@ -1,85 +0,0 @@
from __future__ import unicode_literals

from django.db import models
from django.contrib.auth.models import User

from django.core.exceptions import ValidationError
from galaxylib import GalaxyInstance


class GalaxyServer(models.Model):
"""
Galaxy Server Informations
"""
name = models.CharField(max_length=80)
url = models.URLField(max_length=254, unique=True, null=False)
synopsis = models.CharField(max_length=254)
description = models.TextField(max_length=500)
contact = models.CharField(max_length=254)
version = models.CharField(max_length=9)

def __str__(self):

return "%s %s" %(self.name, self.url)


class GalaxyConf(models.Model):
"""
Model to setup Galaxy Configuration and manage activation of Galaxyserver
:galaxy_server: in GalaxyConf is used to Galaxy requests when status active is true.
"""
name = models.CharField(max_length=80,)
galaxy_server = models.ForeignKey(GalaxyServer, on_delete=models.CASCADE)
anonymous_user_api_access = models.BooleanField(default=False,
verbose_name="Enable Anonymous api?",
help_text="If True, Anonymous user must be set")
anonymous_user = models.OneToOneField('GalaxyUser', on_delete=models.CASCADE,
blank=True, null=True,
verbose_name="Global Anonymous User",
help_text="This User is used to make Galaxy requests for NGPhylogeny Anonymous Users")
active = models.BooleanField(default=False, verbose_name="Active Configuration?")

def clean(self,*args, **kwargs):
"""make anonymous_user as required field them anonymous_user_api_access is true"""
if self.anonymous_user_api_access == True and (not self.anonymous_user):
raise ValidationError({'anonymous_user': 'This field is required.',
})
if self.anonymous_user:
if not (self.anonymous_user.galaxy_server == self.galaxy_server):
raise ValidationError({'anonymous_user': 'Anonymous user must have the same Galaxy Server',
})
super(GalaxyConf,self).clean(*args, **kwargs)

def save(self, *args, ** kwargs):
if self.active is True:
"""One configuration can be actived"""
deactivated_config = GalaxyConf.objects.all()
deactivated_config.update(active=False)
super(GalaxyConf, self).save(*args, **kwargs)

def __unicode__(self):
return self.name


class GalaxyUser(models.Model):
"""
Model to save User APIkey from Galaxy
"""
user = models.ForeignKey(User, on_delete=models.CASCADE )
galaxy_server = models.ForeignKey(GalaxyServer, on_delete=models.CASCADE)
api_key = models.CharField(max_length=100, blank=True)

def get_galaxy_instance(self):
""":return bioblend Galaxy instance object
"""
if self.api_key:
return GalaxyInstance(url=self.galaxy_server.url, key=self.api_key)
else:
raise "API key must be set"

def __unicode__(self):
return self.user.username

class Meta:

unique_together = ['user','galaxy_server']
3 changes: 0 additions & 3 deletions account/tests.py

This file was deleted.

9 changes: 3 additions & 6 deletions account/urls.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@

from django.conf.urls import url
from django.contrib.auth.views import login, logout
from django.contrib.auth.decorators import login_required
from django.views.generic import TemplateView

from django.contrib.auth.views import login, logout

from views import *
from galaxy.views import *

urlpatterns = [
url(r'^login$', login, {'template_name': "account/login.html" }, name='login'),
url(r'logout$', logout, {'next_page': "/"}, name='logout'),
url(r'^$',login_required( GalaxyUserUpdateApiKey.as_view() ), name='account'),
url(r'^$', login_required(UpdateApiKey.as_view()), name='account'),
#url(r'^create_account/$', create_account),
#url(r'^success/$', TemplateView.as_view(template_name='success.html'))
]
3 changes: 0 additions & 3 deletions data/admin.py

This file was deleted.

5 changes: 0 additions & 5 deletions data/models.py

This file was deleted.

3 changes: 0 additions & 3 deletions data/tests.py

This file was deleted.

21 changes: 3 additions & 18 deletions data/urls.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
"""NGPhylogeny_fr URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.9/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.conf.urls import url, include
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from views import *

from account.decorator import connection_galaxy

from views import *

urlpatterns = [
url(r'^upload/$', UploadView.as_view(), name='upload'),

url(r'^display/(?P<file_id>[\w-]+)$', display_file, name="display_file"),
url(r'^displaytree/(?P<file_id>[\w-]+)$', tree_visualization, name="display_tree"),
url(r'^download/(?P<file_id>[\w-]+)$', download_file, name="download_file"),
url(r'^export_to_itol/(?P<file_id>[\w-]+)$', export_to_itol, name="export_to_itol"),
url(r'^export/(?P<file_id>[\w-]+)$', export_file, name="export_file"),
]
Loading

0 comments on commit 8bfd3a5

Please sign in to comment.