Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c524325f0a | ||
|
|
4a07ab80ce | ||
|
|
c8dead4457 | ||
|
|
4a06357137 | ||
|
|
29ac82a91b | ||
|
|
fecea17a9d | ||
|
|
03062e3de5 |
@@ -14,7 +14,10 @@ EMAIL_HOST_USER=example
|
||||
EMAIL_HOST_PASSWORD=example_password
|
||||
EMAIL_HOST=smtp.example.com
|
||||
EMAIL_PORT=465
|
||||
SERVER_EMAIL=<Shynet> noreply@shynet.example.com
|
||||
EMAIL_USE_SSL=True
|
||||
# Comment out EMAIL_USE_SSL & uncomment EMAIL_USE_TLS if your SMTP server uses TLS.
|
||||
# EMAIL_USE_TLS=True
|
||||
SERVER_EMAIL=Shynet <noreply@shynet.example.com>
|
||||
|
||||
# General Django settings
|
||||
DJANGO_SECRET_KEY=random_string
|
||||
|
||||
@@ -60,6 +60,7 @@ class ServiceForm(forms.ModelForm):
|
||||
|
||||
def clean_collaborators(self):
|
||||
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(","):
|
||||
email = collaborator_email.strip()
|
||||
if email == "":
|
||||
@@ -69,6 +70,10 @@ class ServiceForm(forms.ModelForm):
|
||||
).first()
|
||||
if collaborator_email_linked is None:
|
||||
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)
|
||||
return collaborators
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class DashboardView(LoginRequiredMixin, DateRangeMixin, TemplateView):
|
||||
data = super().get_context_data(**kwargs)
|
||||
data["services"] = Service.objects.filter(
|
||||
Q(owner=self.request.user) | Q(collaborators__in=[self.request.user])
|
||||
)
|
||||
).distinct()
|
||||
for service in data["services"]:
|
||||
service.stats = service.get_core_stats(data["start_date"], data["end_date"])
|
||||
return data
|
||||
@@ -139,6 +139,9 @@ class ServiceSessionView(LoginRequiredMixin, PermissionRequiredMixin, DetailView
|
||||
context_object_name = "session"
|
||||
permission_required = "core.view_service"
|
||||
|
||||
def get_permission_object(self, **kwargs):
|
||||
return self.get_object().service
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
data = super().get_context_data(**kwargs)
|
||||
data["object"] = get_object_or_404(Service, pk=self.kwargs.get("pk"))
|
||||
|
||||
@@ -18,7 +18,7 @@ import urllib.parse as urlparse
|
||||
from django.contrib.messages import constants as messages
|
||||
|
||||
# Increment on new releases
|
||||
VERSION = "v0.6.2"
|
||||
VERSION = "v0.6.5"
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
@@ -279,7 +279,8 @@ else:
|
||||
EMAIL_PORT = int(os.environ.get("EMAIL_PORT", 465))
|
||||
EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER")
|
||||
EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD")
|
||||
EMAIL_USE_SSL = True
|
||||
EMAIL_USE_SSL = os.environ.get("EMAIL_USE_SSL")
|
||||
EMAIL_USE_TLS = os.environ.get("EMAIL_USE_TLS")
|
||||
|
||||
# NPM
|
||||
|
||||
|
||||
Reference in New Issue
Block a user