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

Move utillity function #612

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 21 additions & 1 deletion backend/organization/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,41 @@
from project.views import ProjectViewSet
from django.http import HttpRequest
import pandas as pd
from project.utils import send_mail_with_report
from transcript.models import Transcript
from translation.models import Translation
from voiceover.models import VoiceOver
from video.models import Video
from task.models import Task


def send_mail_with_report(subject, body, user, csv_file_path):
from_email = settings.DEFAULT_FROM_EMAIL
to_email = user.email
email = EmailMessage(subject, body, from_email, [to_email])
# Attach the CSV file to the email
email.attach_file(csv_file_path)

# Send the email
try:
email.send()
except:
logging.info("Unable to send Email.")
os.remove(csv_file_path)


def get_project_report_users(project_id, user):
data = ProjectViewSet(detail=True)
new_request = HttpRequest()
new_request.user = user
ret = data.get_report_users(new_request, project_id)
return ret.data

def get_project_report_languages(self, project_id, user):
data = ProjectViewSet(detail=True)
new_request = HttpRequest()
new_request.user = user
ret = data.get_report_languages(new_request, project_id)
return ret.data

def task_search_filter(videos, search_dict, filter_dict):
if search_dict is not None:
Expand Down
9 changes: 0 additions & 9 deletions backend/organization/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@
from translation.models import Translation
import json
from translation.metadata import TRANSLATION_LANGUAGE_CHOICES
from project.views import ProjectViewSet
from django.http import HttpRequest
from django.db.models import Q
import logging
import math
from django.db.models import Value
from django.db.models.functions import Concat
from .utils import *
from project.views import ProjectViewSet
from .tasks import *


Expand Down Expand Up @@ -622,13 +620,6 @@ def list_org_tasks(self, request, pk=None, *args, **kwargs):
status=status.HTTP_200_OK,
)

def get_project_report_languages(self, project_id, user):
data = ProjectViewSet(detail=True)
new_request = HttpRequest()
new_request.user = user
ret = data.get_report_languages(new_request, project_id)
return ret.data

@swagger_auto_schema(method="get", responses={200: "Success"})
@action(
detail=True,
Expand Down
Loading