This file contains hidden or 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
| from .models import Lecture,PlayList | |
| class InLineLecture(admin.TabularInline): | |
| model = Lecture | |
| class PlayListAdmin(admin.ModelAdmin): | |
| inlines = [InLineLecture] | |
| list_display = ('title','slug') | |
| admin.site.register(Lecture) |
This file contains hidden or 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
| from django.db import models | |
| class PlayList(models.Model): | |
| title = models.CharField(max_length=255) | |
| slug = models.SlugField() | |
| description = models.TextField() | |
| def __str__(self): | |
| return self.title | |
This file contains hidden or 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
| from django.contrib import admin | |
| from .models import Lecture | |
| class LectureAdmin(admin.ModelAdmin): | |
| list_display = ('title','slug','video_url','description_length') | |
| list_display_link = ('slug') | |
| iist_diplay_editable = ('title','video_url') | |
| list_display_filter = ('title') | |
| list_display_search = ('title','description') | |
This file contains hidden or 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
| from django.db import models | |
| class Lecture(models.Model): | |
| title = models.CharField(max_length=255) | |
| slug = models.SlugField() | |
| description = models.TextField() | |
| video_url = models.CharField(max_length=500) | |
| def __str__(self): |
This file contains hidden or 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
| import random | |
| import string | |
| from django.utils.text import slugify | |
| def random_string_generator(size=5, chars=string.ascii_lowercase + string.digits): | |
| return ''.join(random.choice(chars) for _ in range(size)) | |
| def unique_slug_generator(instance, new_slug=None): |
This file contains hidden or 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
| # add the account app and all the dependency | |
| INSTALLED_APPS = [ | |
| 'django.contrib.admin', | |
| 'django.contrib.auth', | |
| 'django.contrib.contenttypes', | |
| 'django.contrib.sessions', | |
| 'django.contrib.messages', |
This file contains hidden or 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
| from django.contrib import admin | |
| from django.urls import path,include | |
| from rest_framework_jwt.views import obtain_jwt_token,refresh_jwt_token | |
| # from Door import urls as DoorUrls | |
| urlpatterns = [ | |
| path('admin/', admin.site.urls), | |
| path('api/',include('account.urls')), | |
| ] |
This file contains hidden or 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
| from django.conf.urls import include | |
| from django.urls import path | |
| from rest_framework import routers | |
| from .views import UserViewSet,ProfileViewSet | |
| router = routers.DefaultRouter() | |
| router.register('user', UserViewSet) | |
| router.register('profile', ProfileViewSet) |
This file contains hidden or 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
| from rest_framework import permissions | |
| class IsOwnerAndAuthenticated(permissions.BasePermission): | |
| def has_permission(self, request, view): | |
| # let permmission just for create user | |
| if request.method == 'POST' : | |
| return True |
This file contains hidden or 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
| from django.shortcuts import render | |
| from rest_framework.decorators import action | |
| from rest_framework.response import Response | |
| from rest_framework import viewsets,status,generics | |
| from .models import User,Profile | |
| from .serializers import SimpleProfileSerializer,ProfileSerializer | |
| from .UserSerializer import UserSerializer | |
| from .permissions import IsOwnerAndAuthenticated | |