diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62f88d1e5..78ca310fa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,91 +1,91 @@ -default_language_version: - python: python3 - -repos: - - repo: https://github.com/psf/black - rev: 23.1.0 - hooks: - - id: black - args: ["-l 88"] - files: zubhub_backend/.*\.py$ - - - repo: https://github.com/PyCQA/isort - rev: 5.11.5 # do not update this until our CI runner uses Python >=3.8.1 - hooks: - - id: isort - files: zubhub_backend/.*\.py$ - - - repo: https://github.com/PyCQA/flake8 - rev: 5.0.4 # do not update this until our CI runner uses Python >=3.8.1 - hooks: - - id: flake8 - # use same max-line-length as black - # E121, E123, E126, E133, E226, E241, E242, E704 and W503 are default ignores - # E124: closing bracket does not match visual indentation - # E203: non-pep8 compliant brainfart of flake8 - args: - [ - "--max-line-length=88", - "--ignore=E121,E123,E126,E133,E203,E226,E241,E242,E704,W503,E124", - ] - files: zubhub_backend/.*\.py$ - - # - repo: https://github.com/pre-commit/mirrors-mypy - # rev: v1.0.0 - # hooks: - # - id: mypy - # exclude: ^tests/ - # verbose: true - # args: [--show-error-codes, --ignore-missing-imports] - # additional_dependencies: - # ["types-requests", "types-PyYAML", "types-flask", "toolforge-weld"] - - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - - id: check-shebang-scripts-are-executable - - id: check-executables-have-shebangs - - id: check-merge-conflict - - - repo: https://github.com/pre-commit/mirrors-eslint - rev: v7.32.0 - hooks: - - id: eslint - entry: ./zubhub_frontend/zubhub/pre-commit-eslint - pass_filenames: false - always_run: true - - - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.1.0 - hooks: - - id: prettier - files: zubhub_frontend/.*\.[jt]sx?$ - exclude: ^zubhub_frontend/zubhub/node_modules/ - args: ["--config", "./zubhub_frontend/zubhub/.prettierrc.yaml"] - - - repo: local - hooks: - - id: zubhub-test - name: zubhub-test - entry: ./zubhub_backend/pre-commit-zubhub-test - language: system - files: zubhub_backend/zubhub/.*\.py$ - pass_filenames: false - - - id: media-test - name: media-test - entry: ./zubhub_backend/pre-commit-media-test - language: system - files: zubhub_backend/media/.*\.py$ - pass_filenames: false - - - id: react-test - name: react-test - entry: npm --prefix ./zubhub_frontend/zubhub/ run test -- --coverage --watchAll=false - language: node - files: zubhub_frontend/.*\.[jt]sx?$ - exclude: ^zubhub_frontend/zubhub/node_modules/ - pass_filenames: false +default_language_version: + python: python3 + +repos: + - repo: https://github.com/psf/black + rev: 23.1.0 + hooks: + - id: black + args: ["-l 88"] + files: zubhub_backend/.*\.py$ + + - repo: https://github.com/PyCQA/isort + rev: 5.11.5 # do not update this until our CI runner uses Python >=3.8.1 + hooks: + - id: isort + files: zubhub_backend/.*\.py$ + + - repo: https://github.com/PyCQA/flake8 + rev: 5.0.4 # do not update this until our CI runner uses Python >=3.8.1 + hooks: + - id: flake8 + # use same max-line-length as black + # E121, E123, E126, E133, E226, E241, E242, E704 and W503 are default ignores + # E124: closing bracket does not match visual indentation + # E203: non-pep8 compliant brainfart of flake8 + args: + [ + "--max-line-length=88", + "--ignore=E121,E123,E126,E133,E203,E226,E241,E242,E704,W503,E124", + ] + files: zubhub_backend/.*\.py$ + + # - repo: https://github.com/pre-commit/mirrors-mypy + # rev: v1.0.0 + # hooks: + # - id: mypy + # exclude: ^tests/ + # verbose: true + # args: [--show-error-codes, --ignore-missing-imports] + # additional_dependencies: + # ["types-requests", "types-PyYAML", "types-flask", "toolforge-weld"] + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-shebang-scripts-are-executable + - id: check-executables-have-shebangs + - id: check-merge-conflict + + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v7.32.0 + hooks: + - id: eslint + entry: ./zubhub_frontend/zubhub/pre-commit-eslint + pass_filenames: false + always_run: true + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v3.1.0 + hooks: + - id: prettier + files: zubhub_frontend/.*\.[jt]sx?$ + exclude: ^zubhub_frontend/zubhub/node_modules/ + args: ["--config", "./zubhub_frontend/zubhub/.prettierrc.yaml"] + + - repo: local + hooks: + - id: zubhub-test + name: zubhub-test + entry: ./zubhub_backend/pre-commit-zubhub-test + language: system + files: zubhub_backend/zubhub/.*\.py$ + pass_filenames: false + + - id: media-test + name: media-test + entry: ./zubhub_backend/pre-commit-media-test + language: system + files: zubhub_backend/media/.*\.py$ + pass_filenames: false + + - id: react-test + name: react-test + entry: npm --prefix ./zubhub_frontend/zubhub/ run test -- --coverage --watchAll=false + language: node + files: zubhub_frontend/.*\.[jt]sx?$ + exclude: ^zubhub_frontend/zubhub/node_modules/ + pass_filenames: false diff --git a/zubhub_backend/zubhub/projects/serializers.py b/zubhub_backend/zubhub/projects/serializers.py index 61d9b1a19..aed0e21e8 100644 --- a/zubhub_backend/zubhub/projects/serializers.py +++ b/zubhub_backend/zubhub/projects/serializers.py @@ -159,7 +159,7 @@ def get_comments(self, obj): def validate_video(self, video): if(self.initial_data.get('publish').get('type') == 1): return video - + if(video == "" and len(self.initial_data.get("images")) == 0): raise serializers.ValidationError( _("You must provide either image(s), video file, or video URL to create your project!")) @@ -168,7 +168,7 @@ def validate_video(self, video): def validate_images(self, images): if(self.initial_data.get('publish').get('type') == 1): return images - + if(len(images) == 0 and len(self.initial_data["video"]) == 0): raise serializers.ValidationError( _("You must provide either image(s), video file, or video URL to create your project!")) @@ -265,7 +265,7 @@ def create(self, validated_data): if project.video.find("cloudinary.com") > -1 and project.video.split(".")[-1] != "mpd": update_video_url_if_transform_ready.delay( {"url": project.video, "project_id": project.id}) - + return project def update(self, project, validated_data): @@ -276,7 +276,7 @@ def update(self, project, validated_data): category = None if validated_data.get('category', []): category = validated_data.pop('category') - + video_data = validated_data.pop("video") if (project.video.find("cloudinary.com") > -1 or @@ -327,6 +327,8 @@ class ProjectListSerializer(serializers.ModelSerializer): many=True, slug_field='id', read_only=True) created_on = serializers.DateTimeField(read_only=True) publish = PublishingRuleSerializer(read_only=True) + activity = serializers.SlugRelatedField( + slug_field="id", queryset=Activity.objects.all(), required=False) class Meta: model = Project @@ -343,7 +345,8 @@ class Meta: "comments_count", "created_on", "publish", - "group" + "group", + "activity" ] diff --git a/zubhub_frontend/zubhub/public/locales/en/translation.json b/zubhub_frontend/zubhub/public/locales/en/translation.json index 51afb1356..0c85ad11a 100644 --- a/zubhub_frontend/zubhub/public/locales/en/translation.json +++ b/zubhub_frontend/zubhub/public/locales/en/translation.json @@ -343,8 +343,8 @@ "unexpected": "Uh oh! Seems like we hit a snag :( Maybe try again later?" } }, - "createProject": { + "activityProjectCreate": "Create this Project", "welcomeMsg": { "primary": "Create Project", "secondary": "Tell us about your project!" diff --git a/zubhub_frontend/zubhub/public/locales/hi/translation.json b/zubhub_frontend/zubhub/public/locales/hi/translation.json index 03af477a0..f7b72b485 100644 --- a/zubhub_frontend/zubhub/public/locales/hi/translation.json +++ b/zubhub_frontend/zubhub/public/locales/hi/translation.json @@ -294,6 +294,7 @@ }, "createProject": { + "activityProjectCreate": "यह प्रोजेक्ट बनाएं", "welcomeMsg": { "primary": "प्रोजेक्ट बनाएं", "secondary": "हमें अपनी परियोजना के बारे में बताएं!" diff --git a/zubhub_frontend/zubhub/src/views/activity_details/ActivityDetailsV2.jsx b/zubhub_frontend/zubhub/src/views/activity_details/ActivityDetailsV2.jsx index 085207407..6e05aa6be 100644 --- a/zubhub_frontend/zubhub/src/views/activity_details/ActivityDetailsV2.jsx +++ b/zubhub_frontend/zubhub/src/views/activity_details/ActivityDetailsV2.jsx @@ -81,6 +81,10 @@ export default function ActivityDetailsV2(props) { props.navigate(`${props.location.pathname}/edit`); }; + const handleCreateProject = () => { + props.history.push('/projects/create', {activity_id: id}); + }; + const toggleDialog = () => { setOpen(!open); props.navigate(window.location.pathname, { replace: true }); @@ -139,7 +143,11 @@ export default function ActivityDetailsV2(props) {
- + Create this Project