Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
aottr committed Aug 5, 2024
1 parent 76078d1 commit 0a3751e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
15 changes: 14 additions & 1 deletion core/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.dispatch import receiver
from django.db.models.signals import post_save
from django.utils.translation import gettext_lazy as _
from django.conf import settings
from django.core.mail import send_mail
Expand Down Expand Up @@ -56,4 +58,15 @@ def send_mail(self, to_list: list[str], context):
print(f"Error sending email with type {type(e)}: {e}")

def __str__(self):
return f"{self.name} - [{self.event}]"
return f"{self.name} - [{self.event}]"

@receiver(post_save, sender=PawUser, dispatch_uid="new_user_notification")
def new_user_notification(sender, instance, created, **kwargs):
if not created or not instance.email:
return None

mail_template = MailTemplate.get_template('new_user', instance.language)
if not mail_template:
return None
mail_template.send_mail([instance.email], {
'username': instance.username, 'email': instance.email })
10 changes: 7 additions & 3 deletions paw/templates/ticketing/tickets.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
{% load i18n %}
<div class="w-full p-8">
<h1 class="flex items-center text-2xl text-base-content font-bold mb-4">{% trans 'Open Tickets' %}
{% if request.user.team_set.all %}
{% comment %} Print team names {% endcomment %}
{% if request.user.is_superuser %}
{% trans 'for' %}:
<span class="ml-2 badge badge-accent">{% trans 'Admin' %}</span>
{% elif request.user.team_set.all %}
{% trans 'for' %}:
{% for team in request.user.team_set.all %}
<span class="ml-2 badge badge-neutral">{{ team.name }}</span>
Expand All @@ -28,7 +32,7 @@ <h1 class="flex items-center text-2xl text-base-content font-bold mb-4">{% trans
</tr>
{% endif %}
{% for ticket in tickets %}
<tr>
<a href="{% url 'ticket_detail' ticket.id %}" class=""><tr>
<td><span class="badge badge-neutral">#{{ ticket.id }}</span></td>
<td>{{ ticket.title }}</td>
<td>
Expand All @@ -47,7 +51,7 @@ <h1 class="flex items-center text-2xl text-base-content font-bold mb-4">{% trans
{% include 'partials/ticket_status_badge.html' with ticket=ticket %}
</td>
<td class="flex justify-end"><a href="{% url 'ticket_detail' ticket.id %}" class="btn btn-xs btn-accent">{% trans 'View' %}</a></td>
</tr>
</tr></a>
{% endfor %}
</tbody>
</table>
Expand Down

0 comments on commit 0a3751e

Please sign in to comment.