Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c524325f0a | ||
|
|
4a07ab80ce | ||
|
|
c8dead4457 |
@@ -60,6 +60,7 @@ class ServiceForm(forms.ModelForm):
|
|||||||
|
|
||||||
def clean_collaborators(self):
|
def clean_collaborators(self):
|
||||||
collaborators = []
|
collaborators = []
|
||||||
|
users_to_emails = {} # maps users to the email they are listed under as a collaborator
|
||||||
for collaborator_email in self.cleaned_data["collaborators"].split(","):
|
for collaborator_email in self.cleaned_data["collaborators"].split(","):
|
||||||
email = collaborator_email.strip()
|
email = collaborator_email.strip()
|
||||||
if email == "":
|
if email == "":
|
||||||
@@ -69,6 +70,10 @@ class ServiceForm(forms.ModelForm):
|
|||||||
).first()
|
).first()
|
||||||
if collaborator_email_linked is None:
|
if collaborator_email_linked is None:
|
||||||
raise forms.ValidationError(f"Email '{email}' is not registered")
|
raise forms.ValidationError(f"Email '{email}' is not registered")
|
||||||
|
user = collaborator_email_linked.user
|
||||||
|
if user in collaborators:
|
||||||
|
raise forms.ValidationError(f"The emails '{email}' and '{users_to_emails[user]}' both correspond to the same user")
|
||||||
|
users_to_emails[user] = email
|
||||||
collaborators.append(collaborator_email_linked.user)
|
collaborators.append(collaborator_email_linked.user)
|
||||||
return collaborators
|
return collaborators
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class DashboardView(LoginRequiredMixin, DateRangeMixin, TemplateView):
|
|||||||
data = super().get_context_data(**kwargs)
|
data = super().get_context_data(**kwargs)
|
||||||
data["services"] = Service.objects.filter(
|
data["services"] = Service.objects.filter(
|
||||||
Q(owner=self.request.user) | Q(collaborators__in=[self.request.user])
|
Q(owner=self.request.user) | Q(collaborators__in=[self.request.user])
|
||||||
)
|
).distinct()
|
||||||
for service in data["services"]:
|
for service in data["services"]:
|
||||||
service.stats = service.get_core_stats(data["start_date"], data["end_date"])
|
service.stats = service.get_core_stats(data["start_date"], data["end_date"])
|
||||||
return data
|
return data
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import urllib.parse as urlparse
|
|||||||
from django.contrib.messages import constants as messages
|
from django.contrib.messages import constants as messages
|
||||||
|
|
||||||
# Increment on new releases
|
# Increment on new releases
|
||||||
VERSION = "v0.6.4"
|
VERSION = "v0.6.5"
|
||||||
|
|
||||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|||||||
Reference in New Issue
Block a user