users

parent 1632f2fa
......@@ -28,5 +28,14 @@
</span>
</a>
</li>
<li>
<a class="treeview " href="#" onclick="window.history.back();">
<i class="fa fa-backward"></i>
<span>Back</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
</ul>
</div>
\ No newline at end of file
......@@ -126,6 +126,15 @@
</span>
</a>
</li>
<li>
<a class="treeview " href="#" onclick="window.history.back();">
<i class="fa fa-backward"></i>
<span>Back</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
</ul>
</div>
<!-- form-group-->
......
......@@ -10,6 +10,7 @@
</span>
</a>
</li>
<li class="treeview">
<a href="#">
<i class="fa fa-file-archive-o"></i>
......@@ -136,5 +137,14 @@
</li>
</ul>
</li>
<li>
<a class="treeview " href="#" onclick="window.history.back();">
<i class="fa fa-backward"></i>
<span>Back</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
</ul>
</div>
\ No newline at end of file
......@@ -125,10 +125,9 @@
<li class="active">User profile</li>
</ol>
</section>
<section class="content">
<div class="row">
<div class="row-fluid">
{% block profile %}
{% include 'profile.html' %}
{% endblock %}
......@@ -136,134 +135,48 @@
<div class="col-md-9">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active"><a href="#activity" data-toggle="tab">Activity</a></li>
<!--li><a href="#timeline" data-toggle="tab">Timeline</a></li>
<li><a href="#settings" data-toggle="tab">Settings</a></li-->
<li class="active"><a href="#timeline" data-toggle="tab">Most Recent</a></li>
<li><a href="#settings" data-toggle="tab">Settings</a></li>
</ul>
<div class="tab-content">
<div class="active tab-pane" id="activity">
<!-- Post -->
<div class="post">
<div class="user-block">
<img class="img-circle img-bordered-sm"
src="{% static 'users/images/user_default.png' %}"
alt="user image">
<span class="username">
<a href="#">Jonathan Burke Jr.</a>
<a href="#" class="pull-right btn-box-tool"><i class="fa fa-times"></i></a>
</span>
<span class="description">Shared publicly - 7:30 PM today</span>
</div>
<!-- /.user-block -->
<p>
Lorem ipsum represents a long-held tradition for designers,
typographers and the like. Some people hate it and argue for
its demise, but others ignore the hate as they create awesome
tools to help create filler text for everyone from bacon lovers
to Charlie Sheen fans.
</p>
</div>
<!-- /.post -->
</div>
<!-- /.tab-pane -->
<div class="tab-pane" id="timeline">
<div class="tab-content" style="height: 670px">
<div class=" active tab-pane" id="timeline" style="overflow-y:auto; ">
<!-- The timeline -->
<ul class="timeline timeline-inverse">
{% for product in productList|slice:":4" %}
<!-- timeline time label -->
<li class="time-label">
<span class="bg-red">
10 Feb. 2014
{{ product.purchase_date }}
</span>
</li>
<!-- /.timeline-label -->
<!-- timeline item -->
<li>
<i class="fa fa-envelope bg-blue"></i>
<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> 12:05</span>
<h3 class="timeline-header"><a href="#">Support Team</a> sent you an email</h3>
<div class="timeline-body">
Etsy doostang zoodles disqus groupon greplin oooj voxy zoodles,
weebly ning heekya handango imeem plugg dopplr jibjab, movity
jajah plickers sifteo edmodo ifttt zimbra. Babblely odeo kaboodle
quora plaxo ideeli hulu weebly balihoo...
</div>
<div class="timeline-footer">
<a class="btn btn-primary btn-xs">Read more</a>
<a class="btn btn-danger btn-xs">Delete</a>
</div>
</div>
</li>
<!-- END timeline item -->
<!-- timeline item -->
<li>
<i class="fa fa-user bg-aqua"></i>
<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> 5 mins ago</span>
<h3 class="timeline-header no-border"><a href="#">Sarah Young</a> accepted your
friend request
</h3>
</div>
</li>
<!-- END timeline item -->
<!-- timeline item -->
<!--li>
<i class="fa fa-comments bg-yellow"></i>
<i class="fa fa-cart-arrow-down bg-green-active"></i>
<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> 27 mins ago</span>
<span class="time">
{% if product.initial_folder != "." %}
Ready
{% else %}
In process
{% endif %}
</a>
</span>
<h3 class="timeline-header"><a href="#">Jay White</a> commented on your post
<h3 class="timeline-header no-border">You bought
<br>Process: <b>{{ product.process }}</b>
<br>Area: <b>{{ product.search_name }}</b>
<br>Size: <b>{{ product.size }}</b>
</h3>
<div class="timeline-body">
Take me to your leader!
Switzerland is small and neutral!
We are more like Germany, ambitious and misunderstood!
</div>
<div class="timeline-footer">
<a class="btn btn-warning btn-flat btn-xs">View comment</a>
</div>
</div>
</li-->
<!-- END timeline item -->
<!-- timeline time label -->
<li class="time-label">
<span class="bg-green">
3 Jan. 2014
</span>
</li>
<!-- /.timeline-label -->
<!-- timeline item -->
<li>
<i class="fa fa-camera bg-purple"></i>
<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> 2 days ago</span>
<h3 class="timeline-header"><a href="#">Mina Lee</a> uploaded new photos</h3>
{% endfor %}
<div class="timeline-body">
<img src="http://placehold.it/150x100" alt="..." class="margin">
<img src="http://placehold.it/150x100" alt="..." class="margin">
<img src="http://placehold.it/150x100" alt="..." class="margin">
<img src="http://placehold.it/150x100" alt="..." class="margin">
</div>
</div>
</li>
<!-- END timeline item -->
<li>
<i class="fa fa-clock-o bg-gray"></i>
</li>
</ul>
</div>
<!-- /.tab-pane -->
......@@ -331,12 +244,11 @@
<!-- /.col -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
<footer class=" page-footer font-small special-color-dark pt-5" style="bottom: 0; position: absolute">
<section>
<footer class=" page-footer font-small special-color-dark pt-5">
<!-- Footer Elements -->
<div class="container">
<!-- Social buttons
......@@ -379,6 +291,9 @@
</footer>
</section>
</div>
{% if messages %}
<div class="container col-md-2 col-lg-2 col-xs-2 col-sm-2" style="bottom: 0; right: 0;position: absolute">
{% for message in messages %}
......
......@@ -71,5 +71,7 @@
<!-- /.box-body -->
</div>
<!-- /.box -->
<div><br></div>
</div>
{% endfor %}
\ No newline at end of file
......@@ -28,5 +28,14 @@
</span>
</a>
</li-->
<li>
<a class="treeview " href="#" onclick="window.history.back();">
<i class="fa fa-backward"></i>
<span>Back</span>
<span class="pull-right-container">
<span class="label label-primary pull-right"></span>
</span>
</a>
</li>
</ul>
</div>
\ No newline at end of file
import os
from django.contrib.auth.models import User
from django.shortcuts import render
# Create your views here.
import json
from catalog.models import Search, Purchase
dirname = os.path.dirname(__file__)
configfile = os.path.join(dirname, '../config/config.json')
with open(configfile, 'r') as f:
config = json.load(f)
USERS_PATH = config['PATHS']['PATH_USERS']
#-------------------------------------------
def Users(request):
user_data = []
user_statics = []
......@@ -30,18 +39,110 @@ def Users(request):
"in_process": in_process.count(),
})
return render(request,'User_profile.html',{"user_data" : user_data} )
progress = 0
productList = []
size = 0
folders = []
zip = ""
product_list = Purchase.objects.values('id', 'productList', 'aggreg_date', 'search__clouds', 'search__startDate',
'search__endDate', 'search__process_id__name', 'search__search_name').filter(
user_id=request.user.id, purchased=1).order_by('-aggreg_date')
for producto in product_list:
log_info = USERS_PATH + request.user.email + "/" + str(producto['id']) + "/L2ASCL_AreaProcessing.log"
#####################################################
# progress bar #
#####################################################
if os.stat(log_info).st_size == 0:
progress = 0
else:
if 'Linking Products...' in open(log_info).read():
progress = 20
if 'Merging Images...' in open(log_info).read():
progress = 40
if 'Deleting Images...' in open(log_info).read():
progress = 50
if 'Extracting SCL information...' in open(log_info).read():
progress = 60
if 'Finalizing...' in open(log_info).read():
progress = 100
# item = Purchase.objects.filter(pk=producto['id'])
# item = Purchase.objects.get(pk=producto['id'])
# item.progress = progress
# item.save()
with open(log_info, 'r') as myfile:
log = myfile.read().replace('\n', '')
for p in json.loads(producto['productList']):
size = size + float(p['info']['size'][:-3])
if size > 1000:
size2 = size / 1000
final_size = str(round(size2, 2)) + " GB"
else:
final_size = str(round(size, 2)) + " MB"
initial_folder = "."
absolute_path = USERS_PATH + request.user.email + "/" + str(producto['id']) + "/out"
if not os.path.exists(absolute_path):
print("folder out noes not exists")
else:
folders = os.listdir(path=absolute_path)
print(folders)
if len(folders) == 0:
initial_folder = "../#"
else:
initial_folder = folders.pop(0) + "_sclData"
zip_path = USERS_PATH + request.user.email + "/" + str(producto['id'])
# print(zip_path)
# "../ static / reports / tmpImages / repsat_test_dev / umorales @ centrogeo.edu.mx / "+str(producto['id']) / myzip.zip"
wkt = USERS_PATH + request.user.email + "/" + str(producto['id']) + "/findProducts.json"
with open(wkt, 'r') as jsonfile:
polygon = json.load(jsonfile)
for file in os.listdir(path=zip_path):
if file.endswith(".zip"):
zip = zip_path + "/" + file
productList.append({
"search_name": producto['search__search_name'],
"process": producto['search__process_id__name'],
"purchase_date": producto['aggreg_date'],
"startDate": producto['search__startDate'],
"endDate": producto['search__endDate'],
"clouds": producto['search__clouds'],
"size": final_size,
"purchase_id": producto['id'],
"progress": progress,
"log_info": log,
"initial_folder": initial_folder,
"zip": zip,
"polygon": polygon['wkt'],
})
size = 0
final_size = 0
log_info = ""
progress = 0
initial_folder = ""
zip = ""
wkt = ""
return render(request,'User_profile.html',{"user_data" : user_data, "productList" : productList} )
#----------------------------------------------------------------------
def User_id(request,user_id):
user_data = []
user_statics = []
user = User.objects.get(pk=user_id)
searches = Search.objects.filter(user_id=user.id)
purchases = Purchase.objects.filter(user_id=user.id).order_by('aggreg_date')
purchases = Purchase.objects.filter(user_id=user.id)
in_process = Purchase.objects.filter(user_id=user.id).exclude(progress=100)
user_data.append({
"user_fullname": user.first_name+" "+user.last_name,
"searches": searches.count(),
......@@ -49,5 +150,101 @@ def User_id(request,user_id):
"in_process": in_process.count(),
})
user_statics.append({
"user_fullname": user.first_name + " " + user.last_name,
"searches": searches.count(),
"purchases": purchases.count(),
"in_process": in_process.count(),
})
progress = 0
productList = []
size = 0
folders = []
zip = ""
product_list = Purchase.objects.values('id', 'productList', 'aggreg_date', 'search__clouds', 'search__startDate',
'search__endDate', 'search__process_id__name', 'search__search_name').filter(
user_id=user.id, purchased=1).order_by('-aggreg_date')
for producto in product_list:
log_info = USERS_PATH + user.email + "/" + str(producto['id']) + "/L2ASCL_AreaProcessing.log"
#####################################################
# progress bar #
#####################################################
if os.stat(log_info).st_size == 0:
progress = 0
else:
if 'Linking Products...' in open(log_info).read():
progress = 20
if 'Merging Images...' in open(log_info).read():
progress = 40
if 'Deleting Images...' in open(log_info).read():
progress = 50
if 'Extracting SCL information...' in open(log_info).read():
progress = 60
if 'Finalizing...' in open(log_info).read():
progress = 100
# item = Purchase.objects.filter(pk=producto['id'])
# item = Purchase.objects.get(pk=producto['id'])
# item.progress = progress
# item.save()
with open(log_info, 'r') as myfile:
log = myfile.read().replace('\n', '')
for p in json.loads(producto['productList']):
size = size + float(p['info']['size'][:-3])
if size > 1000:
size2 = size / 1000
final_size = str(round(size2, 2)) + " GB"
else:
final_size = str(round(size, 2)) + " MB"
initial_folder = "."
absolute_path = USERS_PATH + user.email + "/" + str(producto['id']) + "/out"
if not os.path.exists(absolute_path):
print("folder out noes not exists")
else:
folders = os.listdir(path=absolute_path)
if len(folders) == 0:
initial_folder = "../#"
else:
initial_folder = folders.pop(0) + "_sclData"
zip_path = USERS_PATH + user.email + "/" + str(producto['id'])
# print(zip_path)
# "../ static / reports / tmpImages / repsat_test_dev / umorales @ centrogeo.edu.mx / "+str(producto['id']) / myzip.zip"
wkt = USERS_PATH + user.email + "/" + str(producto['id']) + "/findProducts.json"
with open(wkt, 'r') as jsonfile:
polygon = json.load(jsonfile)
for file in os.listdir(path=zip_path):
if file.endswith(".zip"):
zip = zip_path + "/" + file
productList.append({
"search_name": producto['search__search_name'],
"process": producto['search__process_id__name'],
"purchase_date": producto['aggreg_date'],
"startDate": producto['search__startDate'],
"endDate": producto['search__endDate'],
"clouds": producto['search__clouds'],
"size": final_size,
"purchase_id": producto['id'],
"progress": progress,
"log_info": log,
"initial_folder": initial_folder,
"zip": zip,
"polygon": polygon['wkt'],
})
size = 0
final_size = 0
log_info = ""
progress = 0
initial_folder = ""
zip = ""
wkt = ""
return render(request,'User_profile.html',{"user_data" : user_data} )
\ No newline at end of file
return render(request,'User_profile.html',{"user_data" : user_data, "productList" : productList} )
\ No newline at end of file
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