Adding new origin and spendable fields. (WIP), PEP8, ..)

This commit is contained in:
Xavier Fiechter 2023-08-09 00:08:02 +02:00
parent 20c0a1b05a
commit 49a6fa627c
11 changed files with 154 additions and 39 deletions

View file

@ -22,6 +22,10 @@ class Labelbase(models.Model):
class Label(models.Model):
"""
Reference:
https://github.com/bitcoin/bips/blob/master/bip-0329.mediawiki
"""
TYPE_TX = "tx"
TYPE_ADDR = "addr"
TYPE_PUBKEY = "pubkey"
@ -56,6 +60,28 @@ class Label(models.Model):
blank=True,
)
)
origin = encrypt(
models.CharField(
help_text=("Optional key origin information referencing the wallet "
"associated with the label. The origin property should "
"only appear where type is 'tx'.")
max_length=160,
default="",
blank=True,
)
)
spendable = encrypt(
models.BooleanField(
help_text=("One of true or false, denoting if an output should be "
"spendable by the wallet. The spendable property only "
"where type is 'output'.")
max_length=160,
default=False,
)
)
labelbase = models.ForeignKey(Labelbase, on_delete=models.CASCADE)
def get_absolute_url(self):

View file

@ -1,3 +0,0 @@
from django.test import TestCase
# Create your tests here.

View file

@ -128,8 +128,7 @@ DATABASES = {
"USER": proj_config.get("database", "user"),
"OPTIONS": {"charset": "utf8mb4"},
"PASSWORD": proj_config.get("database", "password"),
#'HOST': 'de', # This should match the service name defined in the docker-compose.yml for the MySQL container.
'HOST': proj_config.get("database", "localhost"),
'HOST': 'localhost',
'PORT': 3306,
}
}

View file

@ -21,6 +21,7 @@ from .views import (
LabelbaseFormView,
LabelbaseUpdateView,
FaqView,
AboutView,
)
from importer.views import upload_labels
from exporter.views import stream_labels_as_jsonl
@ -29,12 +30,31 @@ from django.contrib.auth import views as auth_views
urlpatterns = [
# path('api/labelbase/<int:labelbase_id>/label/<int:id>/', api.label),
path("api/v0/labelbase/", LabelbaseAPIView.as_view()),
path("api/v0/labelbase/<int:id>/", LabelbaseAPIView.as_view()),
path("api/v0/labelbase/<int:labelbase_id>/label/", LabelAPIView.as_view()),
path("api/v0/labelbase/<int:labelbase_id>/label/<int:id>/", LabelAPIView.as_view()),
path("api-reference/", include_docs_urls(title="Labelbase API")),
path("account/apikey/", login_required(APIKeyView.as_view()), name="apikey"),
path(
"api/v0/labelbase/",
LabelbaseAPIView.as_view()
),
path(
"api/v0/labelbase/<int:id>/",
LabelbaseAPIView.as_view()
),
path(
"api/v0/labelbase/<int:labelbase_id>/label/",
LabelAPIView.as_view()
),
path(
"api/v0/labelbase/<int:labelbase_id>/label/<int:id>/",
LabelAPIView.as_view()
),
path(
"api-reference/",
include_docs_urls(title="Labelbase API")
),
path(
"account/apikey/",
login_required(APIKeyView.as_view()),
name="apikey"
),
path(
"account/userprofile/",
login_required(ProfileView.as_view()),
@ -55,14 +75,18 @@ urlpatterns = [
login_required(LabelbaseUpdateView.as_view()),
name="edit_labelbase",
),
path("labelbase/import/", upload_labels, name="import_labels"),
path("labelbase/import/",
upload_labels,
name="import_labels"),
path(
"labelbase/export/<int:labelbase_id>/",
stream_labels_as_jsonl,
name="export_labels",
),
path(
"labelbase/", login_required(LabelbaseFormView.as_view()), name="labelbase_new"
"labelbase/",
login_required(LabelbaseFormView.as_view()),
name="labelbase_new"
),
# path('labelbase/<int:labelbase_id>/label/<int:label_id>/edit/', login_required(LabelUpdateView.as_view()), name='edit_label'),
path(
@ -75,8 +99,15 @@ urlpatterns = [
login_required(LabelDeleteView.as_view()),
name="del_label",
),
path("account/logout/", LogoutView.as_view(), name="logout"),
path("account/register/", RegistrationView.as_view(), name="registration"),
path(
"account/logout/",
LogoutView.as_view(),
name="logout"
),
path(
"account/register/",
RegistrationView.as_view(),
name="registration"),
path(
"account/register/done/",
RegistrationCompleteView.as_view(),
@ -85,15 +116,40 @@ urlpatterns = [
path(
"account/change-password/",
auth_views.PasswordChangeView.as_view(
template_name="change_password.html", success_url="/"
template_name="change_password.html",
success_url="/"
),
name="change_password",
),
path("privacy-policy", PrivacyView.as_view(), name="privacy_policy"),
path("terms", TermsView.as_view(), name="terms"),
path("faq", FaqView.as_view(), name="faq"),
path("", HomeView.as_view(), name="home"),
path("", include(tf_urls)),
path("", include("user_sessions.urls", "user_sessions")),
path("admin/", admin.site.urls),
path(
"privacy-policy",
PrivacyView.as_view(),
name="privacy_policy"),
path(
"terms",
TermsView.as_view(),
name="terms"),
path(
"faq",
FaqView.as_view(),
name="faq"),
path(
"about",
AboutView.as_view(),
name="about"),
path(
"",
HomeView.as_view(),
name="home"),
path(
"",
include(tf_urls)),
path(
"",
include("user_sessions.urls", "user_sessions")
),
path(
"admin/",
admin.site.urls
),
]

View file

@ -16,6 +16,9 @@ from labelbase.forms import LabelForm, LabelbaseForm
from django.http import HttpResponseRedirect
from rest_framework.authtoken.models import Token
class AboutView(TemplateView):
template_name = "about.html"
class HomeView(TemplateView):
template_name = "home.html"

View file

@ -269,6 +269,9 @@ body {
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted text-uppercase">
<span>&nbsp;</span>
</h6>
<li class="nav-item ">
<a class="nav-link" href="{% url 'about' %}">About</a>
<li>
<li class="nav-item ">
<a class="nav-link" href="{% url 'faq' %}">FAQ</a>
<li>

34
templates/about.html Normal file
View file

@ -0,0 +1,34 @@
{% extends "_base.html" %}
{% load i18n %}
{% block title %}About{% endblock %}
{% block nav_home %}active{% endblock %}
{% block content %}
<style>
.lb-header {
max-width: 810px;
}
</style>
<div class="p-3 pb-md-4 mx-auto text-center">
<h1 style="padding-top: 1.6em; padding-bottom: 0.9em; text-transform: uppercase;font-weight:800;">L<span style="height:1.1em; width:1em" data-feather="tag" class="align-text-bottom"></span>belbase</h1>
<h2 class="display-6 fw-normal" style="padding-bottom: 0.9em;">All your labels in one place.</h2>
</div>
<div class="lb-header p-3 pb-md-4 mx-auto text-left">
<h2 class="display-8 fw-normal">About</h2>
<p class="fs-5 text-muted">
<ol style="line-height:2em; ">
<li>
</li>
</ol>
</p>
</div>
{% endblock %}

View file

@ -8,7 +8,7 @@
<style>
.pricing-header {
.lb-header {
max-width: 810px;
}
</style>
@ -20,7 +20,7 @@
<div class="pricing-header p-3 pb-md-4 mx-auto text-left">
<div class="lb-header p-3 pb-md-4 mx-auto text-left">
<h2 class="display-8 fw-normal">Frequently Asked Questions</h2>
<p>
</p>
@ -48,7 +48,7 @@
</ol>
</p>
</div>
{#% include "footer.html" %#}
{% comment %}

View file

@ -1,30 +1,27 @@
{% extends "_base.html" %}
{% load i18n %}
{% block title %}Labelbase{% endblock %}
{% block nav_home %}active{% endblock %}
{% block content %}
<style>
.pricing-header {
.lb-header {
max-width: 810px;
}
</style>
<div class="p-3 pb-md-4 mx-auto text-center">
<h1 style="padding-top: 1.6em; padding-bottom: 0.9em; text-transform: uppercase;font-weight:800;">L<span style="height:1.1em; width:1em" data-feather="tag" class="align-text-bottom"></span>belbase</h1>
<h2 class="display-6 fw-normal" style="padding-bottom: 0.9em;">All your labels in one place.</h2>
<p class="pricing-header mx-auto text-center fs-5 text-muted">Labelbase is a label management service for Bitcoin transactions and addresses.</p>
<p class="pricing-header mx-auto text-center fs-5 text-muted">Labelbase provides features for adding labels, importing and exporting labels, and offers a public API for integration with wallets and existing workflows.<br>
<p class="lb-header mx-auto text-center fs-5 text-muted">Labelbase is a label management service for Bitcoin transactions and addresses.</p>
<p class="lb-header mx-auto text-center fs-5 text-muted">Labelbase provides features for adding labels, importing and exporting labels, and offers a <a href="/api-reference/">public API</a> for integration with wallets and existing workflows.<br>
This ensures that you always have access to the most up-to-date information.</p>
<p class="pricing-header mx-auto text-center fs-5 text-muted"> Labelbase supports BIP-329, a format for unifying label data.</p>
<p class="lb-header mx-auto text-center fs-5 text-muted"> Labelbase supports BIP-329, a format for unifying label data.</p>
</div>
<main class="pricing-header mx-auto text-center">
<main class="lb-header mx-auto text-center">
<div class="row row-cols-1 row-cols-md-3 mb-3 text-center">
<div class="col">
@ -75,7 +72,7 @@
{% if request.user.is_superuser %}
{% comment %}
<main class="pricing-header mx-auto text-center">
<main class="lb-header mx-auto text-center">
<div class="row row-cols-1 row-cols-md-3 mb-3 text-center">
<div class="col">

View file

@ -8,7 +8,7 @@
<style>
.pricing-header {
.lb-header {
max-width: 810px;
}
</style>
@ -20,7 +20,7 @@
<div class="pricing-header p-3 pb-md-4 mx-auto text-left">
<div class="lb-header p-3 pb-md-4 mx-auto text-left">
<h2 class="display-8 fw-normal">Privacy Policy</h2>
<small>The privacy policy on this website specifically applies to the labelbase.space web application, which is hosted by the Labelbase team.<br>Last updated: July 26<sup>th</sup> 2023.</small>

View file

@ -8,7 +8,7 @@
<style>
.pricing-header {
.lb-header {
max-width: 810px;
}
</style>
@ -20,7 +20,7 @@
<div class="pricing-header p-3 pb-md-4 mx-auto text-left">
<div class="lb-header p-3 pb-md-4 mx-auto text-left">
<h2 class="display-8 fw-normal">Terms of Service</h2>
<small>February 10<sup>th</sup> 2023</small>
<p class="fs-5 text-muted">