Commit 6e7d6f2b authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[accounts][all] Pre-commit cleanup

parent c8028c46
Pipeline #42537 passed with stage
in 14 minutes and 58 seconds
......@@ -25,43 +25,35 @@
# #
###############################################################################
import datetime
from urllib.parse import urlparse
from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
from django.db.models import Q
from rest_framework import generics
from rest_framework import permissions
from rest_framework.response import Response
from rest_framework import status
from rest_framework.response import Response
from .serializers import FullSupervisionTrackSerializer
from .serializers import SupervisionTrackUpdateSerializer
from .serializers import UserSerializer
from ..common.responses import BadRequestResponse
from ..ui.registration.models import RegistrationProfile
from ..utils import mail
from .models import Profile
from .models import SupervisionTrack
from .models import TemporaryUrl
from .permissions import IsAuthorAndNotSupervisor
from .permissions import IsAuthorAndPossiblySupervisor
from .permissions import IsSuperUser
from .permissions import IsSupervisorAndAuthor
from .serializers import FullSupervisionTrackSerializer
from .serializers import SupervisionTrackUpdateSerializer
from .serializers import UserSerializer
from .views import accept_supervisee
from .views import emergency_rejection
from .views import perform_revalidation
from .views import supervisee_rejection
from .views import emergency_rejection
from ..ui.registration.models import RegistrationProfile
from ..utils import mail
from .permissions import (
IsSupervisorAndAuthor,
IsAuthorAndNotSupervisor,
IsAuthorAndPossiblySupervisor,
IsSuperUser,
)
from ..common.responses import BadRequestResponse
import datetime
from urllib.parse import urlparse
# ----------------------------------------------------------
......
......@@ -28,14 +28,17 @@
from django.apps import AppConfig
from django.utils.translation import ugettext_lazy as _
class AccountsConfig(AppConfig):
name = 'beat.web.accounts'
verbose_name = _('Accounts')
name = "beat.web.accounts"
verbose_name = _("Accounts")
def ready(self):
super(AccountsConfig, self).ready()
from django.contrib.auth.models import User
from actstream import registry
from django.contrib.auth.models import User
registry.register(User)
from .signals import setup_user
from .signals import setup_user # noqa Django signal registration
......@@ -26,14 +26,16 @@
###############################################################################
from django.forms import ModelForm
from .models import AccountSettings
class AccountSettingsForm(ModelForm):
class Meta:
model = AccountSettings
fields = [
'daily_summary',
'experiment_mail_notifications_enabled',
'database_notifications_enabled',
'environment_notifications_enabled',
"daily_summary",
"experiment_mail_notifications_enabled",
"database_notifications_enabled",
"environment_notifications_enabled",
]
......@@ -25,15 +25,15 @@
# #
###############################################################################
from django.db import models
import datetime
import random
import string
from django.conf import settings
from django.contrib.auth.models import User
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.conf import settings
import random
import string
import datetime
# ------------------------------------------------------------------------------
# Constants
......
......@@ -27,53 +27,59 @@
from rest_framework import permissions
#----------------------------------------------------------
# ----------------------------------------------------------
class IsSupervisorAndAuthor(permissions.BasePermission):
"""
The logged in user should also be the author
"""
message = 'Not a supervisor account'
message = "Not a supervisor account"
def has_permission(self, request, view):
return request.user.profile.is_supervisor or request.user.is_superuser
#----------------------------------------------------------
# ----------------------------------------------------------
class IsAuthorAndNotSupervisor(permissions.BasePermission):
"""
The logged in user should also be the author
"""
message = 'Not a supervisee account'
message = "Not a supervisee account"
def has_permission(self, request, view):
return not request.user.profile.is_supervisor
#----------------------------------------------------------
# ----------------------------------------------------------
class IsAuthorAndPossiblySupervisor(permissions.BasePermission):
"""
The logged in user should also be the author
"""
message = 'Not a supervisee account'
message = "Not a supervisee account"
def has_permission(self, request, view):
return not request.user.profile.is_supervisor or request.user.profile.is_supervisor
return (
not request.user.profile.is_supervisor or request.user.profile.is_supervisor
)
#----------------------------------------------------------
# ----------------------------------------------------------
class IsSuperUser(permissions.BasePermission):
"""
The logged in user should also be the author
"""
message = 'Not a supervisee account'
message = "Not a supervisee account"
def has_permission(self, request, view):
return request.user.is_superuser
......@@ -30,7 +30,6 @@ from rest_framework import serializers
from .models import SupervisionTrack
# ----------------------------------------------------------
......
......@@ -25,22 +25,17 @@
# #
###############################################################################
import django.dispatch
from actstream import action
from django.conf import settings
from django.contrib.auth.models import Group
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import User
from django.contrib.auth.models import Group
from django.conf import settings
from rest_framework.authtoken.models import Token
from actstream import action
from .models import AccountSettings
import django.dispatch
supervision_request = django.dispatch.Signal()
......
......@@ -25,32 +25,26 @@
# #
###############################################################################
from django.conf import settings
from django.shortcuts import render
from django.shortcuts import get_object_or_404
import datetime
from urllib.parse import urlparse
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import PasswordChangeForm
from django.contrib.auth.models import User
from django.contrib import messages
from django.db import models
from django.shortcuts import get_object_or_404
from django.shortcuts import render
from rest_framework.authtoken.models import Token
from ..utils import mail
from .forms import AccountSettingsForm
from .models import AccountSettings
from .models import SupervisionTrack
from .models import Profile
from .models import SupervisionTrack
from .models import TemporaryUrl
from ..utils import mail
import datetime
from urllib.parse import urlparse
@login_required
def account_settings(request):
......
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