Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GeoInt_SIDT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
GeoInt_SIDT
Commits
60fb3c34
Commit
60fb3c34
authored
Mar 08, 2019
by
Ulises Morales Ramírez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
users
parent
1632f2fa
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
318 additions
and
167 deletions
+318
-167
administration_aside.html
administration/templates/administration_aside.html
+9
-0
dashboard.html
administration/templates/dashboard.html
+1
-1
Reports.html
reports/templates/Reports.html
+9
-0
aside.html
reports/templates/aside.html
+10
-0
User_profile.html
users/templates/User_profile.html
+78
-163
profile.html
users/templates/profile.html
+2
-0
users_aside.html
users/templates/users_aside.html
+9
-0
views.py
users/views.py
+200
-3
No files found.
administration/templates/administration_aside.html
View file @
60fb3c34
...
...
@@ -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
administration/templates/dashboard.html
View file @
60fb3c34
reports/templates/Reports.html
View file @
60fb3c34
...
...
@@ -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-->
...
...
reports/templates/aside.html
View file @
60fb3c34
...
...
@@ -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
users/templates/User_profile.html
View file @
60fb3c34
This diff is collapsed.
Click to expand it.
users/templates/profile.html
View file @
60fb3c34
...
...
@@ -71,5 +71,7 @@
<!-- /.box-body -->
</div>
<!-- /.box -->
<div><br></div>
</div>
{% endfor %}
\ No newline at end of file
users/templates/users_aside.html
View file @
60fb3c34
...
...
@@ -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
users/views.py
View file @
60fb3c34
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment