-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into snyk-upgrade-99ee1bdf317deb804248d6d7ad2640a9
- Loading branch information
Showing
82 changed files
with
1,463 additions
and
1,368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import hmac | ||
from hashlib import sha1 | ||
from time import time | ||
|
||
|
||
def hmac_sha1(key, msg): | ||
return hmac.new(key, msg, sha1).hexdigest() | ||
|
||
|
||
method = "GET" | ||
duration_in_seconds = 60 * 60 * 24 | ||
expires = int(time() + duration_in_seconds) | ||
path = "/v1/my_account/container/object" | ||
key = "MYKEY" | ||
hmac_body = "%s\n%s\n%s" % (method, expires, path) | ||
signature = hmac.new(key, hmac_body, sha1).hexdigest() |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.contrib import admin | ||
|
||
from .models import GearFile | ||
|
||
# Register your models here. | ||
|
||
|
||
@admin.register(GearFile) | ||
class GearFileAdmin(admin.ModelAdmin): | ||
list_display = ("gear_id", "user", "file") | ||
fields = ("user", "file") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class GearsConfig(AppConfig): | ||
name = "nonovium_video_backend.gears" | ||
verbose_name = "Gears" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 3.1.13 on 2022-01-04 13:08 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import nonovium_video_backend.gears.models | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='GearFile', | ||
fields=[ | ||
('file', models.FileField(upload_to=nonovium_video_backend.gears.models.user_directory_path)), | ||
('gear_id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), | ||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='gear_files', to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import uuid | ||
|
||
from django.db import models | ||
|
||
# Create your models here. | ||
|
||
|
||
def user_directory_path(instance, filename): | ||
return "user_{0}/{1}".format(instance.user.id, filename) | ||
|
||
|
||
class GearFile(models.Model): | ||
file = models.FileField(upload_to=user_directory_path) | ||
gear_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) | ||
user = models.ForeignKey( | ||
"users.User", | ||
on_delete=models.CASCADE, | ||
related_name="gear_files", | ||
null=True, | ||
blank=True, | ||
) | ||
|
||
def __str__(self): | ||
return str(self.gear_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# from django.shortcuts import render | ||
|
||
# Create your views here. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from django.contrib import admin | ||
|
||
from .models import VideoFile | ||
|
||
# Register your models here. | ||
|
||
|
||
@admin.register(VideoFile) | ||
class VideoFileAdmin(admin.ModelAdmin): | ||
list_display = ("user", "file") | ||
fields = ( | ||
"user", | ||
"file", | ||
"title", | ||
"width", | ||
"height", | ||
"size", | ||
"duration", | ||
"thumbnail", | ||
) | ||
readonly_fields = ("width", "height", "size", "duration") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class PipelinesConfig(AppConfig): | ||
name = "nonovium_video_backend.pipelines" | ||
verbose_name = "Pipelines" |
26 changes: 26 additions & 0 deletions
26
nonovium_video_backend/pipelines/migrations/0001_initial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 3.1.13 on 2022-01-04 11:12 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import nonovium_video_backend.pipelines.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='VideoFile', | ||
fields=[ | ||
('file', models.FileField(upload_to=nonovium_video_backend.pipelines.models.user_directory_path)), | ||
('video_id', models.UUIDField(default='$7b2a4f90-47be-411a-b5c7-b8c395efdc2f', primary_key=True, serialize=False)), | ||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='video_files', to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
nonovium_video_backend/pipelines/migrations/0002_auto_20220104_1112.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.1.13 on 2022-01-04 11:12 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('pipelines', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='videofile', | ||
name='video_id', | ||
field=models.UUIDField(default='$fdc6d087-7243-4107-be33-ec1e3454805a', primary_key=True, serialize=False), | ||
), | ||
] |
19 changes: 19 additions & 0 deletions
19
nonovium_video_backend/pipelines/migrations/0003_auto_20220104_1124.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 3.1.13 on 2022-01-04 11:24 | ||
|
||
from django.db import migrations, models | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('pipelines', '0002_auto_20220104_1112'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='videofile', | ||
name='video_id', | ||
field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False), | ||
), | ||
] |
43 changes: 43 additions & 0 deletions
43
nonovium_video_backend/pipelines/migrations/0004_auto_20220104_1308.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Generated by Django 3.1.13 on 2022-01-04 13:08 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('pipelines', '0003_auto_20220104_1124'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='videofile', | ||
name='duration', | ||
field=models.FloatField(editable=False, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='videofile', | ||
name='height', | ||
field=models.PositiveIntegerField(editable=False, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='videofile', | ||
name='size', | ||
field=models.PositiveIntegerField(editable=False, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='videofile', | ||
name='thumbnail', | ||
field=models.ImageField(blank=True, null=True, upload_to=''), | ||
), | ||
migrations.AddField( | ||
model_name='videofile', | ||
name='title', | ||
field=models.CharField(blank=True, max_length=255, null=True), | ||
), | ||
migrations.AddField( | ||
model_name='videofile', | ||
name='width', | ||
field=models.PositiveIntegerField(editable=False, null=True), | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# from os.path import splitext | ||
import uuid | ||
|
||
from django.db import models | ||
|
||
# Create your models here. | ||
|
||
|
||
def user_directory_path(instance, filename): | ||
return "user_{0}/{1}/{2}".format(instance.user.id, instance.video_id, filename) | ||
|
||
|
||
class VideoFile(models.Model): | ||
file = models.FileField(upload_to=user_directory_path) | ||
video_id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) | ||
title = models.CharField(max_length=255, null=True, blank=True) | ||
width = models.PositiveIntegerField(editable=False, null=True) | ||
height = models.PositiveIntegerField(editable=False, null=True) | ||
size = models.PositiveIntegerField(editable=False, null=True) | ||
duration = models.FloatField(editable=False, null=True) | ||
thumbnail = models.ImageField(null=True, blank=True) | ||
user = models.ForeignKey( | ||
"users.User", | ||
on_delete=models.CASCADE, | ||
related_name="video_files", | ||
null=True, | ||
blank=True, | ||
) | ||
|
||
def __str__(self): | ||
return str(self.video_id) | ||
|
||
print(user_directory_path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import contextlib | ||
import os | ||
import tempfile | ||
from typing import Generator | ||
|
||
from django.core.files import File | ||
|
||
|
||
@contextlib.contextmanager | ||
def get_local_path(fieldfile: File) -> Generator[str, None, None]: | ||
""" | ||
Get a local file to work with from a file retrieved from a FileField. | ||
""" | ||
if not hasattr(fieldfile, "storage"): | ||
# Its a local file with no storage abstraction | ||
try: | ||
yield os.path.abspath(fieldfile.path) | ||
except AttributeError: | ||
yield os.path.abspath(fieldfile.name) | ||
else: | ||
storage = fieldfile.storage | ||
try: | ||
# Try to access with path | ||
yield storage.path(fieldfile.path) | ||
except (NotImplementedError, AttributeError): | ||
# Storage doesnt support absolute paths, | ||
# download file to a temp local dir | ||
with tempfile.NamedTemporaryFile(mode="wb", delete=False) as temp_file: | ||
storage_file = storage.open(fieldfile.name, "rb") | ||
|
||
temp_file.write(storage_file.read()) | ||
temp_file.flush() | ||
yield temp_file.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# from django.shortcuts import render | ||
|
||
# Create your views here. |
18 changes: 18 additions & 0 deletions
18
nonovium_video_backend/users/migrations/0032_auto_20220104_0124.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.1.13 on 2022-01-04 01:24 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('users', '0031_auto_20211028_1645'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='user', | ||
name='user_image', | ||
field=models.CharField(default='https://avatars.dicebear.com/api/avataaars/34436.svg?size=150', max_length=250, verbose_name='Profile Image URL'), | ||
), | ||
] |
Oops, something went wrong.