users

parent 1632f2fa
...@@ -28,5 +28,14 @@ ...@@ -28,5 +28,14 @@
</span> </span>
</a> </a>
</li> </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> </ul>
</div> </div>
\ No newline at end of file
...@@ -194,7 +194,7 @@ ...@@ -194,7 +194,7 @@
<!-- /.info-box-content --> <!-- /.info-box-content -->
</div> </div>
<!-- /.info-box --> <!-- /.info-box -->
</div> </div>
<div class="col-md-2 col-sm-6 col-xs-12"> <div class="col-md-2 col-sm-6 col-xs-12">
<div class="info-box"> <div class="info-box">
......
...@@ -126,6 +126,15 @@ ...@@ -126,6 +126,15 @@
</span> </span>
</a> </a>
</li> </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> </ul>
</div> </div>
<!-- form-group--> <!-- form-group-->
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
</span> </span>
</a> </a>
</li> </li>
<li class="treeview"> <li class="treeview">
<a href="#"> <a href="#">
<i class="fa fa-file-archive-o"></i> <i class="fa fa-file-archive-o"></i>
...@@ -136,5 +137,14 @@ ...@@ -136,5 +137,14 @@
</li> </li>
</ul> </ul>
</li> </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> </ul>
</div> </div>
\ No newline at end of file
...@@ -125,10 +125,9 @@ ...@@ -125,10 +125,9 @@
<li class="active">User profile</li> <li class="active">User profile</li>
</ol> </ol>
</section> </section>
<section class="content"> <section class="content">
<div class="row"> <div class="row-fluid">
{% block profile %} {% block profile %}
{% include 'profile.html' %} {% include 'profile.html' %}
{% endblock %} {% endblock %}
...@@ -136,134 +135,48 @@ ...@@ -136,134 +135,48 @@
<div class="col-md-9"> <div class="col-md-9">
<div class="nav-tabs-custom"> <div class="nav-tabs-custom">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
<li class="active"><a href="#activity" data-toggle="tab">Activity</a></li> <li class="active"><a href="#timeline" data-toggle="tab">Most Recent</a></li>
<!--li><a href="#timeline" data-toggle="tab">Timeline</a></li> <li><a href="#settings" data-toggle="tab">Settings</a></li>
<li><a href="#settings" data-toggle="tab">Settings</a></li-->
</ul> </ul>
<div class="tab-content"> <div class="tab-content" style="height: 670px">
<div class="active tab-pane" id="activity"> <div class=" active tab-pane" id="timeline" style="overflow-y:auto; ">
<!-- 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">
<!-- The timeline --> <!-- The timeline -->
<ul class="timeline timeline-inverse"> <ul class="timeline timeline-inverse">
<!-- timeline time label --> {% for product in productList|slice:":4" %}
<li class="time-label"> <!-- timeline time label -->
<span class="bg-red"> <li class="time-label">
10 Feb. 2014 <span class="bg-red">
</span> {{ product.purchase_date }}
</li> </span>
<!-- /.timeline-label --> </li>
<!-- timeline item --> <!-- timeline item -->
<li> <li>
<i class="fa fa-envelope bg-blue"></i> <i class="fa fa-cart-arrow-down bg-green-active"></i>
<div class="timeline-item"> <div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> 12:05</span> <span class="time">
{% if product.initial_folder != "." %}
<h3 class="timeline-header"><a href="#">Support Team</a> sent you an email</h3> Ready
{% else %}
<div class="timeline-body"> In process
Etsy doostang zoodles disqus groupon greplin oooj voxy zoodles, {% endif %}
weebly ning heekya handango imeem plugg dopplr jibjab, movity </a>
jajah plickers sifteo edmodo ifttt zimbra. Babblely odeo kaboodle </span>
quora plaxo ideeli hulu weebly balihoo...
</div> <h3 class="timeline-header no-border">You bought
<div class="timeline-footer"> <br>Process: <b>{{ product.process }}</b>
<a class="btn btn-primary btn-xs">Read more</a> <br>Area: <b>{{ product.search_name }}</b>
<a class="btn btn-danger btn-xs">Delete</a> <br>Size: <b>{{ product.size }}</b>
</h3>
</div> </div>
</div> </li>
</li> {% endfor %}
<!-- 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>
<div class="timeline-item">
<span class="time"><i class="fa fa-clock-o"></i> 27 mins ago</span>
<h3 class="timeline-header"><a href="#">Jay White</a> commented on your post
</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>
<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> <li>
<i class="fa fa-clock-o bg-gray"></i> <i class="fa fa-clock-o bg-gray"></i>
</li> </li>
</ul> </ul>
</div> </div>
<!-- /.tab-pane --> <!-- /.tab-pane -->
...@@ -331,54 +244,56 @@ ...@@ -331,54 +244,56 @@
<!-- /.col --> <!-- /.col -->
</div> </div>
<!-- /.row --> <!-- /.row -->
</section> </section>
<!-- /.content --> <!-- /.content -->
</div> <section>
<footer class=" page-footer font-small special-color-dark pt-5" style="bottom: 0; position: absolute"> <footer class=" page-footer font-small special-color-dark pt-5">
<!-- Footer Elements --> <!-- Footer Elements -->
<div class="container"> <div class="container">
<!-- Social buttons <!-- Social buttons
<ul class="list-unstyled list-inline text-center"> <ul class="list-unstyled list-inline text-center">
<li class="list-inline-item"> <li class="list-inline-item">
<a class="btn-floating btn-fb mx-1"> <a class="btn-floating btn-fb mx-1">
<i class="fa fa-faceboo"> </i> <i class="fa fa-faceboo"> </i>
</a> </a>
</li> </li>
<li class="list-inline-item"> <li class="list-inline-item">
<a class="btn-floating btn-tw mx-1"> <a class="btn-floating btn-tw mx-1">
<i class="fa fa-twitter"> </i> <i class="fa fa-twitter"> </i>
</a> </a>
</li> </li>
<li class="list-inline-item"> <li class="list-inline-item">
<a class="btn-floating btn-gplus mx-1"> <a class="btn-floating btn-gplus mx-1">
<i class="fa fa-google-plus"> </i> <i class="fa fa-google-plus"> </i>
</a> </a>
</li> </li>
<li class="list-inline-item"> <li class="list-inline-item">
<a class="btn-floating btn-li mx-1"> <a class="btn-floating btn-li mx-1">
<i class="fa fa-linkedin"> </i> <i class="fa fa-linkedin"> </i>
</a> </a>
</li> </li>
<li class="list-inline-item"> <li class="list-inline-item">
<a class="btn-floating btn-dribbble mx-1"> <a class="btn-floating btn-dribbble mx-1">
<i class="fa fa-dribbble"> </i> <i class="fa fa-dribbble"> </i>
</a> </a>
</li> </li>
</ul> </ul>
<!-- Social buttons --> <!-- Social buttons -->
</div> </div>
<!-- Footer Elements --> <!-- Footer Elements -->
<!-- Copyright --> <!-- Copyright -->
<div class="footer-copyright text-center py-3">© 2019 Copyright: <div class="footer-copyright text-center py-3">© 2019 Copyright:
<a href="http://geoint.mx/"> Centro de Investigación en Ciencias de Información Geoespacial.</a> <a href="http://geoint.mx/"> Centro de Investigación en Ciencias de Información Geoespacial.</a>
</div> </div>
<!-- Copyright --> <!-- Copyright -->
</footer> </footer>
</section>
</div>
{% if messages %} {% if messages %}
<div class="container col-md-2 col-lg-2 col-xs-2 col-sm-2" style="bottom: 0; right: 0;position: absolute"> <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 %} {% for message in messages %}
......
...@@ -71,5 +71,7 @@ ...@@ -71,5 +71,7 @@
<!-- /.box-body --> <!-- /.box-body -->
</div> </div>
<!-- /.box --> <!-- /.box -->
<div><br></div>
</div> </div>
{% endfor %} {% endfor %}
\ No newline at end of file
...@@ -28,5 +28,14 @@ ...@@ -28,5 +28,14 @@
</span> </span>
</a> </a>
</li--> </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> </ul>
</div> </div>
\ No newline at end of file
import os
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.shortcuts import render from django.shortcuts import render
# Create your views here. # Create your views here.
import json
from catalog.models import Search, Purchase 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): def Users(request):
user_data = [] user_data = []
user_statics = [] user_statics = []
...@@ -30,18 +39,110 @@ def Users(request): ...@@ -30,18 +39,110 @@ def Users(request):
"in_process": in_process.count(), "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): def User_id(request,user_id):
user_data = [] user_data = []
user_statics = []
user = User.objects.get(pk=user_id) user = User.objects.get(pk=user_id)
searches = Search.objects.filter(user_id=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) in_process = Purchase.objects.filter(user_id=user.id).exclude(progress=100)
user_data.append({ user_data.append({
"user_fullname": user.first_name+" "+user.last_name, "user_fullname": user.first_name+" "+user.last_name,
"searches": searches.count(), "searches": searches.count(),
...@@ -49,5 +150,101 @@ def User_id(request,user_id): ...@@ -49,5 +150,101 @@ def User_id(request,user_id):
"in_process": in_process.count(), "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} ) return render(request,'User_profile.html',{"user_data" : user_data, "productList" : productList} )
\ No newline at end of file \ 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