-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
14691e7
commit d7dccad
Showing
15 changed files
with
1,031 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2025, Dropseed, LLC | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!-- This file is compiled from plain-api/plain/api/README.md. Do not edit this file directly. --> | ||
|
||
# plain.api |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# plain.api |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from plain.packages import PackageConfig | ||
|
||
|
||
class Config(PackageConfig): | ||
name = "plain.api" | ||
label = "plainapi" # Primarily for migrations |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# from bolt.exceptions import ValidationError | ||
|
||
# class APIFormMixin: | ||
# def clean(self): | ||
# cleaned_data = super().clean() | ||
|
||
# # Make sure all the field names are present in the input data | ||
# for name, field in self.fields.items(): | ||
# if name not in self.data: | ||
# raise ValidationError(f"Missing field {name}") | ||
|
||
# return cleaned_data | ||
|
||
|
||
class APIPartialFormMixin: | ||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
|
||
# If any field is not present in the JSON input, | ||
# then act as if it's "disabled" so Bolt | ||
# will keep the initial value instead of setting it to the default. | ||
# This is required because stuff like checkbox doesn't submit in HTML form data when false. | ||
for name, field in self.fields.items(): | ||
if name not in self.data: | ||
field.disabled = True |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Plain 0.17.0 on 2025-01-22 20:02 | ||
|
||
import uuid | ||
|
||
import plain.api.models | ||
from plain import models | ||
from plain.models import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
initial = True | ||
|
||
dependencies = [] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="APIKey", | ||
fields=[ | ||
("id", models.BigAutoField(auto_created=True, primary_key=True)), | ||
( | ||
"uuid", | ||
models.UUIDField(default=uuid.uuid4, editable=False, unique=True), | ||
), | ||
("created_at", models.DateTimeField(auto_now_add=True)), | ||
("updated_at", models.DateTimeField(auto_now=True)), | ||
("last_used_at", models.DateTimeField(blank=True, null=True)), | ||
("name", models.CharField(blank=True, max_length=255)), | ||
( | ||
"token", | ||
models.CharField( | ||
default=plain.api.models.generate_token, | ||
max_length=40, | ||
unique=True, | ||
), | ||
), | ||
], | ||
), | ||
] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Plain 0.17.0 on 2025-01-22 21:02 | ||
|
||
from plain import models | ||
from plain.models import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("plainapi", "0001_initial"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="apikey", | ||
name="expires_at", | ||
field=models.DateTimeField(blank=True, null=True), | ||
), | ||
] |
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import binascii | ||
import os | ||
import uuid | ||
|
||
from plain import models | ||
|
||
|
||
def generate_token(): | ||
return binascii.hexlify(os.urandom(20)).decode() | ||
|
||
|
||
class APIKey(models.Model): | ||
uuid = models.UUIDField(default=uuid.uuid4, editable=False, unique=True) | ||
created_at = models.DateTimeField(auto_now_add=True) | ||
updated_at = models.DateTimeField(auto_now=True) | ||
expires_at = models.DateTimeField(blank=True, null=True) | ||
last_used_at = models.DateTimeField(blank=True, null=True) | ||
|
||
name = models.CharField(max_length=255, blank=True) | ||
|
||
token = models.CharField(max_length=40, default=generate_token, unique=True) | ||
|
||
# Connect to a user, for example, from your own model: | ||
# api_key = models.OneToOneField( | ||
# APIKey, | ||
# on_delete=models.CASCADE, | ||
# related_name="user", | ||
# null=True, | ||
# blank=True, | ||
# ) | ||
|
||
def __str__(self): | ||
return self.name or str(self.uuid) |
Oops, something went wrong.