Skip to content

Commit

Permalink
add ckeditor section
Browse files Browse the repository at this point in the history
  • Loading branch information
RignonNoel committed Jul 14, 2020
1 parent b10b758 commit 73f3406
Show file tree
Hide file tree
Showing 48 changed files with 271 additions and 56 deletions.
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@
- Front-end repository : https://github.com/Volontaria/Website-Volontaria
- Documentation for the project : http://volontaria.readthedocs.io

## Issue manager
## Interested

Issues are handled in a [Redmine instance](https://genielibre.com/projects/volontaria).
Feel free to create an account there to begin contributing!

## Important

API-Volontaria is not yet ready for testing and is still under development! It will not work as expected! If you'd like to join the public beta test group please contact us.
If you'd like to install Volontaria for your organization feel free to contact us to sync your effort with our
development team and get important tips on deployment and configuration.
11 changes: 7 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
Django==2.2.3
Django==2.2.14
django-filter==2.2.0
djangorestframework==3.10.2
Markdown==2.6.11
djangorestframework==3.10.3
Markdown==3.2.1
drfdocs==0.0.11
django-cors-headers==3.0.2
Faker==0.8.17
factory-boy==2.10.0
django-import-export==1.2.0
django-import-export==2.0.1
django-anymail==6.1
coreapi==2.3.3
django-orderable==6.0.1
django-ckeditor==5.7.1
django-reversion==3.0.3
xlrd==1.2.0
xlwt==1.3.0
openpyxl==3.0.3
Empty file added source/__init__.py
Empty file.
Empty file.
15 changes: 15 additions & 0 deletions source/apiVolontaria/apiVolontaria/permissions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from rest_framework import permissions


class IsAdminOrReadOnly(permissions.BasePermission):
"""
Custom permission to only allow admins to modify objects.
"""

def has_permission(self, request, view):
# Read permissions are allowed to any request,
# so we'll always allow GET, HEAD or OPTIONS requests.
if request.method in permissions.SAFE_METHODS:
return True

return request.user.is_staff
10 changes: 5 additions & 5 deletions source/apiVolontaria/apiVolontaria/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,16 @@
'rest_framework_docs',
'rest_framework.authtoken',
'corsheaders',
'apiVolontaria',
'volunteer',
'location',
'pages',
'ckeditor_api',
'import_export',
'anymail',
'orderable',
'ckeditor',
'reversion',

'apiVolontaria',
'volunteer',
'location',
'pages',
]

MIDDLEWARE = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from rest_framework.test import APITestCase
from django.utils import timezone

from ..models import ActionToken
from ..factories import UserFactory
from apiVolontaria.models import ActionToken
from apiVolontaria.factories import UserFactory


class ActionTokenTests(APITestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from rest_framework.test import APITestCase
from django.core.exceptions import ValidationError

from ..models import Profile
from ..factories import UserFactory
from apiVolontaria.models import Profile
from apiVolontaria.factories import UserFactory


class ProfileTests(APITestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from django.urls import reverse
from django.contrib.auth.models import User

from ..factories import UserFactory
from ..models import ActionToken
from apiVolontaria.factories import UserFactory
from apiVolontaria.models import ActionToken


class ChangePasswordTests(APITestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from django.urls import reverse
from django.test.utils import override_settings

from ..factories import UserFactory
from ..models import ActionToken
from apiVolontaria.factories import UserFactory
from apiVolontaria.models import ActionToken

from django.core import mail
from anymail.exceptions import AnymailCancelSend
Expand Down
4 changes: 2 additions & 2 deletions source/apiVolontaria/apiVolontaria/tests/tests_view_Users.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from django.test.utils import override_settings
from django.contrib.auth.models import User

from ..models import ActionToken
from apiVolontaria.models import ActionToken
from location.models import Address, StateProvince, Country
from volunteer.models import Cell, Event, Cycle, TaskType, Participation
from ..factories import UserFactory, AdminFactory
from apiVolontaria.factories import UserFactory, AdminFactory
from django.core import mail

from anymail.exceptions import AnymailCancelSend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from django.urls import reverse
from django.contrib.auth.models import User

from ..factories import UserFactory
from ..models import ActionToken
from apiVolontaria.factories import UserFactory
from apiVolontaria.models import ActionToken


class UsersActivationTests(APITestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

from location.models import Country, StateProvince, Address
from volunteer.models import Cell
from .. import models
from ..factories import UserFactory, AdminFactory
from apiVolontaria import models
from apiVolontaria.factories import UserFactory, AdminFactory


class UsersIdTests(APITestCase):
Expand Down
23 changes: 23 additions & 0 deletions source/apiVolontaria/apiVolontaria/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,30 @@
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.views.static import serve

from rest_framework.routers import DefaultRouter
from rest_framework.documentation import include_docs_urls

from ckeditor_api.urls import ckeditor_router
from .views import (ObtainTemporaryAuthToken, Users, UsersId, UsersActivation,
ResetPassword, ChangePassword)


class OptionalSlashDefaultRouter(DefaultRouter):
""" Subclass of DefaultRouter to make the trailing slash optional """
def __init__(self, *args, **kwargs):
super(DefaultRouter, self).__init__(*args, **kwargs)
self.trailing_slash = '/?'


# Create a router and register our viewsets with it.
router = OptionalSlashDefaultRouter()

# External workplace application
# Their urls are directly appended to the main router
# The retreat app is not included here because we needed a url prefix, thus
# it is included separately at the bottom of this file.
router.registry.extend(ckeditor_router.registry)

urlpatterns = [
# Token authentification
url(
Expand Down Expand Up @@ -82,6 +101,10 @@
r'^pages/',
include('pages.urls', namespace="pages"),
),
path(
'',
include(router.urls)
), # includes router generated URL
# DOCUMENTATION SWAGGER
path(
'docs/',
Expand Down
Empty file.
11 changes: 11 additions & 0 deletions source/apiVolontaria/ckeditor_api/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.contrib import admin

from .models import CKEditorPage


@admin.register(CKEditorPage)
class CKEditorPageAdmin(admin.ModelAdmin):
readonly_fields = (
'updated_at',
'created_at'
)
5 changes: 5 additions & 0 deletions source/apiVolontaria/ckeditor_api/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class CkeditorApiConfig(AppConfig):
name = 'ckeditor_api'
24 changes: 24 additions & 0 deletions source/apiVolontaria/ckeditor_api/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 2.2.10 on 2020-03-18 21:25

from django.db import migrations, models


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='CKEditorPage',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('key', models.CharField(max_length=255, unique=True, verbose_name='Key')),
('data', models.TextField(blank=True, verbose_name='Data')),
('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created at')),
('updated_at', models.DateTimeField(auto_now=True, verbose_name='Updated at')),
],
),
]
Empty file.
29 changes: 29 additions & 0 deletions source/apiVolontaria/ckeditor_api/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from django.db import models
from django.utils.translation import ugettext_lazy as _


class CKEditorPage(models.Model):

key = models.CharField(
verbose_name=_('Key'),
unique=True,
max_length=255
)

data = models.TextField(
verbose_name=_('Data'),
blank=True
)

created_at = models.DateTimeField(
verbose_name=_('Created at'),
auto_now_add=True
)

updated_at = models.DateTimeField(
verbose_name=_('Updated at'),
auto_now=True
)

def __str__(self):
return self.key
13 changes: 13 additions & 0 deletions source/apiVolontaria/ckeditor_api/serializers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from rest_framework import serializers

from .models import (
CKEditorPage
)


class CKEditorPageSerializer(serializers.HyperlinkedModelSerializer):
id = serializers.ReadOnlyField()

class Meta:
model = CKEditorPage
fields = '__all__'
23 changes: 23 additions & 0 deletions source/apiVolontaria/ckeditor_api/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from rest_framework.routers import SimpleRouter
from django.urls import path
from django.conf.urls import include

from . import views


class OptionalSlashSimpleRouter(SimpleRouter):
""" Subclass of SimpleRouter to make the trailing slash optional """

def __init__(self, *args, **kwargs):
super(SimpleRouter, self).__init__(*args, **kwargs)
self.trailing_slash = '/?'


app_name = "ckeditor_api"

ckeditor_router = OptionalSlashSimpleRouter()
ckeditor_router.register('ckeditor_page', views.CKEditorPageViewSet)

urlpatterns = [
path('', include(ckeditor_router.urls)), # includes router generated URL
]
16 changes: 16 additions & 0 deletions source/apiVolontaria/ckeditor_api/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from rest_framework import viewsets

from apiVolontaria import permissions
from .models import (
CKEditorPage
)

from . import serializers


class CKEditorPageViewSet(viewsets.ModelViewSet):

serializer_class = serializers.CKEditorPageSerializer
queryset = CKEditorPage.objects.all()
filterset_fields = '__all__'
permission_classes = [permissions.IsAdminOrReadOnly]
2 changes: 1 addition & 1 deletion source/apiVolontaria/location/tests/tests_model_Address.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from django.core.exceptions import ValidationError

from ..models import Address, Country, StateProvince
from location.models import Address, Country, StateProvince


class AddressTests(APITestCase):
Expand Down
2 changes: 1 addition & 1 deletion source/apiVolontaria/location/tests/tests_model_Country.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rest_framework.test import APITestCase

from ..models import Country
from location.models import Country


class CountryTests(APITestCase):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from rest_framework.test import APITestCase

from ..models import Country, StateProvince
from location.models import Country, StateProvince


class StateProvinceTests(APITestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rest_framework.test import APIClient, APITestCase

from apiVolontaria.factories import UserFactory, AdminFactory
from ..models import Address, Country, StateProvince
from location.models import Address, Country, StateProvince


class AddressesTests(APITestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rest_framework.test import APIClient, APITestCase

from apiVolontaria.factories import UserFactory, AdminFactory
from ..models import Country
from location.models import Country


class CountriesTests(APITestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from rest_framework.test import APIClient, APITestCase

from apiVolontaria.factories import UserFactory, AdminFactory
from ..models import StateProvince, Country
from location.models import StateProvince, Country


class StateProvincesTests(APITestCase):
Expand Down
Loading

0 comments on commit 73f3406

Please sign in to comment.