# Path: ctleweb/projtrack/models.py
# def get_name(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
# def create_auth_token(sender, instance=None, created=False, **kwargs):
# class Department(models.Model):
#     class Meta:
# class Client(models.Model):
#     class Meta:
# class Type(models.Model):
#     class Meta:
# class Semester(models.Model):
#     class Meta:
# class CurrentSemester(models.Model):
#     class Meta:
# class Project(models.Model):
#     class Meta:


import os
from datetime import datetime
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from .models import User, Project, Client, Semester, Department, Type

def check_type(proj):
    try:
        try:
            return list(Project.objects.filter(type=proj))
        except TypeError:
            return [Project.objects.filter(type=proj)]
    except ObjectDoesNotExist:
        return []


def generate_stats(report):
    hours = 0
    walk_ins = 0
    users = dict()
    projects = list(Project.objects.all())
    active = list(User.objects.filter(is_active=True))
    for x in report:
        hours += x.hours
        if x.walk_in:
            walk_ins += 1
    for x in active:
        proj = 0
        hour = 0
        for y in projects:
            if x in y.users.all():
                proj += 1
                hour += y.hours
        users[x.email] = {'projects': proj, 'hours': hour}
    depts = dict()

# Path: ctleweb/projtrack/models.py
# def get_name(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
# def create_auth_token(sender, instance=None, created=False, **kwargs):
# class Department(models.Model):
#     class Meta:
# class Client(models.Model):
#     class Meta:
# class Type(models.Model):
#     class Meta:
# class Semester(models.Model):
#     class Meta:
# class CurrentSemester(models.Model):
#     class Meta:
# class Project(models.Model):
#     class Meta:


# Path: ctleweb/projtrack/report_generator.py
import os
from datetime import datetime
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from .models import User, Project, Client, Semester, Department, Type


def check_type(proj):
    try:
        try:
            return list(Project.objects.filter(type=proj))
        except TypeError:
            return [Project.objects.filter(type=proj)]
    except ObjectDoesNotExist:
        return []


def generate_stats(report):
    hours = 0
    walk_ins = 0
    users = dict()
    projects = list(Project.objects.all())
    active = list(User.objects.filter(is_active=True))
    for x in report:
        hours += x.hours
        if x.walk_in:
            walk_ins += 1
    for x in active:
        proj = 0
        hour = 0
        for y in projects:
            if x in y.users.all():
                proj += 1
                hour += y.hours
        users[x.email] = {'projects': proj, 'hours': hour}
    depts = dict()

    for x in list(Department.objects.all()):