mirror of
https://git.wownero.com/wownero/wownero-funding-system.git
synced 2024-08-15 00:53:45 +00:00
Added the development fund page
This commit is contained in:
parent
25caa397fd
commit
e94176215c
5 changed files with 163 additions and 10 deletions
|
@ -1,12 +1,18 @@
|
|||
import settings
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
from requests.auth import HTTPDigestAuth
|
||||
|
||||
import settings
|
||||
from funding.orm.orm import User
|
||||
|
||||
|
||||
class Daemon:
|
||||
def __init__(self, url=None, username=None, password=None):
|
||||
self.url = url
|
||||
self.username = username
|
||||
self.password = password
|
||||
|
||||
if url is None:
|
||||
self.url = settings.RPC_LOCATION
|
||||
if username is None:
|
||||
|
@ -86,14 +92,12 @@ class Daemon:
|
|||
return
|
||||
|
||||
def get_transfers_in(self, proposal):
|
||||
daemon = Daemon()
|
||||
|
||||
account = daemon.get_accounts(proposal.id)
|
||||
account = self.get_accounts(proposal.id)
|
||||
if not account:
|
||||
raise Exception('wallet error; pid not found found')
|
||||
index = account['account_index']
|
||||
|
||||
address = daemon.get_address(index, proposal_id=proposal.id)
|
||||
address = self.get_address(index, proposal_id=proposal.id)
|
||||
if not address:
|
||||
print('Could not fetch transfers_in for proposal id %d' % proposal.id)
|
||||
return {'sum': [], 'txs': []}
|
||||
|
@ -119,16 +123,38 @@ class Daemon:
|
|||
'sum': sum([float(z['amount'])/1e11 for z in txs]),
|
||||
'txs': txs
|
||||
}
|
||||
|
||||
def get_transfers_out(self, proposal):
|
||||
daemon = Daemon()
|
||||
|
||||
account = daemon.get_accounts(proposal.id)
|
||||
def get_transfers_in_simple(self):
|
||||
data = {
|
||||
"method": "get_transfers",
|
||||
"params": {"pool": True, "in": True},
|
||||
"jsonrpc": "2.0",
|
||||
"id": "0",
|
||||
}
|
||||
|
||||
data = self._make_request(data)
|
||||
data = data['result']
|
||||
data = data.get('in', []) + data.get('pool', [])
|
||||
|
||||
for d in data:
|
||||
d['datetime'] = datetime.fromtimestamp(d['timestamp'])
|
||||
d['amount_human'] = float(d['amount'])/1e11
|
||||
|
||||
# most recent tx first
|
||||
data = sorted(data, key=lambda k: k['datetime'], reverse=True)
|
||||
|
||||
return {
|
||||
'sum': sum([float(z['amount'])/1e11 for z in data]),
|
||||
'txs': data
|
||||
}
|
||||
|
||||
def get_transfers_out(self, proposal):
|
||||
account = self.get_accounts(proposal.id)
|
||||
if not account:
|
||||
raise Exception('wallet error; pid not found found')
|
||||
index = account['account_index']
|
||||
|
||||
address = daemon.get_address(index, proposal_id=proposal.id)
|
||||
address = self.get_address(index, proposal_id=proposal.id)
|
||||
if not address:
|
||||
print('Could not fetch transfers_in for proposal id %d' % proposal.id)
|
||||
return {'sum': [], 'txs': []}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
from datetime import datetime
|
||||
|
||||
from flask import request, redirect, Response, abort, render_template, url_for, flash, make_response, send_from_directory, jsonify
|
||||
from flask.ext.login import login_user , logout_user , current_user, login_required, current_user
|
||||
from dateutil.parser import parse as dateutil_parse
|
||||
from flask_yoloapi import endpoint, parameter
|
||||
|
||||
import settings
|
||||
|
@ -236,6 +238,34 @@ def proposals(status, page, cat):
|
|||
proposals=proposals, status=status, cat=cat))
|
||||
|
||||
|
||||
@app.route('/fund')
|
||||
def devfund():
|
||||
from funding.bin.daemon import Daemon
|
||||
from funding.factory import cache, db_session
|
||||
|
||||
data_default = {'sum': 0, 'txs': []}
|
||||
cache_key = 'devfund_txs_in'
|
||||
data = cache.get(cache_key)
|
||||
if not data:
|
||||
daemon = Daemon(url=settings.RPC_LOCATION_DEVFUND,
|
||||
username=settings.RPC_USERNAME_DEVFUND,
|
||||
password=settings.RPC_PASSWORD_DEVFUND
|
||||
)
|
||||
|
||||
txs_in = daemon.get_transfers_in_simple()
|
||||
if not txs_in['txs']:
|
||||
cache.set(cache_key, data=data_default, expiry=60)
|
||||
else:
|
||||
txs_in['txs'] = txs_in['txs'][:50] # truncate to last 50
|
||||
cache.set(cache_key, data=txs_in, expiry=60)
|
||||
else:
|
||||
for tx in data['txs']:
|
||||
tx['datetime'] = dateutil_parse(tx['datetime'])
|
||||
txs_in = data
|
||||
|
||||
return make_response(render_template('devfund.html', txs_in=txs_in))
|
||||
|
||||
|
||||
@app.route('/register', methods=['GET', 'POST'])
|
||||
def register():
|
||||
if settings.USER_REG_DISABLED:
|
||||
|
|
|
@ -616,4 +616,45 @@ ul.b {
|
|||
|
||||
.table-proposal tr {
|
||||
background: #00000005;
|
||||
}
|
||||
|
||||
.tx_item {
|
||||
padding-top: 4px;
|
||||
padding-bottom: 4px;
|
||||
background: #ffffff80;
|
||||
}
|
||||
|
||||
.tx_item .amount {
|
||||
float:right;
|
||||
font-weight:bold;
|
||||
color:#890000;
|
||||
}
|
||||
|
||||
.tx_item .amount.in {
|
||||
color:#008926;
|
||||
}
|
||||
|
||||
.tx_item .datetime {
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.tx_item .height {
|
||||
float:right
|
||||
}
|
||||
|
||||
.tx_item .height b {
|
||||
font-size:14px;
|
||||
}
|
||||
|
||||
.page_devfund .tx_item {
|
||||
padding-left: .85rem;
|
||||
padding-right: .85rem;
|
||||
}
|
||||
|
||||
.container>.content h1,
|
||||
.container>.content h2,
|
||||
.container>.content h3,
|
||||
.container>.content h4{
|
||||
margin-bottom:20px;
|
||||
}
|
50
funding/templates/devfund.html
Normal file
50
funding/templates/devfund.html
Normal file
|
@ -0,0 +1,50 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
|
||||
<div class="container page_devfund">
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<h2>Development Fund</h2>
|
||||
<p>
|
||||
Ongoing development is supported by donations and sponsorships.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row content">
|
||||
<div class="col-lg-8">
|
||||
<hr>
|
||||
<h3>Donating Wownero</h3>
|
||||
<p>
|
||||
Donations may be sent to: <code style="word-wrap: break-word">Wo3MWeKwtA918DU4c69hVSNgejdWFCRCuWjShRY66mJkU2Hv58eygJWDJS1MNa2Ge5M1WjUkGHuLqHkweDxwZZU42d16v94mP</code>
|
||||
</p>
|
||||
<img style="margin-bottom:20px;" src="/api/1/qr?address=Wo3MWeKwtA918DU4c69hVSNgejdWFCRCuWjShRY66mJkU2Hv58eygJWDJS1MNa2Ge5M1WjUkGHuLqHkweDxwZZU42d16v94mP"/>
|
||||
|
||||
<h3>View-only wallet</h3>
|
||||
<p>
|
||||
<code style="word-wrap: break-word">e62e40bfd5ca7e3a7f199602a3c97df511780489e1c1861884b00c28abaea406</code>
|
||||
</p>
|
||||
<h3>Donations</h3>
|
||||
<p>
|
||||
Current balance: <code>{{ txs_in['sum']|round(4) }} WOW</code>
|
||||
</p>
|
||||
<p>
|
||||
50 most recent donations:
|
||||
</p>
|
||||
{% from 'proposal/macros/transaction.html' import tx_item %}
|
||||
|
||||
<ul class="list-group">
|
||||
{% for tx in txs_in['txs'] %}
|
||||
{{ tx_item(tx) }}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{% include 'sidebar.html' %}
|
||||
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
</div>
|
||||
<!-- /.container -->
|
||||
{% endblock %}
|
|
@ -39,6 +39,12 @@ RPC_LOCATION = "http://{host}:{rpc_port}/json_rpc".format(host=RPC_HOST, rpc_por
|
|||
RPC_USERNAME = ""
|
||||
RPC_PASSWORD = ""
|
||||
|
||||
RPC_HOST_DEVFUND = '127.0.0.1'
|
||||
RPC_PORT_DEVFUND = '45679'
|
||||
RPC_LOCATION_DEVFUND = "http://{host}:{rpc_port}/json_rpc".format(host=RPC_HOST, rpc_port=RPC_PORT)
|
||||
RPC_USERNAME_DEVFUND = None
|
||||
RPC_PASSWORD_DEVFUND = None
|
||||
|
||||
FUNDING_CATEGORIES = [
|
||||
'wallets',
|
||||
'marketing',
|
||||
|
|
Loading…
Reference in a new issue