Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
c18d6f96
Commit
c18d6f96
authored
Sep 15, 2018
by
Florent Chehab
Browse files
Adding DRI module possible
parent
d3f940a2
Changes
7
Hide whitespace changes
Inline
Side-by-side
backend/permissions/__init__.py
View file @
c18d6f96
...
...
@@ -9,6 +9,7 @@ try:
from
.isStaffOrReadOnly
import
IsStaffOrReadOnly
# noqa: F401
from
.readOnly
import
ReadOnly
# noqa: F401
from
.isDriOrReadOnly
import
IsDriOrReadOnly
# noqa: F401
from
.isDriOrNoPost
import
IsDriOrNoPost
# noqa: F401
from
.default_viewset_permissions
import
DEFAULT_VIEWSET_PERMISSIONS
# noqa: F401
from
.__is_moderation_required
import
is_moderation_required
# noqa: F401
except
Exception
:
...
...
backend/permissions/isDriOrNoPost.py
0 → 100644
View file @
c18d6f96
from
rest_framework
import
permissions
from
backend.utils
import
is_member
class
IsDriOrNoPost
(
permissions
.
BasePermission
):
"""
TODO
"""
def
has_permission
(
self
,
request
,
view
):
if
request
.
method
==
'POST'
:
return
is_member
(
"DRI"
,
request
.
user
)
or
request
.
user
.
is_staff
return
True
backend/utils/__get_viewset_permissions.py
View file @
c18d6f96
from
backend.permissions
import
IsOwner
,
IsStaffOrReadOnly
,
IsDriOrReadOnly
,
ReadOnly
from
backend.permissions
import
IsOwner
,
IsStaffOrReadOnly
,
IsDriOrReadOnly
,
ReadOnly
,
IsDriOrNoPost
from
rest_framework.permissions
import
IsAdminUser
from
backend.permissions
import
DEFAULT_VIEWSET_PERMISSIONS
from
general.api
import
get_api_config
...
...
@@ -15,6 +15,8 @@ def get_viewset_permissions(viewset):
permission
=
(
IsStaffOrReadOnly
,)
elif
custom_permission
==
"IsDriOrReadOnly"
:
permission
=
(
IsDriOrReadOnly
,)
elif
custom_permission
==
"IsDriOrNoPost"
:
permission
=
(
IsDriOrNoPost
,)
elif
custom_permission
==
"IsStaff"
:
permission
=
(
IsAdminUser
,)
elif
custom_permission
==
'default'
:
...
...
frontend/src/components/university/modules/UniversityDri.js
View file @
c18d6f96
...
...
@@ -74,7 +74,17 @@ class UniversityDri extends MyComponent {
}
return
(
<
GenericGroupModule
groupTitle
=
{
"
Informations émanant de la DRI
"
}
>
<
GenericGroupModule
groupTitle
=
{
"
Informations émanant de la DRI
"
}
editor
=
{
UniversityDriEditor
}
invalidateGroup
=
{
this
.
props
.
invalidateData
}
propsForEditor
=
{{
modelData
:
{
universities
:
[
this
.
props
.
univId
],
importance_level
:
'
-
'
},
parseRawModelData
:
parseRawModelData
,
outsideData
:
outsideData
,
__apiAttr
:
this
.
props
.
univId
,
}}
>
{
univDriItems
.
map
((
rawModelData
)
=>
(
<
GenericModule
...
...
frontend/src/components/university/shared/GenericGroupModule.js
View file @
c18d6f96
import
React
from
'
react
'
;
import
PropTypes
from
'
prop-types
'
;
import
withStyles
from
'
@material-ui/core/styles/withStyles
'
;
import
compose
from
'
recompose/compose
'
;
import
{
connect
}
from
"
react-redux
"
;
import
Typography
from
'
@material-ui/core/Typography
'
;
import
Paper
from
'
@material-ui/core/Paper
'
;
import
Tooltip
from
'
@material-ui/core/Tooltip
'
;
...
...
@@ -13,7 +16,7 @@ import AddIcon from '@material-ui/icons/Add';
import
green
from
'
@material-ui/core/colors/green
'
;
import
MyComponent
from
'
../../MyComponent
'
;
const
styles
=
theme
=>
({
root
:
{
...
...
@@ -38,21 +41,52 @@ const styles = theme => ({
class
GenericGroupModule
extends
React
.
Component
{
class
GenericGroupModule
extends
MyComponent
{
state
=
{
editorOpen
:
false
,
};
handleOpenEditor
=
()
=>
{
this
.
setState
({
editorOpen
:
true
});
}
handleCloseEditor
=
(
somethingWasSaved
=
false
)
=>
{
this
.
setState
({
editorOpen
:
false
});
if
(
somethingWasSaved
)
{
this
.
props
.
invalidateGroup
();
}
};
render
()
{
const
{
classes
,
theme
,
groupTitle
}
=
this
.
props
;
return
(
<
Paper
className
=
{
classes
.
root
}
>
<
this
.
props
.
editor
{...
this
.
props
.
propsForEditor
}
open
=
{
this
.
state
.
editorOpen
}
handleCloseEditor
=
{
this
.
handleCloseEditor
}
userData
=
{
this
.
props
.
userDataEl
}
/
>
<
Grid
container
spacing
=
{
8
}
alignItems
=
'
center
'
>
<
Grid
item
xs
>
<
Typography
variant
=
'
title
'
align
=
'
center
'
color
=
"
textSecondary
"
><
em
>
{
groupTitle
}
<
/em></
Typography
>
<
/Grid
>
<
Grid
item
xs
=
{
2
}
style
=
{{
textAlign
:
'
right
'
}}
>
<
Tooltip
title
=
"
Ajouter un élément
"
placement
=
"
top
"
>
<
div
style
=
{{
display
:
'
inline-block
'
}}
>
{
/* Needed to fire events for the tooltip when below is disabled! */
}
<
Button
variant
=
'
fab
'
mini
aria
-
label
=
"
Ajouter un élément
"
disabled
=
{
false
}
style
=
{{
backgroundColor
:
green
.
A700
}}
className
=
{
classes
.
button
}
>
<
Button
variant
=
'
fab
'
mini
aria
-
label
=
"
Ajouter un élément
"
disabled
=
{
false
}
style
=
{{
backgroundColor
:
green
.
A700
}}
className
=
{
classes
.
button
}
onClick
=
{
this
.
handleOpenEditor
}
>
<
AddIcon
/>
<
/Button
>
<
/div
>
...
...
@@ -71,4 +105,23 @@ GenericGroupModule.propTypes = {
groupTitle
:
PropTypes
.
string
.
isRequired
,
};
export
default
withStyles
(
styles
,
{
withTheme
:
true
})(
GenericGroupModule
);
const
mapStateToProps
=
(
state
)
=>
{
return
{
userDataEl
:
state
.
userDataEl
};
};
const
mapDispatchToProps
=
(
dispatch
)
=>
{
return
{
fetchData
:
{
userDataEl
:
()
=>
dispatch
(
userDataElFetchData
(
""
)),
}
};
};
export
default
compose
(
withStyles
(
styles
,
{
withTheme
:
true
}),
connect
(
mapStateToProps
,
mapDispatchToProps
)
)(
GenericGroupModule
);
\ No newline at end of file
frontend/src/components/university/shared/GenericModule.js
View file @
c18d6f96
...
...
@@ -108,8 +108,6 @@ class GenericModule extends MyComponent {
}
})
}
};
handleCloseEditor
=
(
somethingWasSaved
=
false
)
=>
{
...
...
general/api/api_config.yml
View file @
c18d6f96
...
...
@@ -134,6 +134,7 @@
api_end_point
:
countryDri
api_attr
:
(?P<country_id>[a-zA-Z]+)
enforce_moderation_user_level
:
'
DRI'
viewset_permission
:
IsDriOrNoPost
versionned
:
true
...
...
@@ -179,6 +180,7 @@
api_end_point
:
universityDri
api_attr
:
(?P<univ_id>[0-9]+)
enforce_moderation_user_level
:
'
DRI'
viewset_permission
:
IsDriOrNoPost
versionned
:
true
...
...
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