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
......@@ -10,7 +10,6 @@ from backend_app.models.abstract.my_model import (
class UserRestrictedModule(MyModel):
"""
TODO move to abstract folder ?
"""
# RGPD made easy with CASCADE
......@@ -27,9 +26,7 @@ class UserRestrictedModule(MyModel):
class UserRestrictedModuleSerializer(MyModelSerializer):
owner = serializers.HiddenField(
default=serializers.CurrentUserDefault()
) # TODO check that this works
owner = serializers.HiddenField(default=serializers.CurrentUserDefault())
class Meta:
model = UserRestrictedModule
......
......@@ -4,7 +4,8 @@ from backend_app.utils import is_member
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):
......
......@@ -4,7 +4,8 @@ from backend_app.utils import is_member
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):
......
......@@ -3,7 +3,7 @@ from rest_framework import permissions
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):
......
......@@ -5,7 +5,5 @@ from base_app.models import User
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.
TODO unit test
"""
return user.is_staff or is_member("DRI", user) or is_member("Moderators", user)
......@@ -6,7 +6,6 @@ from shared import OBJ_MODERATION_PERMISSIONS
def get_user_level(user: User) -> int:
"""
Returns the user level as int.
TODO unit test
"""
if user.is_staff:
return OBJ_MODERATION_PERMISSIONS["staff"]
......
......@@ -4,8 +4,6 @@ from base_app.models import User
def is_member(group_name: str, user: User) -> bool:
"""
Function to know if a user is part of a specific group.
TODO unit test
"""
return group_name in user.cached_groups
# before:
......
......@@ -16,8 +16,6 @@ else:
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"^user/login$", django_cas_ng.views.LoginView.as_view(), name="cas_ng_login"),
url(
......
import json
import re
from django.contrib.auth.models import Group
from django.http import HttpResponse
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):
"""
......
#OutGoing_REX
# REX-DRI
Django==2.1.7
psycopg2-binary==2.7.7
django-cas-ng==3.6.0
......@@ -21,3 +21,4 @@ django-webpack-loader==0.6.0
ipython==7.3.0 # For a better Django shell
black==18.9b0
flake8==3.7.6
flake8-todo==0.7 # Also lint TODO notes in python
......@@ -43,6 +43,13 @@ module.exports = {
],
"react/no-unescaped-entities": "off", // that one doesn't improve code readability
"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";
export const mainListItems = (
<>
<NavLink to={"/app/"} style={{ textDecoration: "none" }}>
{/* TODO add styling */}
<ListItem button>
<ListItemIcon>
<HomeIcon />
......
......@@ -10,7 +10,7 @@
*
*
*
* TODO
*
*
*
*
......
......@@ -10,7 +10,7 @@
*
*
*
* TODO
*
*
*
*
......@@ -64,7 +64,6 @@ class Filter extends CustomComponentForAPI {
// use of map to get only each country once
let res = new Map();
// TODO optimize: use maps instead of joinCampus
mainCampuses.forEach(campus => {
const country = this.joinCampus(campus).country,
code = country.iso_alpha2_code;
......
......@@ -37,7 +37,7 @@ export default {
if (possibleObjModeration.length > 1) {
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"}
{...this.getReferenceAndValue("obj_moderation_level")}
required={true}
......@@ -53,7 +53,6 @@ export default {
},
renderImportanceLevelField() {
//TODO change below use JSON
const options = [
{ "label": "Normal", "value": "-" },
{ "label": "Important", "value": "+" },
......
......@@ -35,7 +35,6 @@ class UnivMap extends Component {
*/
updateDimensions() {
try {
// TODO add a minimum height
const height = window.innerHeight - document.getElementById("MySuperMap").getBoundingClientRect().y;
this.setState({ height: Math.round(0.9 * height) });
}
......
......@@ -9,7 +9,7 @@
*
*
*
* TODO
*
*
*
*
......
......@@ -11,7 +11,7 @@ import ColorTools from "./ColorTools";
class Settings extends Component {
render() {
return (
<ColorTools /> //TODO fix backgroud
<ColorTools />
);
}
}
......
......@@ -35,7 +35,7 @@ class ScholarshipForm extends Form {
required: true,
label: "Présentation succincte",
maxLength: 200,
fieldMapping: "type",
fieldMapping: "short_description",
})}
{this.renderCurrencyField({ label: "Devise", required: false, fieldMapping: "currency" })}
{this.renderNumberField({
......
......@@ -22,7 +22,7 @@ const styles = theme => ({
});
function renderCore(rawModelData, classes, outsideData) {
const { comment, frequency, currency, type } = rawModelData;
const { comment, frequency, currency, short_description } = rawModelData;
const amountMin = rawModelData.amount_min,
amountMax = rawModelData.amount_max,
otherAdvantages = rawModelData.other_advantages;
......@@ -32,7 +32,7 @@ function renderCore(rawModelData, classes, outsideData) {
currency={currency}
currencies={outsideData.currencies}
frequency={frequency}
type={type}
shortDescription={short_description}
amountMin={amountMin}
amountMax={amountMax}
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