Skip to content

Commit e4b47b3

Browse files
committed
Added contributors data in component details
1 parent 80f6292 commit e4b47b3

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

main/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def save(self, *args, **kwargs):
4646
if not self.id:
4747
self.created_time = timezone.now()
4848
if not self.url_name:
49-
self.url_name = (str(self.name).replace(' ', '-')).lower()
49+
self.url_name = (str(self.name).replace(' ', '-')).replace('/', '-').lower()
5050
return super(Component, self).save(*args, **kwargs)
5151

5252
def __unicode__(self):

main/serializers.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,11 @@ class Meta:
5252

5353
class DetailComponentSerializer(serializers.ModelSerializer):
5454
tags = serializers.SerializerMethodField()
55-
icon_url = serializers.SerializerMethodField()
5655
def get_tags(self, obj):
5756
tags = []
5857
for t in obj.tags.all():
5958
tags.append(t.name)
6059
return tags
61-
def get_icon_url(self, obj):
62-
if obj.icon:
63-
request = self.context.get('request')
64-
icon_url = obj.icon.url
65-
return request.build_absolute_uri(icon_url)
66-
else:
67-
return '#'
6860
class Meta:
6961
model = Component
7062
fields = (
@@ -106,8 +98,8 @@ class Meta:
10698
fields = ('username', 'avatar_url')
10799

108100
class ContributionSerializer(serializers.ModelSerializer):
109-
contributor = ContributorSerializer(required=True, write_only=True)
101+
contributor = ContributorSerializer(read_only=True)
110102

111103
class Meta:
112104
model = Contribution
113-
fields = ('contributor', 'contributions')
105+
fields = ('contributor', 'contributions', 'id')

0 commit comments

Comments
 (0)