Skip to content

Commit

Permalink
added podcast api and cloudinary upload
Browse files Browse the repository at this point in the history
  • Loading branch information
walosha committed Jan 25, 2023
1 parent 7e3351b commit 8e3217c
Show file tree
Hide file tree
Showing 62 changed files with 547 additions and 33,603 deletions.
20 changes: 20 additions & 0 deletions account/migrations/0007_customuser_skills.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.0.8 on 2023-01-25 12:16

import account.models
import django.contrib.postgres.fields
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('account', '0006_alter_customuser_role'),
]

operations = [
migrations.AddField(
model_name='customuser',
name='skills',
field=django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=20), default=account.models.get_skill_default, size=None),
),
]
9 changes: 8 additions & 1 deletion account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
from .enums import CATEGORY, ROLES
from core.models import AuditableModel
from django.contrib.auth.models import PermissionsMixin
from django.contrib.postgres.fields import ArrayField


def get_skill_default():
return list()

class CustomUser(AbstractUser, PermissionsMixin):
username = None # Here
email = models.EmailField('email address', unique=True) # Here
Expand All @@ -18,7 +22,10 @@ class CustomUser(AbstractUser, PermissionsMixin):
category = models.CharField(
default='unknown', max_length=20, choices=CATEGORY)
objects = CustomUserManager() # Here
# skills = models.CharField()
skills = ArrayField(
models.CharField(max_length=20, blank=True),
default=get_skill_default
)

class Meta:
verbose_name = "user"
Expand Down
5 changes: 3 additions & 2 deletions account/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ def get_token(cls, user):
class CreateUserSerializer(serializers.ModelSerializer):
class Meta:
firstname = serializers.CharField(required=True, write_only=True)
skills = serializers.CharField(required=False, write_only=True)
lastname = serializers.CharField(required=True, write_only=True)
model = CustomUser
fields = ['email', 'password', 'firstname', 'lastname']
fields = ['email', 'password', 'firstname', 'lastname',"skills"]
extra_kwargs = {'password': {'write_only': True}}

def save(self):
Expand Down Expand Up @@ -69,7 +70,7 @@ class Meta:
model = CustomUser
order = ('-created_at')
fields = ("id", 'email', "firstname",
"lastname", "category", "group_list")
"lastname", "category", "group_list","skills")

def to_representation(self, instance):
print(instance)
Expand Down
18 changes: 0 additions & 18 deletions blog/urls copy.py

This file was deleted.

17 changes: 14 additions & 3 deletions core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
https://docs.djangoproject.com/en/4.0/ref/settings/
"""
import os
from dotenv import load_dotenv
from pathlib import Path
from datetime import timedelta
import dj_database_url
from decouple import config
import cloudinary
import cloudinary.uploader
import cloudinary.api
load_dotenv()

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
Expand Down Expand Up @@ -67,6 +69,7 @@
'django_filters',
'taggit',
"account",
"podcast",
"attendance",
"event",
"blog",
Expand All @@ -84,6 +87,7 @@
MEDIA_URL = "/media/"



MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
Expand Down Expand Up @@ -124,11 +128,14 @@
}

cloudinary.config(
cloud_name = "walosha",
api_key = "754947971137564",
api_secret = "EELIIr1XwH0XMljIFaMvmSz1NBQ"
cloud_name=os.getenv("CLOUDINARY_CLOUD_NAME"),
api_key=os.getenv("CLOUDINARY_API_KEY"),
api_secret=os.getenv("CLOUDINARY_API_SECRET"),
)




# DATABASES = {
# 'default': {
# 'ENGINE': "django.db.backends.postgresql",
Expand Down Expand Up @@ -198,6 +205,10 @@
}






# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/

Expand Down
1 change: 1 addition & 0 deletions core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
path('api/events/', include('event.urls')),
path('api/blogs/', include('blog.urls')),
path('api/siteinfo/', include('siteinfo.urls')),
path('api/podcast/', include('podcast.urls')),
path('api/giving/', include('giving.urls')),
# Optional UI:
path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
Expand Down
4 changes: 4 additions & 0 deletions event/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@ class Meta:
# fields = ('id', 'title', 'description', 'completed')
# Shortcut for getting all fields
fields = '__all__'
extra_kwargs = {
'owner': {'read_only': True},
}

6 changes: 6 additions & 0 deletions event/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ class EventListCreateAPIView (generics.ListCreateAPIView):
queryset = Event.objects.all()
serializer_class = EventSerializer

def perform_create(self, serializer):
if self.request.user.is_authenticated:
serializer.save(user=self.request.user)
else:
serializer.save()


class EventRetrieveAPIView (generics.RetrieveAPIView):
queryset = Event.objects.all()
Expand Down
24 changes: 0 additions & 24 deletions fe/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions fe/index.html

This file was deleted.

Loading

0 comments on commit 8e3217c

Please sign in to comment.