import logging
import socket
import collections
import os

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
SECRET = ''
DEBUG = True

COIN_ADDRESS_LENGTH = 97
COINCODE = ''
PSQL_USER = ''
PSQL_PASS = ''
PSQL_DB = ''

SQLALCHEMY_DATABASE_URI = os.environ.get('SQLALCHEMY_DATABASE_URI', 'postgresql://{user}:{pw}@localhost/{db}').format(user=PSQL_USER, pw=PSQL_PASS, db=PSQL_DB)

SESSION_COOKIE_NAME = os.environ.get('{coincode}_SESSION_COOKIE_NAME', '{coincode}_id').format(coincode=COINCODE.upper())
SESSION_PREFIX = os.environ.get('{coincode}_SESSION_PREFIX', 'session:').format(coincode=COINCODE.upper())

REDIS_HOST = os.environ.get('REDIS_HOST', '127.0.0.1')
REDIS_PORT = int(os.environ.get('REDIS_PORT', 6379))
REDIS_PASSWD = os.environ.get('REDIS_PASSWD', None)

BIND_HOST = os.environ.get("BIND_HOST", "0.0.0.0")
if not BIND_HOST:
    raise Exception("BIND_HOST missing")
BIND_PORT = os.environ.get("BIND_PORT", 5004)
if not BIND_PORT:
    raise Exception("BIND_PORT missing")

HOSTNAME = os.environ.get("{coincode}_HOSTNAME", socket.gethostname()).format(coincode=COINCODE.upper())

# If using a local RPC, no need for --rpc-login credentials unless you're binding wallet-rpc to 0.0.0.0. If you are, you're bad.
# elif, remote wallet-rpc, enable --rpc-login and enter credentials below.
RPC_HOST = '127.0.0.1'
RPC_PORT = '11182'
RPC_LOCATION = "http://{host}:{rpc_port}/json_rpc".format(host=RPC_HOST, rpc_port=RPC_PORT)
RPC_USERNAME = ""
RPC_PASSWORD = ""

FUNDING_CATEGORIES = [
    'wallets',
    'marketing',
    'core',
    'misc',
    'design'
]

FUNDING_STATUSES = collections.OrderedDict()
FUNDING_STATUSES[0] = 'disabled'
FUNDING_STATUSES[1] = 'proposal'
FUNDING_STATUSES[2] = 'funding'
FUNDING_STATUSES[3] = 'wip'
FUNDING_STATUSES[4] = 'completed'

USER_REG_DISABLED = False

PROPOSAL_CONTENT_DEFAULT = """
#### Why?

What problem(s) are you trying to solve?

#### How much?

What is the total cost in {coincode}? List expenses per item. Total hours of work and per hour rate. What exchange rates are you using?

#### What?

Describe your idea in detail.

#### Milestones?

Break down tasks into different stages. Each stage should have the estimated number of days/weeks needed and cost per stage.

#### Outcomes?

What will be delivered? What goals will be reached?

#### Why you?

What skills and experience do you have?
""".strip().format(coincode=COINCODE.upper())