-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from C3BI-pasteur-fr/dev
Dev
- Loading branch information
Showing
70 changed files
with
7,615 additions
and
642 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'] | ||
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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')) | ||
] |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | ||
] |
Oops, something went wrong.