File services.py
has 447 lines of code (exceeds 250 allowed). Consider refactoring. Open
from collections import OrderedDict
from datetime import date, timedelta
from django.db.models import Q
from django.utils import timezone
- Create a ticketCreate a ticket
Function event_permissions
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def event_permissions(member, event: Event, name=None, registration_prefetch=False):
"""Return a dictionary with the available event permissions of the user.
:param member: the user
:param event: the event
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function registration_status
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def registration_status(event: Event, registration: EventRegistration, member):
if not event.registration_required and not event.optional_registration_allowed:
return status.STATUS_NONE
if not member or not member.is_authenticated:
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function update_registration
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def update_registration(
member=None, event=None, name=None, registration=None, field_values=None, actor=None
):
"""Update a user registration of an event.
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function cancel_registration
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def cancel_registration(member, event):
"""Cancel a user registration for an event.
:param member: the user
:param event: the event
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function create_registration
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def create_registration(member, event):
"""Create a new user registration for an event.
:param member: the user
:param event: the event
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function registration_fields
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def registration_fields(request, member=None, event=None, registration=None, name=None):
"""Return information about the registration fields of a registration.
:param member: the user (optional if registration provided)
:param name: the name of a non member registration
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function update_registration_by_organiser
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def update_registration_by_organiser(registration, member, data):
if not is_organiser(member, registration.event):
raise RegistrationError(_("You are not allowed to update this registration."))
if "present" in data:
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function update_registration
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def update_registration(
- Create a ticketCreate a ticket
Function registration_fields
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def registration_fields(request, member=None, event=None, registration=None, name=None):
- Create a ticketCreate a ticket
Function is_eventdocument_owner
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def is_eventdocument_owner(member, event_doc):
if member and member.is_authenticated:
if member.is_superuser or member.has_perm("documents.override_owner"):
return True
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this function. Open
return status.STATUS_CANCELLED_LATE
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return status.STATUS_OPEN
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return status.STATUS_WAITINGLIST
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return status.STATUS_EXPIRED
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return False
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return status.STATUS_CANCELLED_FINAL
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return status.STATUS_OPTIONAL_REGISTERED
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return status.STATUS_FULL
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return status.STATUS_REGISTERED
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return status.STATUS_OPTIONAL
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return status.STATUS_CANCELLED
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return status.STATUS_WILL_OPEN
- Create a ticketCreate a ticket
Avoid too many return
statements within this function. Open
return False
- Create a ticketCreate a ticket
Function is_organiser
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def is_organiser(member, event):
if member and member.is_authenticated:
if member.is_superuser or member.has_perm("events.override_organiser"):
return True
- Read upRead up
- Create a ticketCreate a ticket
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"