Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26,947 changes: 26,947 additions & 0 deletions lcc_web/get-pip.py

Large diffs are not rendered by default.

1,949 changes: 1,949 additions & 0 deletions lcc_web/logs/django.log

Large diffs are not rendered by default.

24 changes: 18 additions & 6 deletions lcc_web/web/LCCwebApp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
'django.contrib.messages',
'django.contrib.staticfiles',
'interface',
'graphos',
]

MIDDLEWARE = [
Expand Down Expand Up @@ -120,12 +119,16 @@


# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
# Provide sane defaults when DOCKYARD_* env vars are not set
_DEFAULT_DATA_DIR = os.environ.get(
"DOCKYARD_SRVDATA",
os.path.normpath(os.path.join(os.path.dirname(BASE_DIR), "data"))
)

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(os.environ["DOCKYARD_SRVDATA"], 'db.sqlite3'),
'NAME': os.path.join(_DEFAULT_DATA_DIR, 'db.sqlite3'),
}
}

Expand Down Expand Up @@ -170,12 +173,21 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/

_DEFAULT_SAMPLE_DIR = os.environ.get(
"DOCKYARD_SRVSAMPLE",
os.path.normpath(os.path.join(os.path.dirname(BASE_DIR), "sample_data"))
)
_DEFAULT_STATIC_ROOT = os.environ.get(
"DOCKYARD_SRVSTATIC",
os.path.normpath(os.path.join(BASE_DIR, "static_collected"))
)

# TODO: FTP server
MEDIA_ROOT = os.environ["DOCKYARD_SRVDATA"]
MEDIA_ROOT = _DEFAULT_DATA_DIR

TEST_SAMPLE = os.environ["DOCKYARD_SRVSAMPLE"]
TEST_SAMPLE = _DEFAULT_SAMPLE_DIR

STATIC_ROOT = os.environ["DOCKYARD_SRVSTATIC"]
STATIC_ROOT = _DEFAULT_STATIC_ROOT
# STATIC_URL = os.path.join(BASE_DIR, "interface", "static/")
STATIC_URL = "/static/"
if os.environ.get('DOCKYARD_APP_CONTEXT') is not None:
Expand Down
5 changes: 4 additions & 1 deletion lcc_web/web/LCCwebApp/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
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, include
try:
from django.conf.urls import url, include # Django 1.x compatibility
except ImportError:
from django.urls import re_path as url, include
from django.contrib import admin
import os

Expand Down
4 changes: 2 additions & 2 deletions lcc_web/web/interface/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class StarsFilter(models.Model):
id = models.AutoField(primary_key=True)
user = models.ForeignKey('auth.User')
user = models.ForeignKey('auth.User', on_delete=models.CASCADE)
status = models.CharField(default="Not started", max_length=15)
start_date = models.DateTimeField(
default=timezone.now)
Expand All @@ -19,7 +19,7 @@ class StarsFilter(models.Model):

class DbQuery(models.Model):
id = models.AutoField(primary_key=True)
user = models.ForeignKey('auth.User')
user = models.ForeignKey('auth.User', on_delete=models.CASCADE)
status = models.CharField(default="Not started", max_length=15)
start_date = models.DateTimeField(
default=timezone.now)
Expand Down
31 changes: 20 additions & 11 deletions lcc_web/web/interface/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import importlib
import interface.views as views
from django.conf.urls import url
from interface.lcc_views import jobs, searching, filtering, visualization
try:
from django.conf.urls import url # Django 1.x compatibility
except ImportError:
from django.urls import re_path as url

def _lazy(module_name, attr):
def _wrapped(*args, **kwargs):
module = importlib.import_module(module_name)
return getattr(module, attr)(*args, **kwargs)
return _wrapped

urlpatterns = [
url(r'^$', views.home, name='home'),
Expand All @@ -11,18 +20,18 @@
url(r'^logs', views.show_logs, name='show_logs'),
url(r'^login', views.login_view, name='login_view'),
url(r'^logout', views.logout_view, name='logout_view'),
url(r'^show', visualization.stars, name='show'),
url(r'^unsup', visualization.unsup_clust, name='unsup'),
url(r'^make_filter$', filtering.upload_form, name='make_filter'),
url(r'^show', _lazy('interface.lcc_views.visualization', 'stars'), name='show'),
url(r'^unsup', _lazy('interface.lcc_views.visualization', 'unsup_clust'), name='unsup'),
url(r'^make_filter$', _lazy('interface.lcc_views.filtering', 'upload_form'), name='make_filter'),
url(r'^delete/(?P<job_type>\D+)/(?P<job_id>\d+)',
views.delete_job, name='delete_job'),
url(r'^stars_filter/(?P<job_id>[a-zA-Z0-9]*)',
filtering.show, name='stars_filter'),
url(r'^search', searching.upload_form, name='search'),
url(r'^result/(?P<job_id>[a-zA-Z0-9]*)', searching.show, name='result'),
url(r'^stars_filters', jobs.all_filters, name='all_filters'),
url(r'^results*', jobs.all_results, name='all_results'),
url(r'^download/(?P<file_name>[a-zA-Z0-9]*)', jobs.download_file, name='download')]
_lazy('interface.lcc_views.filtering', 'show'), name='stars_filter'),
url(r'^search', _lazy('interface.lcc_views.searching', 'upload_form'), name='search'),
url(r'^result/(?P<job_id>[a-zA-Z0-9]*)', _lazy('interface.lcc_views.searching', 'show'), name='result'),
url(r'^stars_filters', _lazy('interface.lcc_views.jobs', 'all_filters'), name='all_filters'),
url(r'^results*', _lazy('interface.lcc_views.jobs', 'all_results'), name='all_results'),
url(r'^download/(?P<file_name>[a-zA-Z0-9]*)', _lazy('interface.lcc_views.jobs', 'download_file'), name='download')]


# run_workers(n_workers=int(os.environ.get("LCC_RQ_WORKERS", 1)))
27 changes: 18 additions & 9 deletions lcc_web/web/interface/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,39 @@
import os
import shutil

import pandas as pd
try:
import pandas as pd
except Exception:
pd = None
from django.conf import settings
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import UserCreationForm
from django.http import HttpResponse
from django.shortcuts import redirect
from django.shortcuts import render
from django.shortcuts import render_to_response
from django.template import RequestContext


from interface.forms import LoginForm
from interface.models import DbQuery
from interface.models import StarsFilter

pd.set_option('display.max_colwidth', -1)
if pd is not None:
try:
pd.set_option('display.max_colwidth', -1)
except Exception:
pass


# TODO
def handler404(request):
response = render_to_response('interface/404.html', {},
context_instance=RequestContext(request))
response = render(request, 'interface/404.html', {})
response.status_code = 404
return response


def handler500(request):
response = render_to_response('interface/500.html', {},
context_instance=RequestContext(request))
response = render(request, 'interface/500.html', {})
response.status_code = 500
return response

Expand Down Expand Up @@ -119,7 +122,13 @@ def guide(request):


def show_logs(request):
if request.user.is_authenticated():
try:
is_auth = request.user.is_authenticated
if callable(is_auth):
is_auth = is_auth()
except Exception:
is_auth = False
if is_auth:
groups = [g.name for g in request.user.groups.all()]
if "admin_gr" in groups:
log_file = request.GET.get('name')
Expand Down
2 changes: 1 addition & 1 deletion lcc_web/web/manage.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
import os
import sys

Expand Down