Skip to content

Commit

Permalink
add default values to config
Browse files Browse the repository at this point in the history
  • Loading branch information
F-Node-Karlsruhe committed Jul 7, 2021
1 parent 809a83e commit ce439d7
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 48 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Alter the following variables in the `.env` file:
Default Value: _null_. Set to the admin key of a custom integration. Can be generated in the admin dashboard ([Custom Integration](https://ghost.org/integrations/custom-integrations/))

- `DEFAULT_IOTA_ADDRESS`
Default Value: _null_. Set to the IOTA Address which is owned by the blog. The application will listen there for incoming payments.
Default Value: `NO ADDRESS GIVEN`. Set to the IOTA Address which is owned by the blog. The application will listen there for incoming payments.

- `NODE_URL`
Default Value: `https://api.hornet-1.testnet.chrysalis2.com`. Set to the url of your prefered node.
Expand Down
19 changes: 4 additions & 15 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
import secrets
from utils.hash import hash_user_token
from services.ghost_api import get_post, get_post_payment
from config import (SECRET_KEY,
DATABASE_LOCATION,
SESSION_LIFETIME,
URL, ADMIN_PANEL,
ADMIN_USER,
ADMIN_PW)
from config.settings import (SESSION_LIFETIME,
URL,
ADMIN_PANEL)
import os
from services.iota import Listener
from datetime import datetime, timedelta
Expand All @@ -30,15 +27,7 @@

app = Flask(__name__.split('.')[0])

app.config['SECRET_KEY'] = SECRET_KEY

app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_LOCATION

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

app.config['BASIC_AUTH_USERNAME'] = ADMIN_USER

app.config['BASIC_AUTH_PASSWORD'] = ADMIN_PW
app.config.from_object('config.flask')

# create web socket for async communication
socketio = SocketIO(app, async_mode='threading', cors_allowed_origins="*")
Expand Down
25 changes: 0 additions & 25 deletions config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
from dotenv import load_dotenv
from os import getenv

load_dotenv()

SECRET_KEY = getenv('SECRET_KEY')

DEFAULT_PRICE = int(getenv('PRICE_PER_CONTENT'))

DATABASE_LOCATION = 'sqlite:///data/db.sqlite3'

SESSION_LIFETIME = int(getenv('SESSION_LIFETIME'))

URL = getenv('URL')

DEFAULT_IOTA_ADDRESS= getenv('DEFAULT_IOTA_ADDRESS')

AUTHOR_ADDRESSES= getenv('AUTHOR_ADDRESSES') == 'true'

NODE_URL = getenv('NODE_URL')

GHOST_ADMIN_KEY = getenv('GHOST_ADMIN_KEY')

ADMIN_PANEL = getenv('ADMIN_PANEL') == 'true'

ADMIN_USER = getenv('ADMIN_USER')

ADMIN_PW = getenv('ADMIN_PW')
12 changes: 12 additions & 0 deletions config/flask.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from os import getenv
from distutils.util import strtobool

SECRET_KEY = getenv('SECRET_KEY', None)

SQLALCHEMY_DATABASE_URI = getenv('SQLALCHEMY_DATABASE_URI', 'sqlite:///data/db.sqlite3')

SQLALCHEMY_TRACK_MODIFICATIONS = bool(strtobool(getenv('SQLALCHEMY_TRACK_MODIFICATIONS', 'false')))

BASIC_AUTH_USERNAME = getenv('ADMIN_USER', 'admin')

BASIC_AUTH_PASSWORD = getenv('ADMIN_PW', 'admin')
18 changes: 18 additions & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from os import getenv
from distutils.util import strtobool

SESSION_LIFETIME = int(getenv('SESSION_LIFETIME', 24))

URL = getenv('URL', 'http://localhost:2368')

DEFAULT_IOTA_ADDRESS= getenv('DEFAULT_IOTA_ADDRESS', 'NO ADDRESS GIVEN')

DEFAULT_PRICE = int(getenv('PRICE_PER_CONTENT', 1000000))

AUTHOR_ADDRESSES= bool(strtobool(getenv('AUTHOR_ADDRESSES', 'false')))

NODE_URL = getenv('NODE_URL', 'https://api.hornet-1.testnet.chrysalis2.com')

GHOST_ADMIN_KEY = getenv('GHOST_ADMIN_KEY')

ADMIN_PANEL = bool(strtobool(getenv('ADMIN_PANEL', 'false')))
2 changes: 1 addition & 1 deletion database/models/authors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from database.db import db
from config import DEFAULT_IOTA_ADDRESS
from config.settings import DEFAULT_IOTA_ADDRESS

class Author(db.Model):
id = db.Column(db.Integer, primary_key=True)
Expand Down
2 changes: 1 addition & 1 deletion database/models/slugs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from database.db import db
from config import DEFAULT_PRICE
from config.settings import DEFAULT_PRICE

class Slug(db.Model):
slug = db.Column(db.String(128), primary_key=True)
Expand Down
2 changes: 1 addition & 1 deletion database/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from database.models.slugs import Slug

from services.ghost_api import slug_exists, get_post_data
from config import DEFAULT_IOTA_ADDRESS, AUTHOR_ADDRESSES
from config.settings import DEFAULT_IOTA_ADDRESS, AUTHOR_ADDRESSES

socket_sessions = {}

Expand Down
2 changes: 1 addition & 1 deletion services/ghost_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime as date
import os
from bs4 import BeautifulSoup
from config import URL, GHOST_ADMIN_KEY
from config.settings import URL, GHOST_ADMIN_KEY


# Split the key into ID and SECRET
Expand Down
3 changes: 1 addition & 2 deletions services/iota.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import json
import logging
from datetime import datetime, timedelta
import os
from config import SESSION_LIFETIME, NODE_URL
from config.settings import SESSION_LIFETIME, NODE_URL

from database.operations import get_iota_listening_addresses, add_access, is_own_address, get_socket_session, get_slug_price_for_hash

Expand Down
2 changes: 1 addition & 1 deletion test_wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
SEED = USER_SEED
RECIPIENT_ADDRESS = 'atoi1qq4tuenpv2cxlcg7hd2lem6q7qzvt5wlapmtfj92nskpmuq9luqtqyguj6x'
INDEX = "ghost-iota-pay"
DATA = "7485b5f5ea094bd449b5b0077c0b7b3d47108a3a5197be5bfb427ffe4186530d".encode()
DATA = "ee398d5c2373add55c19cdbc4f70a0cce31bda4aed7ec224a55734384649f377".encode()
# Chrysalis testnet node
client = iota_client.Client()

Expand Down

0 comments on commit ce439d7

Please sign in to comment.