Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with employment_certification fix, creation of Vacations, Users update to StaffNet, factories and Notifications #81

Merged
merged 59 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
edc7dfd
refactor: Update employment certification template
Heibert May 17, 2024
2dbfd81
Update the permissions to visualize the goals module, fix the order o…
S-e-b-a-s May 17, 2024
ba8b56a
Add vacation module
Heibert May 20, 2024
d6a31d8
test: project documentation
S-e-b-a-s May 20, 2024
350036a
basic project info
S-e-b-a-s May 20, 2024
ee52f53
enhancement: Update the frontend project documentation
S-e-b-a-s May 20, 2024
df09526
First frontend documentation final version
S-e-b-a-s May 21, 2024
8b33c3c
Add vacation module to settings and create her model
Heibert May 21, 2024
ef037d8
chore: Remove unused images and remove the used ones from gitignore a…
S-e-b-a-s May 21, 2024
b929bd6
Remove unnecessary copyright information
Heibert May 22, 2024
3fab0d6
feat: Add "goals.add_goals" permission to navbar
S-e-b-a-s May 22, 2024
c384867
Rename request_pdf field to request_file in VacationRequest model, ad…
Heibert May 23, 2024
81c5074
Another day working at cobra
Heibert May 24, 2024
3652256
Start back-end documentation
Heibert May 27, 2024
be8f892
feat: Start develop of vacation requests functionality
S-e-b-a-s May 27, 2024
5212ae5
This code change updates the ALLOWED_HOSTS configuration in the setti…
Heibert May 28, 2024
b6a7e3f
Fix bug with react router
S-e-b-a-s May 28, 2024
8af9af2
The admin warning of an error now is working, a lot of settings are c…
Heibert May 30, 2024
ac87a8b
Multiple changes in the code to delete me from the code, vacation mod…
Heibert May 31, 2024
4594fee
Correct the birthday section and adjust the vacationRequest component…
S-e-b-a-s May 31, 2024
bb6f447
Delete mi identification from the code and add the job_position to hi…
Heibert Jun 4, 2024
715877f
Adjust vacation modal interaction and dates collapse
S-e-b-a-s Jun 4, 2024
4b7801c
Add notifications app, and some checks to vacations
Heibert Jun 5, 2024
c7946e6
feat: Add employee selection and file upload functionality to vacatio…
S-e-b-a-s Jun 5, 2024
d2ae91b
Add extra check in admins emails, add notifications app, and some cha…
Heibert Jun 6, 2024
8be49d7
feat: Add notifications functionality and update NavBar component
S-e-b-a-s Jun 6, 2024
3802b21
feat: Add error handling and snack bar alerts to VacationsRequest com…
S-e-b-a-s Jun 7, 2024
1752720
Refactor vacation serializers and models for improved code organizati…
Heibert Jun 7, 2024
7923912
Refactor vacation serializers and models
Heibert Jun 11, 2024
9a445ae
Refactor handleError function and getApiUrl function to remove unnece…
S-e-b-a-s Jun 11, 2024
ab91f90
Add get-users endpoint for retrieving users based on user rank and area
Heibert Jun 12, 2024
d4fd8f1
Fix parameter order in the showSnack function in VacationRequest
S-e-b-a-s Jun 12, 2024
40f6a8b
Refactor create_notification function to improve parameter order and …
Heibert Jun 13, 2024
878d3c0
feat: Add vacations page and update navigation menu, also adjust the …
S-e-b-a-s Jun 13, 2024
eb4db74
Refactor get_full_name and get_full_name_reversed methods in User model
Heibert Jun 14, 2024
ac5dc58
Add a error message for the 401 error in the handleError function
S-e-b-a-s Jun 14, 2024
e97e8d5
Change the way the risk-events module is conditionally render
S-e-b-a-s Jun 17, 2024
10106be
Change the way the risk-events module is conditionally render
S-e-b-a-s Jun 17, 2024
49a20d1
Merge branch 'dev' of https://github.com/S-e-b-a-s/INSIGHTS into dev
S-e-b-a-s Jun 17, 2024
52317c7
Fixed bug in user test
Heibert Jun 18, 2024
0dec8e2
email multi-alternatives
Heibert Jun 19, 2024
85ac34a
feat: Add PowerBI page to the application
S-e-b-a-s Jun 19, 2024
f5db53b
Remove unused imports and code in payslip module
Heibert Jun 20, 2024
b8de0a7
chore: Remove commented out code for PQRS module in NavBar component
S-e-b-a-s Jun 20, 2024
83009fa
Improve to readme, fix bug in goals and emails
Heibert Jun 21, 2024
525ee8b
bug: add the data variable in the 200 response and add the .apiUrl pa…
S-e-b-a-s Jun 21, 2024
0b18d10
Add some test for vacations and add the different list versions
Heibert Jun 24, 2024
5609bec
Refactor vacation request filtering in list method
Heibert Jun 25, 2024
2629f95
add meta description
S-e-b-a-s Jun 25, 2024
a2256f7
Start of the users update to StaffNet
Heibert Jun 26, 2024
2bef555
Update user URLs and add profile endpoints that connect to StaffNet
Heibert Jun 27, 2024
441b00e
feat: Add PowerBI page and update home carousel images, adjust Vacati…
S-e-b-a-s Jun 27, 2024
bbd8dba
Update README.md
Heibert Jun 28, 2024
d36fc4f
Update file upload path for vacation requests, and add some test to v…
Heibert Jun 28, 2024
2c44ec2
Merge branch 'dev' of https://github.com/S-e-b-a-s/INSIGHTS into dev
Heibert Jun 28, 2024
cf1ac59
A lot of improvements for notifications, vacations, and users, also …
Heibert Jul 2, 2024
3af976c
Update API endpoint for getting employees in charge in VacationsReque…
S-e-b-a-s Jul 2, 2024
5e3d0d0
Remove job_title field from User model and related code, add some imp…
Heibert Jul 3, 2024
9825a8d
Refactor serializers to include user's cedula in EmploymentCertificat…
Heibert Jul 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ secure/
INSIGHTSAPI/static/admin/
INSIGHTSAPI/static/rest_framework/
public/
src/images/
test.html
test.pdf
*.pdf
Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"formulahendry.vscode-mysql"
]
}
110 changes: 105 additions & 5 deletions INSIGHTSAPI/INSIGHTSAPI/custom/custom_email_backend.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,109 @@

"""Custom Email Backend for Django using our own SMTP server"""
import sys
import ssl
import logging
from email.utils import formataddr
from smtplib import SMTP
from imaplib import IMAP4_SSL
from django.conf import settings
from django.core.mail.backends.smtp import EmailBackend
from django.core.mail import EmailMultiAlternatives


logger = logging.getLogger("requests")


class CustomEmailBackend(EmailBackend):
"""Custom Email Backend for Django using our own SMTP server"""

display_name = "INTRANET C&C"

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.outbox = []

def add_signature(self, message):
"""Add a signature to the email body depending on the content subtype, and add html alternatives if needed"""
html_signature = """
<table style="width: 100%; border-top: 1px solid #ccc; margin-top: 20px;">
<tr id="contact-info">
<td style="padding: 10px; width: 35%;">
<a href="https://cyc-bpo.com/">
<img src="https://raw.githubusercontent.com/CodeHive-Solutions/INSIGHTS/a79b9187f5eb34bf1e41111c9f957ed4f75842ba/INSIGHTSAPI/static/images/Logo_cyc_text.png" width="100%" alt="C&C SERVICES S.A.S">
</a>
</td>
<td style="padding: 20px;">
<strong>C&C SERVICES S.A.S</strong> <br>
https://cyc-bpo.com/ <br>
PBX: (601)7461166-Ext: 8081 <br>
Calle 19 #3-16 | Piso 3-CC Barichara <br>
Bogotá D.C.-Colombia
</td>
</tr>
<tr>
<td colspan="2" style="padding: 10px; font-size: 12px;">
<strong>Aviso de confidencialidad:</strong><br>
Este correo electrónico y cualquier archivo adjunto son confidenciales y pueden contener información privilegiada. Si usted no es el destinatario correcto, por favor notifique al remitente respondiendo este mensaje y elimine inmediatamente este correo electrónico y cualquier archivo adjunto de su sistema. Si está usted recibiendo este correo electrónico por error, no debe copiar este mensaje o divulgar su contenido a ninguna persona.
</td>
</tr>
<tr>
<td colspan="2" style="padding: 10px; font-size: 12px;">
Mensaje generado automáticamente, por favor no responder.
</td>
</tr>
</table>
"""

plain_signature = """
---
C&C SERVICES S.A.S
https://cyc-bpo.com/
PBX: (601)7461166-Ext: 8081
Calle 19 #3-16 | Piso 3-CC Barichara
Bogotá D.C.-Colombia

Aviso de confidencialidad:
Este correo electrónico y cualquier archivo adjunto son confidenciales y pueden contener información privilegiada. Si usted no es el destinatario correcto, por favor notifique al remitente respondiendo este mensaje y elimine inmediatamente este correo electrónico y cualquier archivo adjunto de su sistema. Si está usted recibiendo este correo electrónico por error, no debe copiar este mensaje o divulgar su contenido a ninguna persona.

Mensaje generado automáticamente, por favor no responder.
"""

if isinstance(message, EmailMultiAlternatives):
# Ensure HTML signature is added to the HTML alternative part
has_html_alternative = False
for i, (content, mime_type) in enumerate(message.alternatives):
if mime_type == "text/html":
message.alternatives[i] = (content + html_signature, mime_type)
has_html_alternative = True
if not has_html_alternative:
message.alternatives.append(
(message.body.replace("\n", "<br>") + html_signature, "text/html")
)
else:
# If no alternatives, ensure a plain text alternative is added
if message.content_subtype == "html":
message.alternatives = [
(message.body.replace("\n", "<br>") + html_signature, "text/html")
]
else:
message.alternatives = [
(message.body.replace("\n", "<br>") + html_signature, "text/html"),
(message.body, "text/plain"),
]

# Add the appropriate signature based on content_subtype
if message.content_subtype == "html":
message.body += html_signature
else:
message.body += plain_signature

# Ensure the message body is plain text if alternatives exist
if message.content_subtype == "html" and isinstance(
message, EmailMultiAlternatives
):
message.body = (
message.body.replace(html_signature, "").strip() + plain_signature
)

def open(self):
if self.connection:
return False
Expand All @@ -30,7 +120,7 @@ def open(self):
if not self.fail_silently:
raise e

# Override the send_messages method without changing his working
# Override the send_messages method without changing its functionality
def send_messages(self, email_messages):
if not email_messages:
return
Expand All @@ -44,14 +134,24 @@ def send_messages(self, email_messages):
num_sent = 0
for message in email_messages:
if ("test" in sys.argv or settings.DEBUG) and not (
all("heibert" in str(email).lower() or "juan.carreno" in str(email).lower() for email in message.to)
all(
"heibert.mogollon@cyc-bpo.com" in str(email).lower()
or "carreno" in str(email).lower()
or "diego.martinez.p@cyc-bpo.com" in str(email).lower()
for email in message.to
)
):

raise Exception(f"Email {message.to} not allowed in test mode")
self.add_signature(message)

message.from_email = formataddr((self.display_name, self.username))
sent = self._send(message)
if sent:
num_sent += 1
self.outbox.append(message)
self.save_to_sent_folder(message)
else:
print("Email not sent")

if new_conn_created:
self.close()
Expand Down
Loading