1
0

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:
2022-06-04 10:41:53 +02:00
commit c75ea4ea9d
111 changed files with 7193 additions and 0 deletions

View File

@@ -0,0 +1 @@
/db.sqlite3

View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class TestingConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'testing'

View 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

View File

@@ -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',
},
),
]

View 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,
}

View 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 = [
]

View 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()),
]