mirror of
https://github.com/RoboSats/robosats.git
synced 2024-10-26 15:31:14 +03:00
Add any-domain referral, ontop UnsafeAlert and control panel(app)
This commit is contained in:
parent
d31bd63edc
commit
5730ec0383
@ -700,7 +700,7 @@ class InfoView(ListAPIView):
|
|||||||
|
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
context["nickname"] = request.user.username
|
context["nickname"] = request.user.username
|
||||||
context["referral_link"] = str(config('HOST_NAME'))+'/ref/'+str(request.user.profile.referral_code)
|
context["referral_code"] = str(request.user.profile.referral_code)
|
||||||
context["earned_rewards"] = request.user.profile.earned_rewards
|
context["earned_rewards"] = request.user.profile.earned_rewards
|
||||||
has_no_active_order, _, order = Logics.validate_already_maker_or_taker(
|
has_no_active_order, _, order = Logics.validate_already_maker_or_taker(
|
||||||
request.user)
|
request.user)
|
||||||
|
0
control/__init__.py
Executable file
0
control/__init__.py
Executable file
41
control/admin.py
Executable file
41
control/admin.py
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
from control.models import AccountingDay, AccountingMonth, Dispute
|
||||||
|
# Register your models here.
|
||||||
|
|
||||||
|
@admin.register(AccountingDay)
|
||||||
|
class AccountingDayAdmin(admin.ModelAdmin):
|
||||||
|
list_display = (
|
||||||
|
"day",
|
||||||
|
"contracted",
|
||||||
|
"net_settled",
|
||||||
|
"net_paid",
|
||||||
|
"net_balance",
|
||||||
|
"total_inflow",
|
||||||
|
"total_outflow",
|
||||||
|
"total_routing_fees",
|
||||||
|
"total_cashflow",
|
||||||
|
"pending_rewards",
|
||||||
|
"pending_disputes",
|
||||||
|
"pending_claimable",
|
||||||
|
)
|
||||||
|
change_links = ["day"]
|
||||||
|
search_fields = ["day"]
|
||||||
|
|
||||||
|
@admin.register(AccountingMonth)
|
||||||
|
class AccountingMonthAdmin(admin.ModelAdmin):
|
||||||
|
list_display = (
|
||||||
|
"month",
|
||||||
|
"contracted",
|
||||||
|
"net_settled",
|
||||||
|
"net_paid",
|
||||||
|
"net_balance",
|
||||||
|
"total_inflow",
|
||||||
|
"total_outflow",
|
||||||
|
"total_routing_fees",
|
||||||
|
"total_cashflow",
|
||||||
|
"pending_rewards",
|
||||||
|
"pending_disputes",
|
||||||
|
"pending_claimable",
|
||||||
|
)
|
||||||
|
change_links = ["month"]
|
||||||
|
search_fields = ["month"]
|
6
control/apps.py
Executable file
6
control/apps.py
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ControlConfig(AppConfig):
|
||||||
|
default_auto_field = 'django.db.models.BigAutoField'
|
||||||
|
name = 'control'
|
60
control/models.py
Executable file
60
control/models.py
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
|
class AccountingDay(models.Model):
|
||||||
|
day = models.DateTimeField(primary_key=True, auto_now=False, auto_now_add=False)
|
||||||
|
|
||||||
|
# Every field is denominated in Sats with (3 decimals for millisats)
|
||||||
|
# Total volume contracted
|
||||||
|
contracted = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Net volume of trading invoices settled (excludes disputes)
|
||||||
|
net_settled = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Net volume of trading invoices paid (excludes rewards and disputes)
|
||||||
|
net_paid = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Sum of net settled and net paid
|
||||||
|
net_balance = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Total volume of invoices settled
|
||||||
|
total_inflow = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Total volume of invoices paid
|
||||||
|
total_outflow = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Total cost in routing fees
|
||||||
|
total_routing_fees = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Total inflows minus outflows and routing fees
|
||||||
|
total_cashflow = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Balance on pending rewards (referral rewards and slashed bonds)
|
||||||
|
pending_rewards = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Balance on pending disputes (not resolved yet)
|
||||||
|
pending_disputes = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Balance on pending rewards and resolved disputes
|
||||||
|
pending_claimable = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
|
||||||
|
|
||||||
|
class AccountingMonth(models.Model):
|
||||||
|
month = models.DateTimeField(primary_key=True, auto_now=False, auto_now_add=False)
|
||||||
|
|
||||||
|
# Every field is denominated in Sats with (3 decimals for millisats)
|
||||||
|
# Total volume contracted
|
||||||
|
contracted = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Net volume of trading invoices settled (excludes disputes)
|
||||||
|
net_settled = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Net volume of trading invoices paid (excludes rewards and disputes)
|
||||||
|
net_paid = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Sum of net settled and net paid
|
||||||
|
net_balance = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Total volume of invoices settled
|
||||||
|
total_inflow = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Total volume of invoices paid
|
||||||
|
total_outflow = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Total cost in routing fees
|
||||||
|
total_routing_fees = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Total inflows minus outflows and routing fees
|
||||||
|
total_cashflow = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Balance on pending rewards (referral rewards and slashed bonds)
|
||||||
|
pending_rewards = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Balance on pending disputes (not resolved yet)
|
||||||
|
pending_disputes = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
# Balance on pending rewards and resolved disputes
|
||||||
|
pending_claimable = models.DecimalField(max_digits=15, decimal_places=3, default=0, null=False, blank=False)
|
||||||
|
|
||||||
|
class Dispute(models.Model):
|
||||||
|
pass
|
6
control/tasks.py
Normal file
6
control/tasks.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
from celery import shared_task
|
||||||
|
from api.models import Order, LNPayment, Profile
|
||||||
|
|
||||||
|
@shared_task(name="do_accounting")
|
||||||
|
def do_accounting():
|
||||||
|
return
|
3
control/tests.py
Executable file
3
control/tests.py
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
3
control/views.py
Executable file
3
control/views.py
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
from django.shortcuts import render
|
||||||
|
|
||||||
|
# Create your views here.
|
@ -76,7 +76,7 @@ export default class BottomBar extends Component {
|
|||||||
alternative_site: 'robosats...',
|
alternative_site: 'robosats...',
|
||||||
node_id: '00000000',
|
node_id: '00000000',
|
||||||
showRewards: false,
|
showRewards: false,
|
||||||
referral_link: 'Loading...',
|
referral_code: '',
|
||||||
earned_rewards: 0,
|
earned_rewards: 0,
|
||||||
rewardInvoice: null,
|
rewardInvoice: null,
|
||||||
badInvoice: false,
|
badInvoice: false,
|
||||||
@ -141,7 +141,6 @@ export default class BottomBar extends Component {
|
|||||||
</ListItem>
|
</ListItem>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
<Divider/>
|
<Divider/>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
<ListItemIcon><WebIcon/></ListItemIcon>
|
<ListItemIcon><WebIcon/></ListItemIcon>
|
||||||
@ -272,6 +271,11 @@ export default class BottomBar extends Component {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getHost(){
|
||||||
|
var url = (window.location != window.parent.location) ? this.getHost(document.referrer) : document.location.href;
|
||||||
|
return url.split('/')[2]
|
||||||
|
}
|
||||||
|
|
||||||
dialogProfile =() =>{
|
dialogProfile =() =>{
|
||||||
return(
|
return(
|
||||||
<Dialog
|
<Dialog
|
||||||
@ -362,13 +366,13 @@ export default class BottomBar extends Component {
|
|||||||
<ListItemText secondary="Share to earn 100 Sats per trade">
|
<ListItemText secondary="Share to earn 100 Sats per trade">
|
||||||
<TextField
|
<TextField
|
||||||
label='Your referral link'
|
label='Your referral link'
|
||||||
value={this.state.referral_link}
|
value={this.getHost()+'/ref/'+this.state.referral_code}
|
||||||
// variant='filled'
|
// variant='filled'
|
||||||
size='small'
|
size='small'
|
||||||
InputProps={{
|
InputProps={{
|
||||||
endAdornment:
|
endAdornment:
|
||||||
<Tooltip disableHoverListener enterTouchDelay="0" title="Copied!">
|
<Tooltip disableHoverListener enterTouchDelay="0" title="Copied!">
|
||||||
<IconButton onClick= {()=>navigator.clipboard.writeText(this.state.referral_link)}>
|
<IconButton onClick= {()=>navigator.clipboard.writeText('http://'+this.getHost()+'/ref/'+this.state.referral_code)}>
|
||||||
<ContentCopy />
|
<ContentCopy />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>,
|
</Tooltip>,
|
||||||
|
@ -343,7 +343,7 @@ export default class MakerPage extends Component {
|
|||||||
|
|
||||||
AdvancedMakerOptions = () => {
|
AdvancedMakerOptions = () => {
|
||||||
return(
|
return(
|
||||||
<Paper elevation={12} style={{ padding: 8, width:280, align:'center'}}>
|
<Paper elevation={12} style={{ padding: 8, width:250, align:'center'}}>
|
||||||
|
|
||||||
<Grid container xs={12} spacing={1}>
|
<Grid container xs={12} spacing={1}>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
import {Alert, AlertTitle, Button, Grid, Typography} from "@mui/material"
|
import {Paper, Alert, AlertTitle, Button, Grid, Typography} from "@mui/material"
|
||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import MediaQuery from 'react-responsive'
|
import MediaQuery from 'react-responsive'
|
||||||
|
|
||||||
@ -27,26 +27,30 @@ export default class UnsafeAlert extends Component {
|
|||||||
(!this.safe_urls.includes(this.getHost()) & this.state.show) ?
|
(!this.safe_urls.includes(this.getHost()) & this.state.show) ?
|
||||||
<div>
|
<div>
|
||||||
<MediaQuery minWidth={800}>
|
<MediaQuery minWidth={800}>
|
||||||
<Alert severity="warning" sx={{maxHeight:100, zIndex:9999}} z-index={9999}
|
<Paper elevation={6} className="alertUnsafe">
|
||||||
|
<Alert severity="warning" sx={{maxHeight:100}}
|
||||||
action={<Button onClick={() => this.setState({show:false})}>Hide</Button>}
|
action={<Button onClick={() => this.setState({show:false})}>Hide</Button>}
|
||||||
>
|
>
|
||||||
<AlertTitle>You are not using RoboSats privately</AlertTitle>
|
<AlertTitle>You are not using RoboSats privately</AlertTitle>
|
||||||
Some features are disabled for your protection (e.g. chat) and you will not be able to complete a
|
Some features are disabled for your protection (e.g. chat) and you will not be able to complete a
|
||||||
trade without them. To protect your privacy and fully enable RoboSats, use <a href='https://www.torproject.org/download/' target="_blank">Tor Browser</a> and visit the <a href='http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion' target="_blank">Onion</a> site.
|
trade without them. To protect your privacy and fully enable RoboSats, use <a href='https://www.torproject.org/download/' target="_blank">Tor Browser</a> and visit the <a href='http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion' target="_blank">Onion</a> site.
|
||||||
</Alert>
|
</Alert>
|
||||||
|
</Paper>
|
||||||
</MediaQuery>
|
</MediaQuery>
|
||||||
|
|
||||||
<MediaQuery maxWidth={799}>
|
<MediaQuery maxWidth={799}>
|
||||||
<Alert severity="warning" sx={{maxHeight:100, zIndex:9999}} z-index={9999}>
|
<Paper elevation={6} className="alertUnsafe">
|
||||||
|
<Alert severity="warning" sx={{maxHeight:100}}>
|
||||||
<AlertTitle>You are not using RoboSats privately</AlertTitle>
|
<AlertTitle>You are not using RoboSats privately</AlertTitle>
|
||||||
You will not be able to complete a
|
You will not be able to complete a
|
||||||
trade. Use <a href='https://www.torproject.org/download/' target="_blank">Tor Browser</a> and visit the <a href='http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion' target="_blank">Onion</a> site.
|
trade. Use <a href='https://www.torproject.org/download/' target="_blank">Tor Browser</a> and visit the <a href='http://robosats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion' target="_blank">Onion</a> site.
|
||||||
<div style={{width: '100%'}}>
|
<div style={{width: '100%'}}>
|
||||||
</div>
|
</div>
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<Button onClick={() => this.setState({show:false})}>Hide</Button>
|
<Button className="hideAlertButton" onClick={() => this.setState({show:false})}>Hide</Button>
|
||||||
</div>
|
</div>
|
||||||
</Alert>
|
</Alert>
|
||||||
|
</Paper>
|
||||||
</MediaQuery>
|
</MediaQuery>
|
||||||
</div>
|
</div>
|
||||||
:
|
:
|
||||||
|
@ -23,7 +23,16 @@ body {
|
|||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%,-50%) translate(0,-20px);
|
transform: translate(-50%,-50%) translate(0,-20px);
|
||||||
z-index: 1;
|
}
|
||||||
|
|
||||||
|
.alertUnsafe{
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 9999;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hideAlertButton{
|
||||||
|
position: fixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
.clickTrough{
|
.clickTrough{
|
||||||
|
File diff suppressed because one or more lines are too long
@ -58,6 +58,7 @@ INSTALLED_APPS = [
|
|||||||
"django_celery_results",
|
"django_celery_results",
|
||||||
"api",
|
"api",
|
||||||
"chat",
|
"chat",
|
||||||
|
"control",
|
||||||
"frontend.apps.FrontendConfig",
|
"frontend.apps.FrontendConfig",
|
||||||
]
|
]
|
||||||
from .celery.conf import *
|
from .celery.conf import *
|
||||||
|
Loading…
Reference in New Issue
Block a user