Gitlab CSE Unil
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
M. Chardon
ADIM
Commits
2fdbac07
Commit
2fdbac07
authored
Mar 19, 2018
by
M. Chardon
Browse files
maj sur django 1.11
parent
9672d53f
Changes
11
Hide whitespace changes
Inline
Side-by-side
adim_project/adim/permissions.py
View file @
2fdbac07
...
...
@@ -53,7 +53,7 @@ class PermissionClass(object):
def
check_permission
(
self
,
request
,
anobj
):
user
=
request
.
user
# Anonymous users have no permissions
if
user
.
is_anonymous
()
:
if
user
.
is_anonymous
:
raise
PermissionDenied
()
# Owner can always access
...
...
adim_project/adim_app/urls.py
View file @
2fdbac07
...
...
@@ -3,24 +3,25 @@ from __future__ import unicode_literals
from
django.conf.urls
import
url
,
include
from
.views
import
home
,
upload_file
,
annotate_new
,
annotate
,
send_anobj_img
,
anobj_thumb
,
upload_anobj_thumb
,
\
suggest_users
,
essai
from
.
import
views
app_name
=
'adim_app'
urlpatterns
=
[
url
(
r
'^$'
,
home
,
name
=
"
home
"
),
url
(
r
'^new/$'
,
upload_file
,
name
=
'upload_file'
),
url
(
r
'^$'
,
views
.
home
,
name
=
'
home
'
),
url
(
r
'^new/$'
,
views
.
upload_file
,
name
=
'upload_file'
),
url
(
r
'^annotate/'
,
include
([
url
(
r
'^$'
,
annotate_new
,
name
=
"annotate-new"
),
url
(
r
'^$'
,
views
.
annotate_new
,
name
=
"annotate-new"
),
url
(
r
'^(?P<anobj_uuid>[0-9a-f]{6,32})/'
,
include
([
url
(
r
'^$'
,
annotate
,
name
=
"annotate"
),
url
(
r
'^image/$'
,
send_anobj_img
,
name
=
'ao_image'
),
url
(
r
'^thumb/$'
,
anobj_thumb
,
name
=
"ao_thumb"
),
url
(
r
'^u/$'
,
upload_anobj_thumb
)
url
(
r
'^$'
,
views
.
annotate
,
name
=
"annotate"
),
url
(
r
'^image/$'
,
views
.
send_anobj_img
,
name
=
'ao_image'
),
url
(
r
'^thumb/$'
,
views
.
anobj_thumb
,
name
=
"ao_thumb"
),
url
(
r
'^u/$'
,
views
.
upload_anobj_thumb
)
])),
]),
name
=
"annotate_base"
),
url
(
r
'^s/u/$'
,
suggest_users
,
name
=
'suggest-users'
),
url
(
r
'^s/u/$'
,
views
.
suggest_users
,
name
=
'suggest-users'
),
]
adim_project/adim_app/views.py
View file @
2fdbac07
...
...
@@ -40,10 +40,10 @@ def home(request):
:param request:
:return:
"""
cont
ext
=
{}
if
request
.
user
.
is_anonymous
()
:
context
[
'next'
]
=
request
.
GET
.
get
(
'next'
,
""
)
return
render
(
request
,
"adim/home.html"
,
context
)
n
ext
=
request
.
GET
.
get
(
'next'
,
""
)
if
request
.
user
.
is_anonymous
:
return
render
(
request
,
"adim/home.html"
,
{
'next'
:
next
}
)
return
render
(
request
,
"adim/home.html"
,
{}
)
def
handle_404
(
request
):
...
...
@@ -162,7 +162,7 @@ def annotate(request, anobj_uuid=None):
# ----- Login check. Not using decorator so we can delegate to Trusted Third Party if needed
permission
=
get_permission_class
(
anobj
.
sharing_mode
)
if
request
.
user
.
is_anonymous
()
:
if
request
.
user
.
is_anonymous
:
if
permission
and
permission
.
ttp
:
check_url
=
settings
.
ATTP
.
get
(
permission
.
ttp_id
,
{}).
get
(
'CHECK_URL'
)
return
HttpResponseRedirect
(
check_url
.
format
(
uuid
=
anobj
.
uuid
))
...
...
adim_project/adim_env/cimaf/urls.py
View file @
2fdbac07
...
...
@@ -5,6 +5,8 @@ from django.conf.urls import url, include
from
.views
import
analysis
app_name
=
'adim_env'
urlpatterns
=
[
url
(
r
'^analysis/(?P<anobj_uuid>[0-9a-f]{32})/'
,
...
...
adim_project/adim_project/apache/generate_config.py
View file @
2fdbac07
...
...
@@ -11,7 +11,6 @@ import django
from
django.conf
import
settings
from
django.template
import
Context
from
django.template.loader
import
get_template
from
django.utils
import
timezone
__TARGETS
=
(
'local'
,
'production'
,
'staging'
)
...
...
adim_project/adim_project/settings/base.py
View file @
2fdbac07
...
...
@@ -37,8 +37,7 @@ except ImportError:
DEBUG
=
False
ALLOWED_HOSTS
=
[]
ADMINS
=
(
(
"Julien Furrer"
,
'julien.furrer@unil.ch'
),
(
"Marion Chardon"
,
'marion.chardon@unil.ch'
),
(
"Admin Riset"
,
'riset-admin@unil.ch'
)
)
MANAGERS
=
ADMINS
...
...
@@ -65,19 +64,19 @@ TEMPLATES = [{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
'DIRS'
:
(
normpath
(
join
(
SITE_ROOT
,
'templates'
)),
),
'OPTIONS'
:
{
'debug'
:
False
,
'debug'
:
DEBUG
,
'loaders'
:
(
'django.template.loaders.filesystem.Loader'
,
'django.template.loaders.app_directories.Loader'
),
'context_processors'
:
[
'django.contrib.auth.context_processors.auth'
,
'django.
cor
e.context_processors.debug'
,
'django.
cor
e.context_processors.i18n'
,
'django.
cor
e.context_processors.media'
,
'django.
cor
e.context_processors.static'
,
'django.
cor
e.context_processors.request'
,
'django.
cor
e.context_processors.tz'
,
'django.
templat
e.context_processors.debug'
,
'django.
templat
e.context_processors.i18n'
,
'django.
templat
e.context_processors.media'
,
'django.
templat
e.context_processors.static'
,
'django.
templat
e.context_processors.request'
,
'django.
templat
e.context_processors.tz'
,
'django.contrib.messages.context_processors.messages'
,
'adim_utils.context_processors.default'
,
],
...
...
@@ -86,11 +85,11 @@ TEMPLATES = [{
}]
# backward compatibility
TEMPLATE_DIRS
=
TEMPLATES
[
0
][
'DIRS'
]
TEMPLATE_CONTEXT_PROCESSORS
=
TEMPLATES
[
0
][
'OPTIONS'
][
'context_processors'
]
TEMPLATE_DEBUG
=
TEMPLATES
[
0
][
'OPTIONS'
][
'debug'
]
TEMPLATE_LOADERS
=
TEMPLATES
[
0
][
'OPTIONS'
][
'loaders'
]
TEMPLATE_STRING_IF_INVALID
=
TEMPLATES
[
0
][
'OPTIONS'
][
'string_if_invalid'
]
#
TEMPLATE_DIRS = TEMPLATES[0]['DIRS']
#
TEMPLATE_CONTEXT_PROCESSORS = TEMPLATES[0]['OPTIONS']['context_processors']
#
TEMPLATE_DEBUG = TEMPLATES[0]['OPTIONS']['debug']
#
TEMPLATE_LOADERS = TEMPLATES[0]['OPTIONS']['loaders']
#
TEMPLATE_STRING_IF_INVALID = TEMPLATES[0]['OPTIONS']['string_if_invalid']
# ..... MEDIA AND STATICS PATHS
...
...
adim_project/adim_project/settings/local.py
View file @
2fdbac07
...
...
@@ -4,7 +4,7 @@ Settings for local development
from
.base
import
*
DEBUG
=
True
TEMPLATE_DEBUG
=
TEMPLATES
[
0
][
'OPTIONS'
][
'debug'
]
=
True
#
TEMPLATE_DEBUG = TEMPLATES[0]['OPTIONS']['debug'] = True
# update_urls('/adim-dev/', __name__)
...
...
adim_project/adim_project/settings/staging.py
View file @
2fdbac07
...
...
@@ -4,7 +4,7 @@ Settings for staging server
from
.base
import
*
DEBUG
=
True
TEMPLATE_DEBUG
=
TEMPLATES
[
0
][
'OPTIONS'
][
'debug'
]
=
True
#
TEMPLATE_DEBUG = TEMPLATES[0]['OPTIONS']['debug'] = True
update_urls
(
'/adim-dev/'
,
__name__
)
...
...
adim_project/adim_project/urls.py
View file @
2fdbac07
...
...
@@ -2,6 +2,8 @@ from django.conf.urls import include, url, static
from
django.conf
import
settings
from
django.contrib
import
admin
from
django.contrib.auth
import
views
admin
.
site
.
site_header
=
"ADIM - Site d'administration"
admin
.
site
.
site_title
=
"ADIM"
admin
.
site
.
index_title
=
"Administration"
...
...
@@ -9,23 +11,19 @@ admin.site.site_url = None
admin
.
autodiscover
()
urlpatterns
=
[
# Examples:
# url(r'^$', 'adim_project.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
# url(r'^admin/', include(admin.site.urls)),
url
(
r
'^s-412-5/admin/'
,
include
(
admin
.
site
.
urls
)),
# url(r'^admin/', include('django_trap.urls', namespace='django_trap')),
url
(
r
'^s-412-5/admin/'
,
admin
.
site
.
urls
),
url
(
r
'^shibauth/'
,
include
(
'shibauth.urls'
)),
url
(
r
'^accounts/login/$'
,
'django.contrib.auth.
views.login
'
,
{
'template_name'
:
"adim/home.html"
}),
url
(
r
'^accounts/logout/$'
,
'django.contrib.auth.views.logout_then_login'
,
name
=
"
logout
"
),
url
(
r
'^accounts/login/$'
,
views
.
login
,
{
'template_name'
:
"adim/home.html"
}
,
name
=
'django.contrib.auth.views.login'
),
url
(
r
'^accounts/logout/$'
,
views
.
logout
,
name
=
'
logout
'
),
url
(
r
'^api/'
,
include
(
'adim.urls'
)),
url
(
r
'^attp/'
,
include
(
'adim_ttp.urls'
)),
url
(
r
'^cimaf/'
,
include
(
'adim_env.cimaf.urls'
,
namespace
=
'adim.env.cimaf'
,
app_name
=
'adim_env'
)),
url
(
r
'^'
,
include
(
'adim_app.urls'
,
namespace
=
'
adim.app
'
,
app_name
=
'adim_app'
))
,
url
(
r
'^cimaf/'
,
include
(
'adim_env.cimaf.urls'
,
namespace
=
'adim.env.cimaf'
)),
url
(
r
'^'
,
include
(
'adim_app.urls'
,
namespace
=
"
adim.app
"
))
]
handler404
=
'adim_app.views.handle_404'
...
...
adim_project/adim_ttp/authentication.py
View file @
2fdbac07
...
...
@@ -3,7 +3,6 @@ from django.contrib.auth.models import User
from
django.db
import
IntegrityError
from
rest_framework.authentication
import
BaseAuthentication
from
rest_framework.exceptions
import
AuthenticationFailed
from
.utils
import
get_request_attp
...
...
@@ -116,7 +115,7 @@ def login_attp_user(request, attp_message, persist=True):
return
user
=
get_or_create_user
(
attp_user
)
if
request
.
user
.
is_anonymous
()
or
request
.
user
!=
user
:
if
request
.
user
.
is_anonymous
or
request
.
user
!=
user
:
if
persist
:
user
.
backend
=
'django.contrib.auth.backends.ModelBackend'
auth_login
(
request
,
user
)
...
...
adim_project/adim_ttp/views.py
View file @
2fdbac07
from
django.core.exceptions
import
PermissionDenied
from
django.views.decorators.clickjacking
import
xframe_options_exempt
from
django.http.response
import
HttpResponseRedirect
,
HttpResponse
,
HttpResponseForbidden
,
Http404
from
django.http.response
import
HttpResponseRedirect
,
Http404
from
django.core.urlresolvers
import
reverse
from
django.shortcuts
import
get_object_or_404
,
render
from
adim.models.annotables
import
AnObj
...
...
@@ -20,7 +19,7 @@ def login(request):
:param attp_hash:
:return:
"""
if
request
.
user
.
is_anonymous
()
:
if
request
.
user
.
is_anonymous
:
raise
Http404
()
token
,
_
=
Token
.
objects
.
get_or_create
(
user
=
request
.
user
)
return
render
(
request
,
"adim_ttp/logged.html"
,
context
=
{
'token'
:
token
})
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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