Skip to content

Commit

Permalink
Merge branch 'master' of gitlab.com:amfoss/cms
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithpabbati committed May 20, 2021
2 parents 7a4beff + ec97383 commit 1984674
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions activity/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class CollectionAdmin(ImportExportModelAdmin, ExportActionMixin, admin.ModelAdmi
('Basic Details', {
'fields': [
('name', 'author','date'),
('cover')
]
}),
]
Expand Down
7 changes: 6 additions & 1 deletion activity/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@ def __str__(self):
return self.name

class Collection(models.Model):
def get_collection_poster_path(self, filename):
ext = filename.split('.')[-1]
filename = "%s.%s" % (uuid.uuid4(), ext)
return 'static/uploads/collections/cover/' + filename
name = models.CharField(max_length=100)
author = models.ForeignKey(User, on_delete=models.PROTECT, related_name='Collection_Author', blank=True, null=True)
date = models.DateField(default=date.today)

cover = ProcessedImageField(default='', verbose_name='Collection Poster', upload_to=get_collection_poster_path, validators=[validate_file_size], **processed_image_field_specs)

class Meta:
verbose_name_plural = "Collections"
verbose_name = "Collection"
Expand Down
4 changes: 4 additions & 0 deletions activity/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class CollectionTagObj(graphene.ObjectType):
name = graphene.String()
author = graphene.Field(UserBasicObj)
date = graphene.Date(required=True)
cover = graphene.String(required=True)

def resolve_name(self, info):
return self['name']
Expand All @@ -30,6 +31,9 @@ def resolve_author(self, info):

def resolve_date(self, info):
return self['date']

def resolve_cover(self,info):
return self['cover']


class TagObj(graphene.ObjectType):
Expand Down

0 comments on commit 1984674

Please sign in to comment.