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
669d1777
Commit
669d1777
authored
May 09, 2019
by
Ulises Morales Ramírez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
descripcion reportes
parent
a5d4d557
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
364 additions
and
152 deletions
+364
-152
map.html
catalog/templates/map.html
+141
-135
views.py
catalog/views.py
+17
-3
Reports.css
reports/static/reports/css/Reports.css
+0
-5
scldata.css
reports/static/reports/css/scldata.css
+34
-0
scripts.js
users/static/users/js/scripts.js
+1
-0
profile.html
users/templates/profile.html
+107
-5
urls.py
users/urls.py
+1
-0
views.py
users/views.py
+63
-4
No files found.
catalog/templates/map.html
View file @
669d1777
This diff is collapsed.
Click to expand it.
catalog/views.py
View file @
669d1777
...
@@ -10,7 +10,7 @@ from django.http import HttpResponse, JsonResponse, HttpResponseRedirect
...
@@ -10,7 +10,7 @@ from django.http import HttpResponse, JsonResponse, HttpResponseRedirect
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.views.generic.base
import
View
from
django.views.generic.base
import
View
from
django.template
import
loader
,
RequestContext
from
django.template
import
loader
,
RequestContext
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
,
Permission
import
requests
,
json
,
unicodedata
,
sys
,
base64
import
requests
,
json
,
unicodedata
,
sys
,
base64
import
os
import
os
from
geosentinel
import
APISentinel
,
polygonToBox
from
geosentinel
import
APISentinel
,
polygonToBox
...
@@ -57,10 +57,17 @@ def map(request):
...
@@ -57,10 +57,17 @@ def map(request):
"""
"""
View function for home page of site.
View function for home page of site.
"""
"""
if
Permission
.
objects
.
filter
(
user
=
request
.
user
.
id
):
advanced_search
=
True
else
:
advanced_search
=
False
form
=
ASFSearchForm
(
request
.
POST
)
form
=
ASFSearchForm
(
request
.
POST
)
showcart
=
True
showcart
=
True
# Render the HTML template index.html with the data in the context variable
# Render the HTML template index.html with the data in the context variable
return
render
(
request
,
'map.html'
,
{
"searchForm"
:
form
,
"showcart"
:
showcart
})
return
render
(
request
,
'map.html'
,
{
"searchForm"
:
form
,
"showcart"
:
showcart
,
"advanced_search"
:
advanced_search
})
# -------------------------------------------------------------------------------
# -------------------------------------------------------------------------------
...
@@ -620,11 +627,18 @@ def Registration(request):
...
@@ -620,11 +627,18 @@ def Registration(request):
return
HttpResponse
(
"the username or password already exist"
)
return
HttpResponse
(
"the username or password already exist"
)
else
:
else
:
print
(
"agregado"
)
print
(
"agregado"
)
User
.
objects
.
create_user
(
first_name
=
request
.
POST
[
'name'
],
last_name
=
request
.
POST
[
'last_name'
],
username
=
request
.
POST
[
'username'
],
user
=
User
.
objects
.
create_user
(
first_name
=
request
.
POST
[
'name'
],
last_name
=
request
.
POST
[
'last_name'
],
username
=
request
.
POST
[
'username'
],
email
=
request
.
POST
[
'email'
],
email
=
request
.
POST
[
'email'
],
password
=
request
.
POST
[
'password'
],
is_active
=
False
)
password
=
request
.
POST
[
'password'
],
is_active
=
False
)
permissions
=
Permission
.
objects
.
filter
(
content_type__app_label
=
'auth'
,
codename__in
=
[
'advanced_search'
])
user
.
user_permissions
.
add
(
*
permissions
.
filter
(
content_type__model
=
'user'
))
message
=
"your registration is being processed"
message
=
"your registration is being processed"
subject
=
"Registro RepSat"
subject
=
"Registro RepSat"
wsMail2
(
request
.
POST
[
'email'
],
request
.
POST
[
'username'
],
message
,
subject
)
wsMail2
(
request
.
POST
[
'email'
],
request
.
POST
[
'username'
],
message
,
subject
)
messages
.
success
(
request
,
'your registration is being processed'
)
messages
.
success
(
request
,
'your registration is being processed'
)
return
HttpResponseRedirect
(
'login'
)
return
HttpResponseRedirect
(
'login'
)
reports/static/reports/css/Reports.css
View file @
669d1777
.map
{
height
:
400px
;
width
:
100%
;
}
.switch
{
.switch
{
position
:
relative
;
position
:
relative
;
display
:
inline-block
;
display
:
inline-block
;
...
...
reports/static/reports/css/scldata.css
View file @
669d1777
...
@@ -217,3 +217,37 @@ select::-ms-expand {
...
@@ -217,3 +217,37 @@ select::-ms-expand {
-o-transition
:
.25s
all
ease
;
-o-transition
:
.25s
all
ease
;
transition
:
.25s
all
ease
;
transition
:
.25s
all
ease
;
}
}
.arrow_box
{
position
:
relative
;
background
:
#ffffff
;
border
:
1px
solid
#ffa74f
;
min-height
:
30px
;
bottom
:
10px
;
}
.arrow_box
:after
,
.arrow_box
:before
{
top
:
100%
;
left
:
50%
;
border
:
solid
transparent
;
content
:
" "
;
height
:
0
;
width
:
0
;
position
:
absolute
;
pointer-events
:
none
;
}
.arrow_box
:after
{
border-color
:
rgba
(
255
,
255
,
255
,
0
);
border-top-color
:
#ffffff
;
border-width
:
10px
;
margin-left
:
-10px
;
}
.arrow_box
:before
{
border-color
:
rgba
(
255
,
167
,
79
,
0
);
border-top-color
:
#ffa74f
;
border-width
:
11px
;
margin-left
:
-11px
;
}
users/static/users/js/scripts.js
View file @
669d1777
...
@@ -45,3 +45,4 @@ $(document).ready(function () {
...
@@ -45,3 +45,4 @@ $(document).ready(function () {
order
:
[
1
,
'asc'
]
order
:
[
1
,
'asc'
]
});
});
});
});
users/templates/profile.html
View file @
669d1777
{% load staticfiles %}
{% load staticfiles %}
<style>
.switch
{
position
:
relative
;
display
:
inline-block
;
width
:
30px
;
height
:
17px
;
}
.switch
input
{
opacity
:
0
;
width
:
0
;
height
:
0
;
}
.slider
{
position
:
absolute
;
cursor
:
pointer
;
top
:
0
;
left
:
0
;
right
:
0
;
bottom
:
0
;
background-color
:
#ccc
;
-webkit-transition
:
.4s
;
transition
:
.4s
;
}
.slider
:before
{
position
:
absolute
;
content
:
""
;
height
:
13px
;
width
:
13px
;
left
:
4px
;
bottom
:
3px
;
background-color
:
white
;
-webkit-transition
:
.4s
;
transition
:
.4s
;
}
input
:checked
+
.slider
{
background-color
:
#f38e19
;
}
input
:focus
+
.slider
{
box-shadow
:
0
0
1px
#f38e19
;
}
input
:checked
+
.slider
:before
{
-webkit-transform
:
translateX
(
13px
);
-ms-transform
:
translateX
(
13px
);
transform
:
translateX
(
13px
);
}
/* Rounded sliders */
.slider.round
{
border-radius
:
14px
;
}
.slider.round
:before
{
border-radius
:
50%
;
}
</style>
<div
class=
"col-md-3"
>
<div
class=
"col-md-3"
>
{% for data in user_data %}
{% for data in user_data %}
...
@@ -30,6 +92,23 @@
...
@@ -30,6 +92,23 @@
<i
class=
"fa fa-pie-chart margin-r-5"
></i>
<b>
Disk usage
</b>
<a
<i
class=
"fa fa-pie-chart margin-r-5"
></i>
<b>
Disk usage
</b>
<a
class=
"pull-right"
>
{{ data.size }}
</a>
class=
"pull-right"
>
{{ data.size }}
</a>
</li>
</li>
<li
class=
"list-group-item"
>
<div
class=
"row ccontent "
>
<div
class=
"col-md-10 col-xs-10 col-lg-10 col-sm-10 col-xl-10"
>
<i
class=
"fa fa-search-plus margin-r-5"
></i>
<b>
Advanced Search
</b>
</div>
<div
class=
"col-md-2 col-xs-2 col-lg-2 col-sm-2 col-xl-2 pull-right"
>
<label
class=
"switch"
>
<input
class=
"pull-right"
id=
"{{ data.user_id }}"
type=
"checkbox"
onclick=
"change_permission({{ data.user_id }})"
{%
if
data
.
advanced_search =
=
True
%}
checked
{%
endif
%}
>
<span
class=
"slider round pull-right"
style=
"margin-right: 0px"
></span>
</label>
</div>
</div>
</li>
</ul>
</ul>
<!--a href="#" class="btn btn-primary btn-block"><b>Follow</b></a-->
<!--a href="#" class="btn btn-primary btn-block"><b>Follow</b></a-->
...
@@ -52,10 +131,10 @@
...
@@ -52,10 +131,10 @@
<div
class=
"box-body"
>
<div
class=
"box-body"
>
<ul
class=
"list-group list-group-unbordered"
>
<ul
class=
"list-group list-group-unbordered"
>
{% for data in user_searches %}
{% for data in user_searches %}
<li
class=
"list-group-item"
>
<li
class=
"list-group-item"
>
<i
class=
"fa fa-map-marker margin-r-5"
></i>
<b>
{{ data.search_name }}
</b>
<a
<i
class=
"fa fa-map-marker margin-r-5"
></i>
<b>
{{ data.search_name }}
</b>
<a
class=
"pull-right"
>
{{ data.count }}
</a>
class=
"pull-right"
>
{{ data.count }}
</a>
</li>
</li>
{% endfor %}
{% endfor %}
</ul>
</ul>
</div>
</div>
...
@@ -64,6 +143,29 @@
...
@@ -64,6 +143,29 @@
</div>
</div>
<!-- /.box -->
<!-- /.box -->
<div><br></div>
</div>
</div>
<script>
function
change_permission
(
user_id
)
{
var
checkBox
=
document
.
getElementById
(
user_id
);
if
(
checkBox
.
checked
==
true
)
{
permission
(
user_id
,
'True'
);
}
else
{
permission
(
user_id
,
'False'
);
}
}
function
permission
(
user_id
,
status
)
{
$
.
ajax
({
dataType
:
"json"
,
url
:
'ws/change_permission'
,
data
:
{
'user_id'
:
user_id
,
'status'
:
status
},
success
:
function
(
data
)
{
alert
(
data
);
}
});
}
</script>
\ No newline at end of file
users/urls.py
View file @
669d1777
...
@@ -27,5 +27,6 @@ urlpatterns = [
...
@@ -27,5 +27,6 @@ urlpatterns = [
url
(
r'^$'
,
views
.
Users
,
name
=
'users'
),
url
(
r'^$'
,
views
.
Users
,
name
=
'users'
),
url
(
r'^(?P<user_id>(\d+))/$'
,
views
.
User_id
,
name
=
'user_id'
),
url
(
r'^(?P<user_id>(\d+))/$'
,
views
.
User_id
,
name
=
'user_id'
),
url
(
r'^ws/report_table$'
,
views
.
wsPurchasesPM
,
name
=
'wsPurchasesPM'
),
url
(
r'^ws/report_table$'
,
views
.
wsPurchasesPM
,
name
=
'wsPurchasesPM'
),
url
(
r'^ws/change_permission'
,
views
.
wsChangePermission
,
name
=
'wsChangePermission'
),
]
]
# + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
# + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
users/views.py
View file @
669d1777
import
calendar
import
calendar
import
os
import
os
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
,
Permission
from
django.db.models
import
Count
from
django.db.models
import
Count
from
django.http
import
HttpResponse
,
Http404
from
django.http
import
HttpResponse
,
Http404
from
django.shortcuts
import
render
from
django.shortcuts
import
render
# Create your views here.
# Create your views here.
import
json
import
json
...
@@ -35,6 +36,15 @@ def Users(request):
...
@@ -35,6 +36,15 @@ def Users(request):
purchases
=
Purchase
.
objects
.
filter
(
user_id
=
user
.
id
)
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
)
if
Permission
.
objects
.
filter
(
user
=
user
.
id
):
advanced_search
=
True
else
:
advanced_search
=
False
print
(
advanced_search
)
#bytes_size = 0
#bytes_size = 0
#for path, directories, files in os.walk(USERS_PATH + "repsat_test_dev/" + user.email):
#for path, directories, files in os.walk(USERS_PATH + "repsat_test_dev/" + user.email):
# for filename in files:
# for filename in files:
...
@@ -50,11 +60,11 @@ def Users(request):
...
@@ -50,11 +60,11 @@ def Users(request):
"searches"
:
searches
.
count
(),
"searches"
:
searches
.
count
(),
"purchases"
:
purchases
.
count
(),
"purchases"
:
purchases
.
count
(),
"in_process"
:
in_process
.
count
(),
"in_process"
:
in_process
.
count
(),
#"size": size_repsat
,
"advanced_search"
:
advanced_search
,
})
})
for
search
in
Search
.
objects
.
values
(
'search_name'
)
.
filter
(
user_id
=
user
.
id
)
.
annotate
(
for
search
in
Search
.
objects
.
values
(
'search_name'
)
.
filter
(
user_id
=
user
.
id
)
.
annotate
(
count
=
Count
(
'search_name'
))
.
order_by
(
'-count'
)[:
6
]:
count
=
Count
(
'search_name'
))
.
order_by
(
'-count'
)[:
5
]:
user_searches
.
append
({
user_searches
.
append
({
"search_name"
:
search
[
'search_name'
],
"search_name"
:
search
[
'search_name'
],
"count"
:
search
[
'count'
],
"count"
:
search
[
'count'
],
...
@@ -173,7 +183,7 @@ def User_id(request, user_id):
...
@@ -173,7 +183,7 @@ def User_id(request, user_id):
})
})
for
search
in
Search
.
objects
.
values
(
'search_name'
)
.
filter
(
user_id
=
user
.
id
)
.
annotate
(
for
search
in
Search
.
objects
.
values
(
'search_name'
)
.
filter
(
user_id
=
user
.
id
)
.
annotate
(
count
=
Count
(
'search_name'
))
.
order_by
(
'-count'
)[:
6
]:
count
=
Count
(
'search_name'
))
.
order_by
(
'-count'
)[:
5
]:
user_searches
.
append
({
user_searches
.
append
({
"search_name"
:
search
[
'search_name'
],
"search_name"
:
search
[
'search_name'
],
"count"
:
search
[
'count'
],
"count"
:
search
[
'count'
],
...
@@ -338,3 +348,52 @@ def best_unit_size(bytes_size):
...
@@ -338,3 +348,52 @@ def best_unit_size(bytes_size):
return
str
(
round
(
bu_size
,
2
))
+
" "
+
unit
return
str
(
round
(
bu_size
,
2
))
+
" "
+
unit
# ------------------------------------------------
# ------------------------------------------------
@
csrf_exempt
def
wsChangePermission
(
request
):
if
request
.
is_ajax
():
table_data
=
[]
data
=
Purchase
.
objects
.
values
(
'user_id'
,
'search__endDate'
,
'search__startDate'
,
'aggreg_date'
,
'search__process_id__name'
,
'name'
)
.
filter
(
user_id
=
request
.
POST
.
get
(
'user_id'
),
purchased
=
True
,
aggreg_date__month
=
to_if
(
request
.
POST
.
get
(
'title'
)))
.
order_by
(
'aggreg_date'
)
for
producto
in
data
:
table_data
.
append
({
"search_name"
:
producto
[
'name'
],
"process"
:
producto
[
'search__process_id__name'
],
"purchase_date"
:
str
(
producto
[
'aggreg_date'
])[:
10
],
"startDate"
:
str
(
producto
[
'search__startDate'
])[:
10
],
"endDate"
:
str
(
producto
[
'search__endDate'
])[:
10
],
})
return
HttpResponse
(
json
.
dumps
(
table_data
))
# return HttpResponse({'table_data':table_data})
else
:
raise
Http404
pass
#----------------------------------------------
@
csrf_exempt
def
wsChangePermission
(
request
):
if
request
.
is_ajax
():
permissions
=
Permission
.
objects
.
filter
(
content_type__app_label
=
'auth'
,
codename__in
=
[
'advanced_search'
])
user
=
User
.
objects
.
get
(
pk
=
request
.
GET
.
get
(
"user_id"
))
if
request
.
GET
.
get
(
"status"
)
==
'True'
:
print
(
"verdadero"
)
user
.
user_permissions
.
add
(
*
permissions
.
filter
(
content_type__model
=
'user'
))
else
:
print
(
"falso"
)
user
.
user_permissions
.
remove
(
*
permissions
.
filter
(
content_type__model
=
'user'
))
return
HttpResponse
(
"hola"
)
else
:
raise
Http404
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