-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit includes a lot of changes, including: Major UI/UX change, base template is changed Most of pages have been reworked Now it is possible to create new stores and wallets without loading pages, just via popup. Data is now represented in good-looking datatables(datatables.js) which support paging, searching by any of columns of data, and some other features. In wallets page, simply press on wallet in the table on the left to see transactions of this wallet in the table on the right Another big change is support for two factor authentification. Note that after some changes in our login templates it may not work properly, submit an issue if it doesn't work. It is possible to authentificate using any authentificator app like google authentificator, or using backup codes generated. Now we have changed to postgres database for better performance. We have changed our structure, if before it was: user->store->product So now it is: user->wallet->store->product May look strange that you will need an extra step, but this provides more flexibility. For example, you can create a few stores with different products(and domains), linking to the same wallet, so no need to input some settings for each store and syncronyze each store. Now your wallet is starting to sync right after you create it, if you don't leave the wallets page after creating wallet, in some time you will see a notification in top right corner of screen saying that wallet has been syncronyzed. If xpub was invalid, it will say about it instantly. Also a lot of other fixes and things have been fixed, performance was improved.
- Loading branch information
1 parent
145ac4c
commit e709e9a
Showing
89 changed files
with
55,951 additions
and
31,013 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,22 @@ | ||
from django.contrib import admin | ||
from django.contrib.auth.admin import UserAdmin | ||
from django.utils.translation import ugettext_lazy as _ | ||
from . import models | ||
|
||
# Register your models here. | ||
class CustomUserAdmin(UserAdmin): | ||
model = models.User | ||
app_label="authentication" | ||
list_display = ['username','email','first_name','last_name','is_staff','is_confirmed'] | ||
fieldsets = ( | ||
(None, {'fields': ('username', 'password')}), | ||
(_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}), | ||
(_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser','is_confirmed', | ||
'groups', 'user_permissions')}), | ||
(_('Important dates'), {'fields': ('last_login', 'date_joined')}), | ||
) | ||
|
||
# Register your models here. | ||
admin.site.register(models.User, CustomUserAdmin) | ||
admin.site.register(models.Store) | ||
admin.site.register(models.Product) | ||
admin.site.register(models.Product) | ||
admin.site.register(models.Wallet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pylint: disable=no-member | ||
from . import models | ||
from django.conf import settings | ||
from django.db.models import Sum | ||
from django.utils import timezone | ||
from bitcart.coins.btc import BTC | ||
|
||
RPC_USER=settings.RPC_USER | ||
RPC_PASS=settings.RPC_PASS | ||
|
||
RPC_URL=settings.RPC_URL | ||
|
||
btc=BTC(RPC_URL) | ||
|
||
def provide_stats(request): | ||
if request.user.is_authenticated: | ||
products=models.Product.objects.filter(store__wallet__user=request.user) | ||
products=products.order_by("-date") | ||
products_count=len(products) | ||
stores_count=models.Store.objects.filter(wallet__user=request.user).count() | ||
wallets=models.Wallet.objects.filter(user=request.user) | ||
wallets_count=len(wallets) | ||
wallets_balance=0 | ||
for i in wallets: | ||
if timezone.now() - i.updated_date >= timezone.timedelta(hours=2): | ||
wallets_balance+=float(BTC(RPC_URL,xpub=i.xpub, rpc_user=RPC_USER, rpc_pass=RPC_PASS).balance()['confirmed']) | ||
i.updated_date=timezone.now() | ||
i.save() | ||
else: | ||
wallets_balance+=i.balance | ||
wallets_balance=format(wallets_balance,".08f").rstrip("0").rstrip(".") | ||
return {"products":products, "stores_count":stores_count, "wallets_count":wallets_count, | ||
"products_count":products_count, "wallets_balance":wallets_balance} | ||
else: | ||
return {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,108 @@ | ||
# Generated by Django 2.1.7 on 2019-02-17 17:00 | ||
# Generated by Django 2.1.7 on 2019-03-17 14:01 | ||
|
||
from django.conf import settings | ||
import django.contrib.auth.models | ||
import django.contrib.auth.validators | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
import embed_video.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('auth', '0009_alter_user_last_name_max_length'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='User', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('password', models.CharField(max_length=128, verbose_name='password')), | ||
('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), | ||
('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), | ||
('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), | ||
('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), | ||
('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), | ||
('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), | ||
('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), | ||
('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), | ||
('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), | ||
('is_confirmed', models.BooleanField(blank=True, default=False)), | ||
('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), | ||
('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), | ||
], | ||
options={ | ||
'verbose_name': 'user', | ||
'verbose_name_plural': 'users', | ||
'abstract': False, | ||
}, | ||
managers=[ | ||
('objects', django.contrib.auth.models.UserManager()), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='Product', | ||
fields=[ | ||
('id', models.CharField(max_length=255, primary_key=True, serialize=False)), | ||
('amount', models.FloatField()), | ||
('quantity', models.FloatField()), | ||
('title', models.CharField(max_length=1000)), | ||
('status', models.CharField(default='new', max_length=1000)), | ||
('order_id', models.CharField(blank=True, default='', max_length=255)), | ||
('date', models.DateTimeField(default=django.utils.timezone.now)), | ||
('description', models.TextField(blank=True, null=True)), | ||
('image', models.ImageField(blank=True, null=True, upload_to='')), | ||
('video', embed_video.fields.EmbedVideoField(blank=True, null=True)), | ||
('bitcoin_address', models.CharField(default='', max_length=255)), | ||
('bitcoin_url', models.CharField(default='', max_length=255)), | ||
], | ||
options={ | ||
'db_table': 'products', | ||
'managed': True, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Store', | ||
fields=[ | ||
('id', models.CharField(max_length=255, primary_key=True, serialize=False)), | ||
('can_delete', models.IntegerField()), | ||
('name', models.CharField(max_length=1000)), | ||
('website', models.CharField(max_length=1000)), | ||
('can_invoice', models.BooleanField(default=False)), | ||
('xpub', models.CharField(max_length=1000)), | ||
('invoice_expire', models.IntegerField(default=15)), | ||
('fee_mode', models.IntegerField(choices=[(1, '... only if the customer makes more than one payment for the invoice'), (2, 'Always'), (3, 'Never')], default=1)), | ||
('payment_tolerance', models.FloatField(default=0)), | ||
('domain', models.CharField(blank=True, default='', max_length=1000)), | ||
('template', models.CharField(blank=True, default='', max_length=1000)), | ||
('email', models.CharField(blank=True, default='', max_length=1000)), | ||
], | ||
options={ | ||
'db_table': 'stores', | ||
'managed': True, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Wallet', | ||
fields=[ | ||
('id', models.CharField(max_length=255, primary_key=True, serialize=False)), | ||
('name', models.CharField(max_length=1000)), | ||
('xpub', models.CharField(blank=True, default='', max_length=1000)), | ||
('balance', models.FloatField(blank=True, default=0)), | ||
('updated_date', models.DateTimeField(default=django.utils.timezone.now)), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'db_table': 'wallets', | ||
'managed': True, | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='store', | ||
name='wallet', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='gui.Wallet'), | ||
), | ||
migrations.AddField( | ||
model_name='product', | ||
name='store', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='gui.Store'), | ||
), | ||
] |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.