Unverified Commit 2d3deff4 authored by Johannes Tomren Røsvik's avatar Johannes Tomren Røsvik
Browse files

Cognitive Complexity of functions should not be too high

parent e80fcaf3
Pipeline #79935 passed with stage
in 1 minute and 28 seconds
......@@ -32,18 +32,7 @@ def new_project(request):
project.save()
people = Profile.objects.filter(categories__id=project.category.id)
from django.core import mail
for person in people:
if person.user.email:
try:
with mail.get_connection() as connection:
mail.EmailMessage(
"New Project: " + project.title , "A new project you might be interested in was created and can be viwed at " + current_site.domain + '/projects/' + str(project.id), "Agreelancer", [person.user.email],
connection=connection,
).send()
except Exception as e:
from django.contrib import messages
messages.success(request, 'Sending of email to ' + person.user.email + " failed: " + str(e))
send_project_email(people, project, request, current_site)
task_title = request.POST.getlist('task_title')
task_description = request.POST.getlist('task_description')
......@@ -60,6 +49,20 @@ def new_project(request):
form = ProjectForm()
return render(request, 'projects/new_project.html', {'form': form})
def send_project_email(people, project, request, current_site):
from django.core import mail
for person in people:
if person.user.email:
try:
with mail.get_connection() as connection:
mail.EmailMessage(
"New Project: " + project.title , "A new project you might be interested in was created and can be viwed at " + current_site.domain + '/projects/' + str(project.id), "Agreelancer", [person.user.email],
connection=connection,
).send()
except Exception as e:
from django.contrib import messages
messages.success(request, 'Sending of email to ' + person.user.email + " failed: " + str(e))
def project_view(request, project_id):
project = Project.objects.get(pk=project_id)
......
Supports Markdown
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