switch de publico

parent bca19837
from django.shortcuts import HttpResponseRedirect
from django.urls import reverse
# from django.core.urlresolvers import reverse
from catalog.models import Publics
......@@ -15,24 +14,13 @@ class AuthRequiredMiddleware(object):
# the view (and later middleware) are called.
response = self.get_response(request)
# if request.path_info == reverse('ws-news-list2'):
# return response
#publics = Publics.objects.all()
#print (publics)
if request.path_info == reverse('ipn'):
if "/reports/" in request.path_info and "/scl_data" in request.path_info:
print (request.path_info)
elif request.path_info == reverse('ipn'):
print(request.path_info)
elif not request.user.is_authenticated and request.path_info != reverse('login') and not request.user.is_active:
elif not request.user.is_authenticated and request.path_info != reverse('login') and not request.user.is_active:
return HttpResponseRedirect(reverse('login'))
#if not request.user.is_authenticated and request.path_info != reverse('login') and not request.user.is_active:
#if not request.user.is_authenticated or not request.user.is_active:
# return HttpResponseRedirect(reverse('login'))
# Code to be executed for each request/response after
# the view is called.
......
......@@ -44,6 +44,7 @@
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
<span class="sr-only">Toggle navigation</span>
</a>
{% if request.user.is_authenticated %}
<div class="navbar-custom-menu">
<ul class="nav navbar-nav">
<li>
......@@ -82,6 +83,7 @@
</li>
</ul>
</div>
{% endif %}
</nav>
</header>
<!-- Left side column. contains the logo and sidebar -->
......
......@@ -588,6 +588,7 @@ def IPN(request):
print()
f = open(PATH_USERS+"myfile.txt", "w")
x = request.POST.dict()
f.write('variables')
for key, value in x.items():
f.write(key+": "+value+'\n')
return redirect('../../')
......
......@@ -29,11 +29,18 @@ USERS_PATH = config['PATHS']['PATH_USERS']
###########################################################
def report_L2ASCL(request, report, purchase_id):
path = USERS_PATH + request.user.email + '/' + purchase_id + '/'
scl_data_path = USERS_PATH + request.user.email + "/" + purchase_id + "/" + report + ".json"
if not request.user.is_authenticated:
email = "user@algo.com"
print (email)
else:
email = request.user.email
path = USERS_PATH + email + '/' + purchase_id + '/'
scl_data_path = USERS_PATH + email + "/" + purchase_id + "/" + report + ".json"
with open(USERS_PATH + request.user.email + "/" + purchase_id + "/findProducts.json") as p:
with open(USERS_PATH + email + "/" + purchase_id + "/findProducts.json") as p:
dataProduct = json.load(p)
startDate = str(dataProduct['startDate'])[:4] + '-' + str(dataProduct['startDate'])[4:6] + '-' + str(
dataProduct['startDate'])[6:8]
......@@ -65,19 +72,19 @@ def report_L2ASCL(request, report, purchase_id):
reporteDir = report.replace('_sclData', '')
reporteDir += "/mask"
absolute_path = USERS_PATH + request.user.email + "/" + purchase_id + "/out"
absolute_path = USERS_PATH + email + "/" + purchase_id + "/out"
folders = os.listdir(absolute_path)
json_route = USERS_PATH + request.user.email + "/" + purchase_id + "/"
json_route = USERS_PATH + email + "/" + purchase_id + "/"
for file in os.listdir(json_route):
if file.endswith("_sclData.json") and not file.endswith("merge_out_sclData.json"):
with open(USERS_PATH + request.user.email + "/" + purchase_id + "/" + file) as f:
with open(USERS_PATH + email + "/" + purchase_id + "/" + file) as f:
json_data = OrderedDict(json.load(f))
if len(json_data) == 0:
if file[:6] in folders:
folders.remove(file[:6])
with open(USERS_PATH + request.user.email + "/" + purchase_id + "/" + report + ".json") as f:
with open(USERS_PATH + email + "/" + purchase_id + "/" + report + ".json") as f:
json_data = OrderedDict(json.load(f))
if len(json_data) == 0:
graphData = ""
......@@ -85,8 +92,8 @@ def report_L2ASCL(request, report, purchase_id):
defaultDataset = ""
folders.remove(reporteDir)
image_path = request.user.email + "/" + purchase_id + "/" + "out/" + reporteDir + "/TCI/thumbnails/"
SCL_path = request.user.email + "/" + purchase_id + "/" + "out/" + reporteDir + "/SCL/"
image_path = email + "/" + purchase_id + "/" + "out/" + reporteDir + "/TCI/thumbnails/"
SCL_path = email + "/" + purchase_id + "/" + "out/" + reporteDir + "/SCL/"
......
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