You've already forked bthlabs-jsonrpc
Initial public releases
* `bthlabs-jsonrpc-aiohttp` v1.0.0 * `bthlabs-jsonrpc-core` v1.0.0 * `bthlabs-jsonrpc-django` v1.0.0
This commit is contained in:
1
packages/bthlabs-jsonrpc-django/testing/.gitignore
vendored
Normal file
1
packages/bthlabs-jsonrpc-django/testing/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/db.sqlite3
|
||||
0
packages/bthlabs-jsonrpc-django/testing/__init__.py
Normal file
0
packages/bthlabs-jsonrpc-django/testing/__init__.py
Normal file
6
packages/bthlabs-jsonrpc-django/testing/apps.py
Normal file
6
packages/bthlabs-jsonrpc-django/testing/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class TestingConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'testing'
|
||||
14
packages/bthlabs-jsonrpc-django/testing/factories.py
Normal file
14
packages/bthlabs-jsonrpc-django/testing/factories.py
Normal file
@@ -0,0 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import factory
|
||||
|
||||
from testing.models import Thing
|
||||
|
||||
|
||||
class ThingFactory(factory.django.DjangoModelFactory):
|
||||
name = factory.Faker('name')
|
||||
content = factory.Faker('sentence')
|
||||
is_active = True
|
||||
owner = None
|
||||
|
||||
class Meta:
|
||||
model = Thing
|
||||
@@ -0,0 +1,33 @@
|
||||
# Generated by Django 4.0.4 on 2022-05-13 06:44
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Thing',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
('content', models.TextField()),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('modified_at', models.DateTimeField(auto_now=True)),
|
||||
('is_active', models.BooleanField(db_index=True, default=True)),
|
||||
('owner', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'thing',
|
||||
'verbose_name_plural': 'things',
|
||||
},
|
||||
),
|
||||
]
|
||||
29
packages/bthlabs-jsonrpc-django/testing/models.py
Normal file
29
packages/bthlabs-jsonrpc-django/testing/models.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Thing(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
content = models.TextField()
|
||||
created_at = models.DateTimeField(auto_now=False, auto_now_add=True)
|
||||
modified_at = models.DateTimeField(auto_now=True, auto_now_add=False)
|
||||
is_active = models.BooleanField(default=True, db_index=True)
|
||||
|
||||
owner = models.ForeignKey(
|
||||
'auth.User', null=True, blank=True, on_delete=models.CASCADE,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'thing'
|
||||
verbose_name_plural = 'things'
|
||||
|
||||
def to_rpc(self):
|
||||
return {
|
||||
'id': self.pk,
|
||||
'name': self.name,
|
||||
'content': self.content,
|
||||
'created_at': self.created_at,
|
||||
'modified_at': self.modified_at,
|
||||
'is_active': self.is_active,
|
||||
'owner_id': self.owner_id,
|
||||
}
|
||||
77
packages/bthlabs-jsonrpc-django/testing/settings.py
Normal file
77
packages/bthlabs-jsonrpc-django/testing/settings.py
Normal file
@@ -0,0 +1,77 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pathlib import Path
|
||||
|
||||
BASE_DIR = Path(__file__).resolve().parent
|
||||
|
||||
SECRET_KEY = 'bthlabs_jsonrpc_django'
|
||||
DEBUG = False
|
||||
ALLOWED_HOSTS = ['*']
|
||||
|
||||
INSTALLED_APPS = [
|
||||
# Django apps
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
|
||||
# 3rd party apps
|
||||
'bthlabs_jsonrpc_django',
|
||||
|
||||
# Project apps
|
||||
'testing',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
]
|
||||
|
||||
ROOT_URLCONF = 'testing.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [],
|
||||
'APP_DIRS': True,
|
||||
'OPTIONS': {
|
||||
'context_processors': [
|
||||
'django.template.context_processors.debug',
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
},
|
||||
}
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
},
|
||||
]
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
TIME_ZONE = 'UTC'
|
||||
USE_I18N = True
|
||||
USE_TZ = True
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
JSONRPC_METHOD_MODULES = [
|
||||
]
|
||||
15
packages/bthlabs-jsonrpc-django/testing/urls.py
Normal file
15
packages/bthlabs-jsonrpc-django/testing/urls.py
Normal file
@@ -0,0 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from django.urls import path
|
||||
|
||||
from bthlabs_jsonrpc_django import JSONRPCView, is_authenticated
|
||||
|
||||
urlpatterns = [
|
||||
path(
|
||||
'rpc/private',
|
||||
JSONRPCView.as_view(
|
||||
auth_checks=[is_authenticated],
|
||||
namespace='private',
|
||||
),
|
||||
),
|
||||
path('rpc', JSONRPCView.as_view()),
|
||||
]
|
||||
Reference in New Issue
Block a user