Fakultas Ilmu Komputer UI

Commit b0d833f3 authored by Zamil Majdy's avatar Zamil Majdy
Browse files

[#140382397] #8 Add name on user

parent b8f2563e
......@@ -43,6 +43,10 @@ class Student(models.Model):
resume = models.FileField(upload_to=get_file_path, null=True, blank=True)
phone_number = models.CharField(max_length=100, blank=True, db_index=True)
@property
def name(self):
return get_display_name(self.user)
def __unicode__(self):
return u"Student {}".format(get_display_name(self.user))
......@@ -57,6 +61,10 @@ class Company(models.Model):
description = models.TextField()
verified = models.BooleanField(default=False)
@property
def name(self):
return get_display_name(self.user)
def __unicode__(self):
return u"Company {}".format(get_display_name(self.user))
......@@ -70,5 +78,9 @@ class Supervisor(models.Model):
user = models.OneToOneField(User)
nip = models.IntegerField(validators=[MinValueValidator(100000000), MaxValueValidator(9999999999)], unique=True)
@property
def name(self):
return get_display_name(self.user)
def __unicode__(self):
return u"Supervisor {}".format(get_display_name(self.user))
......@@ -11,18 +11,27 @@ class UserSerializer(serializers.HyperlinkedModelSerializer):
class StudentSerializer(serializers.ModelSerializer):
user = UserSerializer()
name = serializers.ReadOnlyField()
class Meta:
model = Student
fields = '__all__'
class CompanySerializer(serializers.ModelSerializer):
user = UserSerializer()
name = serializers.ReadOnlyField()
class Meta:
model = Company
fields = '__all__'
class SupervisorSerializer(serializers.ModelSerializer):
user = UserSerializer()
name = serializers.ReadOnlyField()
class Meta:
model = Supervisor
fields = '__all__'
\ No newline at end of file
fields = '__all__'
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment