# Path: ctleweb/projtrack/models.py
# class Project(models.Model):
#     title = models.CharField(max_length=100)
#     description = models.CharField(max_length=500)
#     date = models.DateField(editable=False)
#     type = models.ForeignKey(Type, on_delete=models.CASCADE)
#     walk_in = models.BooleanField(default=False)
#     client = models.ForeignKey(Client, on_delete=models.CASCADE, blank=True, null=True)
#     users = models.ManyToManyField(User)
#     semester = models.ForeignKey(Semester, on_delete=models.CASCADE, blank=True, null=True)
#     hours = models.PositiveIntegerField(default=0)
#     completed = models.BooleanField(default=False)
# 
#     class Meta:
#         db_table = u'Project'
#         ordering = ['date']
# 
#     def __str__(self):
#         return self.title
# 
# class Client(models.Model):
#     first_name = models.CharField(max_length=100)
#     last_name = models.CharField(max_length=100)
#     email = models.CharField(max_length=100)
#     department = models.ForeignKey(Department,
#                                    on_delete=models.CASCADE)
# 
#     class Meta:
#         db_table = u'Client'
#         ordering = ['last_name']
# 
#     def __str__(self):
#         return str(self.last_name) + ", " + str(self.first_name)
# 
# class Department(models.Model):
#     name = models.CharField(max_length=100)
# 
#     class Meta:
#         db_table = u'Department'
#         ordering = ['name']
# 
#     def __str__(self):
#         return self.name
# 
# class Type(models.Model):
#     name = models.CharField(max_length=100)
# 
#     class Meta:
#         db_table = u'Type'
#         ordering = ['name']
# 
#     def __str__(self):
#         return self.name
# 
# class Semester(models.Model):
#     name = models.CharField(max_length=100)
# 
#     class Meta:
#         db_table = u'Semester'
#         ordering = ['name']
# 
#     def __str__(self):
#         return self.name
# 
# class CurrentSemester(models.Model):
#     semester = models.ForeignKey(Semester, on_delete=models.CASCADE)
# 
#     class Meta:
#         db_table = u'CurrentSemester'
# 
#     def __str__(self):
#         return str(self.semester)


import datetime
from django.contrib.auth.models import User
from rest_framework import serializers
from .models import Project, Client, Department, Type, Semester, CurrentSemester




class DepartmentSerializer(serializers.ModelSerializer):
    queryset = Department.objects.all()

    class Meta:
        model = Department
        fields = ('id', 'name')


class ClientSerializer(serializers.ModelSerializer):
    department = serializers.PrimaryKeyRelatedField(queryset=Department.objects.all())
    queryset = Client.objects.all()

    def create(self, validated_data):
        return Client.objects.create(**validated_data)

    class Meta:
        model = Client
        fields = ('id', 'first_name', 'last_name', 'email', 'department')


class TypeSerializer(serializers.ModelSerializer):

# Path: ctleweb/projtrack/models.py
# class Project(models.Model):
#     title = models.CharField(max_length=100)
#     description = models.CharField(max_length=500)
#     date = models.DateField(editable=False)
#     type = models.ForeignKey(Type, on_delete=models.CASCADE)
#     walk_in = models.BooleanField(default=False)
#     client = models.ForeignKey(Client, on_delete=models.CASCADE, blank=True, null=True)
#     users = models.ManyToManyField(User)
#     semester = models.ForeignKey(Semester, on_delete=models.CASCADE, blank=True, null=True)
#     hours = models.PositiveIntegerField(default=0)
#     completed = models.BooleanField(default=False)
# 
#     class Meta:
#         db_table = u'Project'
#         ordering = ['date']
# 
#     def __str__(self):
#         return self.title
# 
# class Client(models.Model):
#     first_name = models.CharField(max_length=100)
#     last_name = models.CharField(max_length=100)
#     email = models.CharField(max_length=100)
#     department = models.ForeignKey(Department,
#                                    on_delete=models.CASCADE)
# 
#     class Meta:
#         db_table = u'Client'
#         ordering = ['last_name']
# 
#     def __str__(self):
#         return str(self.last_name) + ", " + str(self.first_name)
# 
# class Department(models.Model):
#     name = models.CharField(max_length=100)
# 
#     class Meta:
#         db_table = u'Department'
#         ordering = ['name']
# 
#     def __str__(self):
#         return self.name
# 
# class Type(models.Model):
#     name = models.CharField(max_length=100)
# 
#     class Meta:
#         db_table = u'Type'
#         ordering = ['name']
# 
#     def __str__(self):
#         return self.name
# 
# class Semester(models.Model):
#     name = models.CharField(max_length=100)
# 
#     class Meta:
#         db_table = u'Semester'
#         ordering = ['name']
# 
#     def __str__(self):
#         return self.name
# 
# class CurrentSemester(models.Model):
#     semester = models.ForeignKey(Semester, on_delete=models.CASCADE)
# 
#     class Meta:
#         db_table = u'CurrentSemester'
# 
#     def __str__(self):
#         return str(self.semester)


# Path: ctleweb/projtrack/serializers.py
import datetime
from django.contrib.auth.models import User
from rest_framework import serializers
from .models import Project, Client, Department, Type, Semester, CurrentSemester





class DepartmentSerializer(serializers.ModelSerializer):
    queryset = Department.objects.all()

    class Meta:
        model = Department
        fields = ('id', 'name')


class ClientSerializer(serializers.ModelSerializer):
    department = serializers.PrimaryKeyRelatedField(queryset=Department.objects.all())
    queryset = Client.objects.all()

    def create(self, validated_data):
        return Client.objects.create(**validated_data)

    class Meta:
        model = Client
        fields = ('id', 'first_name', 'last_name', 'email', 'department')


class TypeSerializer(serializers.ModelSerializer):

    queryset = Type.objects.all()