Commit 0e4c1aef authored by Florent Chehab's avatar Florent Chehab Committed by Florent Chehab
Browse files

removed(all TODOs):

Some of them were simply removed, oter were fixed.
From now on, the use of TODO is not permitted in the code.
parent 5530363c
Pipeline #36624 passed with stages
in 4 minutes and 54 seconds
...@@ -10,7 +10,6 @@ from backend_app.models.abstract.my_model import ( ...@@ -10,7 +10,6 @@ from backend_app.models.abstract.my_model import (
class UserRestrictedModule(MyModel): class UserRestrictedModule(MyModel):
""" """
TODO move to abstract folder ?
""" """
# RGPD made easy with CASCADE # RGPD made easy with CASCADE
...@@ -27,9 +26,7 @@ class UserRestrictedModule(MyModel): ...@@ -27,9 +26,7 @@ class UserRestrictedModule(MyModel):
class UserRestrictedModuleSerializer(MyModelSerializer): class UserRestrictedModuleSerializer(MyModelSerializer):
owner = serializers.HiddenField( owner = serializers.HiddenField(default=serializers.CurrentUserDefault())
default=serializers.CurrentUserDefault()
) # TODO check that this works
class Meta: class Meta:
model = UserRestrictedModule model = UserRestrictedModule
......
...@@ -4,7 +4,8 @@ from backend_app.utils import is_member ...@@ -4,7 +4,8 @@ from backend_app.utils import is_member
class IsDriOrNoPost(permissions.BasePermission): class IsDriOrNoPost(permissions.BasePermission):
""" """
TODO Permission to disallow POST to viewset if request user is not a
member of the DRI group or a staff.
""" """
def has_permission(self, request, view): def has_permission(self, request, view):
......
...@@ -4,7 +4,8 @@ from backend_app.utils import is_member ...@@ -4,7 +4,8 @@ from backend_app.utils import is_member
class IsDriOrReadOnly(permissions.BasePermission): class IsDriOrReadOnly(permissions.BasePermission):
""" """
TODO Permission to make a viewset readonly unless the request user
is a member of the DRI group or staff.
""" """
def has_permission(self, request, view): def has_permission(self, request, view):
......
...@@ -3,7 +3,7 @@ from rest_framework import permissions ...@@ -3,7 +3,7 @@ from rest_framework import permissions
class NoPostIfNotStaff(permissions.BasePermission): class NoPostIfNotStaff(permissions.BasePermission):
""" """
TODO Permission to allow POST request to a viewset only if the user is a member of the staff.
""" """
def has_permission(self, request, view): def has_permission(self, request, view):
......
...@@ -5,7 +5,5 @@ from base_app.models import User ...@@ -5,7 +5,5 @@ from base_app.models import User
def does_user_have_moderation_rights(user: User) -> bool: def does_user_have_moderation_rights(user: User) -> bool:
""" """
Function to know if a user is staff or member of DRI or member of the moderator group. Function to know if a user is staff or member of DRI or member of the moderator group.
TODO unit test
""" """
return user.is_staff or is_member("DRI", user) or is_member("Moderators", user) return user.is_staff or is_member("DRI", user) or is_member("Moderators", user)
...@@ -6,7 +6,6 @@ from shared import OBJ_MODERATION_PERMISSIONS ...@@ -6,7 +6,6 @@ from shared import OBJ_MODERATION_PERMISSIONS
def get_user_level(user: User) -> int: def get_user_level(user: User) -> int:
""" """
Returns the user level as int. Returns the user level as int.
TODO unit test
""" """
if user.is_staff: if user.is_staff:
return OBJ_MODERATION_PERMISSIONS["staff"] return OBJ_MODERATION_PERMISSIONS["staff"]
......
...@@ -4,8 +4,6 @@ from base_app.models import User ...@@ -4,8 +4,6 @@ from base_app.models import User
def is_member(group_name: str, user: User) -> bool: def is_member(group_name: str, user: User) -> bool:
""" """
Function to know if a user is part of a specific group. Function to know if a user is part of a specific group.
TODO unit test
""" """
return group_name in user.cached_groups return group_name in user.cached_groups
# before: # before:
......
...@@ -16,8 +16,6 @@ else: ...@@ -16,8 +16,6 @@ else:
urlpatterns = [] urlpatterns = []
urlpatterns += [ urlpatterns += [
# TODO remove this before going to full prod
url(r"^role_change/", views.role_change),
url(r"^admin/", admin.site.urls), url(r"^admin/", admin.site.urls),
url(r"^user/login$", django_cas_ng.views.LoginView.as_view(), name="cas_ng_login"), url(r"^user/login$", django_cas_ng.views.LoginView.as_view(), name="cas_ng_login"),
url( url(
......
import json
import re
from django.contrib.auth.models import Group
from django.http import HttpResponse
from django.shortcuts import render from django.shortcuts import render
from backend_app.utils import is_member
def role_change(request):
user = request.user
moderator_group = Group.objects.get(name="Moderators")
dri_group = Group.objects.get(name="DRI")
moderator_group.user_set.remove(user)
dri_group.user_set.remove(user)
path = request.path
if bool(re.search("dri", path)):
dri_group.user_set.add(user)
if bool(re.search("moderator", path)):
moderator_group.user_set.add(user)
role = "normal"
if is_member("DRI", user):
role = "DRI"
if is_member("Moderators", user):
role = "moderator"
return HttpResponse(json.dumps({"role_actuel": role}))
def index(request): def index(request):
""" """
......
#OutGoing_REX # REX-DRI
Django==2.1.7 Django==2.1.7
psycopg2-binary==2.7.7 psycopg2-binary==2.7.7
django-cas-ng==3.6.0 django-cas-ng==3.6.0
...@@ -21,3 +21,4 @@ django-webpack-loader==0.6.0 ...@@ -21,3 +21,4 @@ django-webpack-loader==0.6.0
ipython==7.3.0 # For a better Django shell ipython==7.3.0 # For a better Django shell
black==18.9b0 black==18.9b0
flake8==3.7.6 flake8==3.7.6
flake8-todo==0.7 # Also lint TODO notes in python
...@@ -43,6 +43,13 @@ module.exports = { ...@@ -43,6 +43,13 @@ module.exports = {
], ],
"react/no-unescaped-entities": "off", // that one doesn't improve code readability "react/no-unescaped-entities": "off", // that one doesn't improve code readability
"react/prop-types": "error", "react/prop-types": "error",
"react/no-deprecated": "error" "react/no-deprecated": "error",
"no-warning-comments": [
"error",
{
"terms": ["todo", "fixme", "any other term"],
"location": "anywhere"
}
]
} }
}; };
...@@ -18,7 +18,6 @@ import { NavLink } from "react-router-dom"; ...@@ -18,7 +18,6 @@ import { NavLink } from "react-router-dom";
export const mainListItems = ( export const mainListItems = (
<> <>
<NavLink to={"/app/"} style={{ textDecoration: "none" }}> <NavLink to={"/app/"} style={{ textDecoration: "none" }}>
{/* TODO add styling */}
<ListItem button> <ListItem button>
<ListItemIcon> <ListItemIcon>
<HomeIcon /> <HomeIcon />
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* *
* TODO *
* *
* *
* *
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* *
* TODO *
* *
* *
* *
...@@ -64,7 +64,6 @@ class Filter extends CustomComponentForAPI { ...@@ -64,7 +64,6 @@ class Filter extends CustomComponentForAPI {
// use of map to get only each country once // use of map to get only each country once
let res = new Map(); let res = new Map();
// TODO optimize: use maps instead of joinCampus
mainCampuses.forEach(campus => { mainCampuses.forEach(campus => {
const country = this.joinCampus(campus).country, const country = this.joinCampus(campus).country,
code = country.iso_alpha2_code; code = country.iso_alpha2_code;
......
...@@ -37,7 +37,7 @@ export default { ...@@ -37,7 +37,7 @@ export default {
if (possibleObjModeration.length > 1) { if (possibleObjModeration.length > 1) {
return ( return (
<> <>
<Typography variant='caption'>Niveau de modération souhaité (en plus TODO </Typography> <Typography variant='caption'>Niveau de modération supplémentaire souhaité</Typography>
<SelectField label={"Niveau de modération pour ce module"} <SelectField label={"Niveau de modération pour ce module"}
{...this.getReferenceAndValue("obj_moderation_level")} {...this.getReferenceAndValue("obj_moderation_level")}
required={true} required={true}
...@@ -53,7 +53,6 @@ export default { ...@@ -53,7 +53,6 @@ export default {
}, },
renderImportanceLevelField() { renderImportanceLevelField() {
//TODO change below use JSON
const options = [ const options = [
{ "label": "Normal", "value": "-" }, { "label": "Normal", "value": "-" },
{ "label": "Important", "value": "+" }, { "label": "Important", "value": "+" },
......
...@@ -35,7 +35,6 @@ class UnivMap extends Component { ...@@ -35,7 +35,6 @@ class UnivMap extends Component {
*/ */
updateDimensions() { updateDimensions() {
try { try {
// TODO add a minimum height
const height = window.innerHeight - document.getElementById("MySuperMap").getBoundingClientRect().y; const height = window.innerHeight - document.getElementById("MySuperMap").getBoundingClientRect().y;
this.setState({ height: Math.round(0.9 * height) }); this.setState({ height: Math.round(0.9 * height) });
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* *
* TODO *
* *
* *
* *
......
...@@ -11,7 +11,7 @@ import ColorTools from "./ColorTools"; ...@@ -11,7 +11,7 @@ import ColorTools from "./ColorTools";
class Settings extends Component { class Settings extends Component {
render() { render() {
return ( return (
<ColorTools /> //TODO fix backgroud <ColorTools />
); );
} }
} }
......
...@@ -35,7 +35,7 @@ class ScholarshipForm extends Form { ...@@ -35,7 +35,7 @@ class ScholarshipForm extends Form {
required: true, required: true,
label: "Présentation succincte", label: "Présentation succincte",
maxLength: 200, maxLength: 200,
fieldMapping: "type", fieldMapping: "short_description",
})} })}
{this.renderCurrencyField({ label: "Devise", required: false, fieldMapping: "currency" })} {this.renderCurrencyField({ label: "Devise", required: false, fieldMapping: "currency" })}
{this.renderNumberField({ {this.renderNumberField({
......
...@@ -22,7 +22,7 @@ const styles = theme => ({ ...@@ -22,7 +22,7 @@ const styles = theme => ({
}); });
function renderCore(rawModelData, classes, outsideData) { function renderCore(rawModelData, classes, outsideData) {
const { comment, frequency, currency, type } = rawModelData; const { comment, frequency, currency, short_description } = rawModelData;
const amountMin = rawModelData.amount_min, const amountMin = rawModelData.amount_min,
amountMax = rawModelData.amount_max, amountMax = rawModelData.amount_max,
otherAdvantages = rawModelData.other_advantages; otherAdvantages = rawModelData.other_advantages;
...@@ -32,7 +32,7 @@ function renderCore(rawModelData, classes, outsideData) { ...@@ -32,7 +32,7 @@ function renderCore(rawModelData, classes, outsideData) {
currency={currency} currency={currency}
currencies={outsideData.currencies} currencies={outsideData.currencies}
frequency={frequency} frequency={frequency}
type={type} shortDescription={short_description}
amountMin={amountMin} amountMin={amountMin}
amountMax={amountMax} amountMax={amountMax}
otherAdvantages={otherAdvantages} otherAdvantages={otherAdvantages}
......
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