Skip to content

Commit

Permalink
fixed issues #35, #33, #32, #30, #29 (#38)
Browse files Browse the repository at this point in the history
* added functionality to format youtube video url to embedable format

* made video url optional

* switched image upload location from cloudinary to digital ocean spaces

* added functionality to automatically delete image from digitalocean space once image is deleted from db

* added image count indicator and made video optional. also added project create button to navbar

* removed .ssl from git

* untracked .ssl-data

* added support for various forms of youtube video url, vimeo and google drive

* fixed issues #35, #33, #32, #30, #29
  • Loading branch information
NdibeRaymond authored Dec 23, 2020
1 parent ab5f381 commit 0af71e5
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 171 deletions.
2 changes: 1 addition & 1 deletion zubhub_backend/zubhub/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Project(models.Model):
title = models.CharField(max_length=1000)
description = models.CharField(max_length=10000, blank=True, null=True)
video = models.URLField(max_length=1000, blank=True, null=True)
materials_used = models.CharField(max_length=10000)
materials_used = models.CharField(max_length=5000)
views = models.ManyToManyField(
Creator, blank=True, related_name="projects_viewed")
views_count = models.IntegerField(blank=True, default=0)
Expand Down
16 changes: 15 additions & 1 deletion zubhub_backend/zubhub/projects/serializers.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from django.contrib.auth import get_user_model
from creators.serializers import CreatorSerializer
Expand Down Expand Up @@ -40,8 +41,9 @@ class ProjectSerializer(serializers.ModelSerializer):
saved_by = serializers.SlugRelatedField(
many=True, slug_field='id', read_only=True)
comments = CommentSerializer(many=True, read_only=True)
images = ImageSerializer(many=True)
images = ImageSerializer(many=True, required=False)
created_on = serializers.DateTimeField(read_only=True)
views_count = serializers.IntegerField(read_only=True)

class Meta:
model = Project
Expand All @@ -60,6 +62,18 @@ class Meta:
"created_on",
]

def validate_video(self, video):
if(video == "" and len(self.initial_data.get("images")) == 0):
raise serializers.ValidationError(
_("you must provide either image(s) or video url"))
return video

def validate_images(self, images):
if(len(images) == 0 and len(self.initial_data["video"]) == 0):
raise serializers.ValidationError(
_("you must provide either image(s) or video url"))
return images

def create(self, validated_data):
images_data = validated_data.pop('images')
project = Project.objects.create(**validated_data)
Expand Down
40 changes: 9 additions & 31 deletions zubhub_frontend/zubhub/src/components/pages/profile/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -374,37 +374,15 @@ class Profile extends Component {
<Paper className={classes.profileHeaderStyle}>
<Container maxWidth="md">
{this.props.auth.username === profile.username ? (
<>
<Link
className={classes.textDecorationNone}
to="/projects/create"
>
<Button
className={clsx(
classes.secondaryButton,
classes.floatRight
)}
variant="outlined"
size="medium"
margin="normal"
>
Create Project
</Button>
</Link>

<Button
className={clsx(
classes.primaryButton,
classes.floatRight
)}
variant="contained"
size="medium"
margin="normal"
onClick={this.handleToggleEditProfileModal}
>
Edit
</Button>
</>
<Button
className={clsx(classes.primaryButton, classes.floatRight)}
variant="contained"
size="medium"
margin="normal"
onClick={this.handleToggleEditProfileModal}
>
Edit
</Button>
) : (
<Button
className={clsx(
Expand Down
Loading

0 comments on commit 0af71e5

Please sign in to comment.