Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Activity Creation #731

Merged
merged 111 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
18b19b4
Fixed issue with comment form submitting when empty
yaya-mamoudou Mar 21, 2023
092377c
Add validation of username when creating new creator to make sure use…
yaya-mamoudou Jun 5, 2023
ed8b162
Fixed issue with comment form submitting when empty
yaya-mamoudou Mar 21, 2023
d15ebd7
Merge branch 'master' into outreachy-yaya-713
yaya-mamoudou Jun 5, 2023
d176262
-
yaya-mamoudou Jun 5, 2023
b848f81
Wrap error string with translation method
yaya-mamoudou Jun 7, 2023
0027311
Create project creation form and navigation layouts
yaya-mamoudou Jun 22, 2023
e70f62a
Fix form spacing and made banner fixed on mobile
yaya-mamoudou Jun 26, 2023
44c3fdb
modify videoInput component so the user can only add either a video o…
yaya-mamoudou Jun 26, 2023
c632372
Create Rich text editor component
yaya-mamoudou Jun 30, 2023
7b19899
-
yaya-mamoudou Jun 30, 2023
d63be62
create project in steps and modified project details page
yaya-mamoudou Jul 6, 2023
5a3b387
+
yaya-mamoudou Jul 6, 2023
80481d3
removed extra linear gradient on project details page
yaya-mamoudou Jul 7, 2023
8f00c2e
add method to display the right message based on current step and cre…
yaya-mamoudou Jul 7, 2023
78f25a8
Add success dialog to project details page after successful project c…
yaya-mamoudou Jul 8, 2023
9e8460b
bypass validation of image and video fields when publish mode is draft
yaya-mamoudou Jul 8, 2023
d560507
Added modal
yaya-mamoudou Jul 8, 2023
1402605
Create modal component
yaya-mamoudou Jul 8, 2023
c2de630
Add dialogs for step 3 for user to add tags
yaya-mamoudou Jul 8, 2023
7f8236d
Add confetti to successfull project creation dialog
yaya-mamoudou Jul 8, 2023
cb7bc42
refactored the dropdown component to allow maximum selection when the…
yaya-mamoudou Jul 9, 2023
0782e4f
Add query to exclude a project in the list of projects of a creator
yaya-mamoudou Jul 9, 2023
1654bd4
Add more projects to project details page
yaya-mamoudou Jul 9, 2023
fa46437
Currently, the email gets displayed on the user profile. (#714)
yaya-mamoudou Jul 9, 2023
b6d861a
+
yaya-mamoudou Jul 9, 2023
5533093
validate multiple categories
yaya-mamoudou Jul 9, 2023
6390d9f
refactor sidenav
yaya-mamoudou Jul 10, 2023
c007fea
Add project mode selection page
yaya-mamoudou Jul 10, 2023
613d261
+
yaya-mamoudou Jul 12, 2023
070363e
Fix edit
yaya-mamoudou Jul 12, 2023
40a0b56
+
yaya-mamoudou Jul 12, 2023
09a39a0
Add correct links to sidenav and modified the styles of the associate…
yaya-mamoudou Jul 12, 2023
7d4d480
Fixes
yaya-mamoudou Jul 12, 2023
1df51d4
Accept multiple categories in a project
yaya-mamoudou Jul 15, 2023
0f05ec8
refactor sidenav
yaya-mamoudou Jul 10, 2023
e23cd30
Add project mode selection page
yaya-mamoudou Jul 10, 2023
705c92e
+
yaya-mamoudou Jul 12, 2023
03620ca
Fix edit
yaya-mamoudou Jul 12, 2023
57acbc5
+
yaya-mamoudou Jul 12, 2023
e7a45e6
Add correct links to sidenav and modified the styles of the associate…
yaya-mamoudou Jul 12, 2023
5e1ecf3
Fixes
yaya-mamoudou Jul 12, 2023
3442141
+
yaya-mamoudou Jul 14, 2023
15c1536
Merge branch 'project-creation' of https://github.com/yaya-mamoudou/z…
yaya-mamoudou Jul 15, 2023
d718f77
Update multiple categories
yaya-mamoudou Jul 16, 2023
0a1f47b
+
yaya-mamoudou Jul 16, 2023
5c95b38
Add comments in project details
yaya-mamoudou Jul 16, 2023
db9dcbe
Add cat to draft and my projects empty page
yaya-mamoudou Jul 17, 2023
a60726f
unauthorized user navbar and categories new ui
yaya-mamoudou Jul 17, 2023
421e42c
remove publish without tags dialog when tags are available
yaya-mamoudou Jul 17, 2023
a850c9b
Add preview page
yaya-mamoudou Jul 17, 2023
d56e355
+
yaya-mamoudou Jul 18, 2023
aa27478
Add link preview
yaya-mamoudou Jul 20, 2023
938d940
Made preview project to render in a modal
yaya-mamoudou Jul 20, 2023
c555407
Make landing page visible to non logged in users
yaya-mamoudou Jul 20, 2023
336a011
Add old search bar
yaya-mamoudou Jul 23, 2023
d7d08e2
Fixes on profile
yaya-mamoudou Jul 23, 2023
530bafe
+
yaya-mamoudou Jul 23, 2023
b03ce81
+
yaya-mamoudou Jul 23, 2023
dcd4fab
+
yaya-mamoudou Jul 23, 2023
bcd1f95
fix grid on other projects for non logged in users
yaya-mamoudou Jul 23, 2023
c51d8e9
Add create activity to sidenav for staff users
yaya-mamoudou Jul 26, 2023
154803e
remove commented code and some clogs
yaya-mamoudou Jul 26, 2023
4a3ab9a
fixes
yaya-mamoudou Jul 28, 2023
b8fa3cf
update email regex
yaya-mamoudou Jul 28, 2023
47badb6
Merge branch 'outreachy-yaya' into project-creation
yaya-mamoudou Jul 28, 2023
da9320e
create activity form
yaya-mamoudou Aug 7, 2023
3f6d1cf
+
yaya-mamoudou Aug 10, 2023
00671c6
Text & Font & Design changes
yaya-mamoudou Aug 12, 2023
890f98c
Merge branch 'outreachy-yaya' of https://github.com/unstructuredstudi…
yaya-mamoudou Aug 12, 2023
cbd4312
Merge branch 'outreachy-yaya' into project-creation
yaya-mamoudou Aug 12, 2023
dffc44a
Merge branch 'project-creation' of https://github.com/yaya-mamoudou/z…
yaya-mamoudou Aug 12, 2023
d3634f9
Fix
yaya-mamoudou Aug 16, 2023
42bd64f
Move up, move down, delete step
yaya-mamoudou Aug 16, 2023
e32cd07
+
yaya-mamoudou Aug 21, 2023
3f15029
activity detail
yaya-mamoudou Aug 21, 2023
55998d0
input improvement
yaya-mamoudou Aug 22, 2023
f844d4e
Merge branch 'project-creation' of https://github.com/yaya-mamoudou/z…
yaya-mamoudou Aug 23, 2023
aa0939f
Create Gallery component
yaya-mamoudou Aug 23, 2023
001af61
Add gallery component
yaya-mamoudou Aug 23, 2023
350af0b
Merge branch 'master' into activity-creation
yaya-mamoudou Aug 27, 2023
9a00a67
+
yaya-mamoudou Aug 27, 2023
4c5896a
Fix on Project card component
yaya-mamoudou Aug 27, 2023
b406bc0
Take multiple categories and take introduction and class_grade
yaya-mamoudou Aug 28, 2023
4c4cf46
Create activity
yaya-mamoudou Aug 28, 2023
41f007e
-
yaya-mamoudou Aug 28, 2023
aecdecd
Merge branch 'master' of https://github.com/unstructuredstudio/zubhub…
yaya-mamoudou Aug 28, 2023
d17e389
Add title to making_steps
yaya-mamoudou Aug 28, 2023
2593625
Add gutter to activities list
yaya-mamoudou Aug 28, 2023
d527ce8
translation: modify create activity text on sidenav
yaya-mamoudou Aug 28, 2023
2d712c0
Add step 1 and step 2 form schema
yaya-mamoudou Aug 28, 2023
0a07b74
format images for form submit
yaya-mamoudou Aug 29, 2023
c612e9e
Upload images working
yaya-mamoudou Aug 30, 2023
35170cf
+
yaya-mamoudou Aug 30, 2023
3b0fe53
Create activity working
yaya-mamoudou Aug 31, 2023
e5079dd
Added comments
yaya-mamoudou Aug 31, 2023
7719065
make some fields in activity model nullable
yaya-mamoudou Sep 1, 2023
73cc655
Add endpoint to read activity details
yaya-mamoudou Sep 2, 2023
289fe7b
add limit to list of activities
yaya-mamoudou Sep 3, 2023
21e73a1
Activity details, preview and more activities
yaya-mamoudou Sep 3, 2023
c92566e
activity update modify serializer
yaya-mamoudou Sep 3, 2023
3054d49
-
yaya-mamoudou Sep 3, 2023
6e74452
Change image sizes in gallery
yaya-mamoudou Sep 4, 2023
ac3299b
+
yaya-mamoudou Sep 4, 2023
184a8ab
Add download pdf functionality to activity details page
yaya-mamoudou Sep 5, 2023
68c42d6
Fixed issue with images not showing in generated pdf
yaya-mamoudou Sep 5, 2023
b495128
+
yaya-mamoudou Sep 5, 2023
4b651ef
+
yaya-mamoudou Sep 5, 2023
8dd3364
+
yaya-mamoudou Sep 5, 2023
89d9e18
show dialog when user clicks on image in gallery
yaya-mamoudou Sep 5, 2023
a8e1f50
create pill component
yaya-mamoudou Sep 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 3.2 on 2023-08-28 03:39

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('projects', '0010_alter_project_category'),
('activities', '0008_auto_20220829_1530'),
]

operations = [
migrations.AddField(
model_name='activity',
name='class_grade',
field=models.CharField(blank=True, max_length=50),
),
migrations.AddField(
model_name='activity',
name='introduction',
field=models.CharField(blank=True, max_length=10000),
),
migrations.RemoveField(
model_name='activity',
name='category',
),
migrations.AddField(
model_name='activity',
name='category',
field=models.ManyToManyField(blank=True, null=True, related_name='activities', to='projects.Category'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 3.2 on 2023-08-28 05:20

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('activities', '0009_auto_20230828_0339'),
]

operations = [
migrations.RemoveField(
model_name='activitymakingstep',
name='image',
),
migrations.AddField(
model_name='activitymakingstep',
name='image',
field=models.ManyToManyField(blank=True, null=True, to='activities.Image'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2 on 2023-08-28 09:40

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('activities', '0010_auto_20230828_0520'),
]

operations = [
migrations.AddField(
model_name='activitymakingstep',
name='title',
field=models.TextField(max_length=500, null=True),
),
migrations.AlterField(
model_name='activitymakingstep',
name='image',
field=models.ManyToManyField(blank=True, to='activities.Image'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2 on 2023-08-28 09:41

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('projects', '0010_alter_project_category'),
('activities', '0011_auto_20230828_0940'),
]

operations = [
migrations.AlterField(
model_name='activity',
name='category',
field=models.ManyToManyField(blank=True, related_name='activities', to='projects.Category'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2 on 2023-08-31 19:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('activities', '0012_alter_activity_category'),
]

operations = [
migrations.AlterField(
model_name='activity',
name='materials_used',
field=models.TextField(max_length=5000, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2 on 2023-08-31 19:52

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('activities', '0013_alter_activity_materials_used'),
]

operations = [
migrations.AlterField(
model_name='activity',
name='materials_used',
field=models.TextField(blank=True, max_length=5000),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2 on 2023-08-31 19:53

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('activities', '0014_alter_activity_materials_used'),
]

operations = [
migrations.AlterField(
model_name='activity',
name='learning_goals',
field=models.TextField(blank=True, max_length=10000, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2 on 2023-08-31 19:54

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('activities', '0015_alter_activity_learning_goals'),
]

operations = [
migrations.AlterField(
model_name='activity',
name='facilitation_tips',
field=models.TextField(blank=True, max_length=10000, null=True),
),
migrations.AlterField(
model_name='activity',
name='motivation',
field=models.TextField(blank=True, max_length=10000, null=True),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2 on 2023-08-31 19:55

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('activities', '0016_auto_20230831_1954'),
]

operations = [
migrations.AlterField(
model_name='activity',
name='materials_used',
field=models.TextField(blank=True, max_length=5000, null=True),
),
]
24 changes: 11 additions & 13 deletions zubhub_backend/zubhub/activities/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ class Activity(models.Model):
creators = models.ManyToManyField(Creator,
related_name="activities_created")
title = models.CharField(max_length=500)
learning_goals = models.TextField(max_length=10000, blank=True)
facilitation_tips = models.TextField(max_length=10000, blank=True)
motivation = models.TextField(max_length=10000, blank=True)
category = models.ForeignKey(Category,
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name="activities")
category = models.ManyToManyField("projects.Category",blank=True, related_name="activities")
introduction = models.CharField(max_length=10000,blank=True)
class_grade = models.CharField(max_length=50, blank=True)

learning_goals = models.TextField(max_length=10000, blank=True, null=True)
facilitation_tips = models.TextField(max_length=10000, blank=True, null=True)
motivation = models.TextField(max_length=10000, blank=True, null=True)
video = models.URLField(max_length=1000, blank=True, null=True)
materials_used = models.TextField(max_length=5000)
materials_used = models.TextField(max_length=5000, blank=True, null=True)
materials_used_image = models.ForeignKey(Image,
on_delete=models.SET_NULL,
null=True,
Expand Down Expand Up @@ -127,10 +126,9 @@ class ActivityMakingStep(models.Model):
null=True,
related_name="making_steps",
blank=True)
image = models.ForeignKey(Image,
on_delete=models.CASCADE,
null=True,
blank=True)

title = models.TextField(max_length=500,null=True)
image = models.ManyToManyField(Image,blank=True)
description = models.TextField(max_length=10000, blank=True)
step_order = models.IntegerField()

Expand Down
25 changes: 21 additions & 4 deletions zubhub_backend/zubhub/activities/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ class Meta:


class ActivityMakingStepSerializer(serializers.ModelSerializer):
image = ImageSerializer(required=False, allow_null=True)
image = ImageSerializer(required=False, allow_null=True, many=True )
step_order = serializers.IntegerField()

class Meta:
model = ActivityMakingStep
fields = [
"image", "description", "step_order"
"image", "description", "step_order", "title"
]


Expand All @@ -70,7 +70,7 @@ class ActivitySerializer(serializers.ModelSerializer):
images = ActivityImageSerializer(
many=True, required=False, source="activity_images")
category = serializers.SlugRelatedField(
slug_field="name", queryset=Category.objects.all(), required=False)
slug_field="name", queryset=Category.objects.all(), many=True, required=False)
created_on = serializers.DateTimeField(read_only=True)
views_count = serializers.IntegerField(read_only=True)
saved_count = serializers.IntegerField(read_only=True)
Expand All @@ -88,6 +88,8 @@ class Meta:
"inspired_projects",
"creators",
"title",
"introduction",
"class_grade",
"motivation",
"images",
"video",
Expand Down Expand Up @@ -119,8 +121,13 @@ def create(self, validated_data):
making_steps = validated_data.pop('making_steps', None)

inspiring_examples = validated_data.pop('inspiring_examples', None)
category = validated_data.pop('category',None)

activity = Activity.objects.create(**validated_data)

if(category):
activity.category.set(category)

if making_steps:
create_making_steps(activity, making_steps)
if inspiring_examples:
Expand Down Expand Up @@ -177,10 +184,20 @@ def update(self, activity, validated_data):
update_inspiring_examples(
activity, validated_data.pop('inspiring_examples'))
activity.title = validated_data.get('title')

if validated_data.get('introduction'):
activity.introduction = validated_data.get('introduction')

activity.motivation = validated_data.get('motivation')
activity.facilitation_tips = validated_data.get('facilitation_tips')
activity.learning_goals = validated_data.get('learning_goals')
activity.materials_used = validated_data.get('materials_used')

if validated_data.get('publish'):
activity.publish = validated_data.get('publish')

if validated_data.get('materials_used'):
activity.materials_used = validated_data.get('materials_used')

activity.video = validated_data.get('video')
activity.save()
return activity
4 changes: 2 additions & 2 deletions zubhub_backend/zubhub/activities/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
path('<uuid:pk>/update/', ActivityUpdateAPIView.as_view(), name='update'),
path('<uuid:pk>/delete/', ActivityDeleteAPIView.as_view(), name='delete'),
path('<uuid:pk>/toggle-save/', ToggleSaveAPIView.as_view(), name='save'),
path('<uuid:pk>/toggle-publish/', togglePublishActivityAPIView.as_view(), name='publish')

path('<uuid:pk>/toggle-publish/', togglePublishActivityAPIView.as_view(), name='publish'),
path('<uuid:pk>/', ActivityDetailsAPIView.as_view(), name='detail_activity')
]
19 changes: 14 additions & 5 deletions zubhub_backend/zubhub/activities/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@ def create_inspiring_artist(inspiring_artist_data):


def create_making_steps(activity, making_steps):
for step in making_steps:
if(step.get('image')):
saved_image = Image.objects.create(**step['image'])
step['image'] = saved_image
ActivityMakingStep.objects.create(activity=activity, **step)
for step_data in making_steps:
step_images_data = step_data.pop('image', []) # Extract and remove the 'image' key

# Create the ActivityMakingStep instance
step = ActivityMakingStep.objects.create(activity=activity, **step_data)

# Create or retrieve Image instances and associate them with the step
step_images = []
for image_info in step_images_data:
image = Image.objects.create(**image_info)
step_images.append(image)

# Associate the Image instances with the step using the set() method
step.image.set(step_images)


def create_inspiring_examples(activity, inspiring_examples):
Expand Down
Loading