Merge branch 'master' of code.ungleich.ch:uncloud/uncloud

This commit is contained in:
Nico Schottelius 2021-06-20 11:58:23 +02:00
commit e205d8d07c
5 changed files with 17 additions and 33 deletions

View file

@ -11,7 +11,8 @@
<div class="collapse navbar-collapse" id="navbarSupportedContent"> <div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto"> <ul class="navbar-nav mr-auto">
{% if user.is_authenticated %} {% if user.is_authenticated %}
<span class="navbar-text">Logged in as {{ user }}.</span> <span class="navbar-text">Logged in as {{ user }}. Your balance:
{{ balance }} CHF. </span>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="{% url 'logout' %}">Logout</a> <a class="nav-link" href="{% url 'logout' %}">Logout</a>
</li> </li>

View file

@ -25,35 +25,6 @@ router = routers.DefaultRouter()
# Beta endpoints # Beta endpoints
router.register(r'beta/vm', vmviews.NicoVMProductViewSet, basename='nicovmproduct') router.register(r'beta/vm', vmviews.NicoVMProductViewSet, basename='nicovmproduct')
# VM
# router.register(r'v1/vm/snapshot', vmviews.VMSnapshotProductViewSet, basename='vmsnapshotproduct')
# router.register(r'v1/vm/diskimage', vmviews.VMDiskImageProductViewSet, basename='vmdiskimageproduct')
# router.register(r'v1/vm/disk', vmviews.VMDiskProductViewSet, basename='vmdiskproduct')
# router.register(r'v1/vm/vm', vmviews.VMProductViewSet, basename='vmproduct')
# Services
# router.register(r'v1/service/matrix', serviceviews.MatrixServiceProductViewSet, basename='matrixserviceproduct')
# router.register(r'v1/service/generic', serviceviews.GenericServiceProductViewSet, basename='genericserviceproduct')
# Pay
# router.register(r'v1/my/bill', payviews.BillViewSet, basename='bill')
# router.register(r'v1/my/order', payviews.OrderViewSet, basename='order')
# router.register(r'v1/my/payment-method', payviews.PaymentMethodViewSet, basename='payment-method')
# admin/staff urls
# router.register(r'v1/admin/bill', payviews.AdminBillViewSet, basename='admin/bill')
# router.register(r'v1/admin/order', payviews.AdminOrderViewSet, basename='admin/order')
# router.register(r'v1/admin/vmhost', vmviews.VMHostViewSet)
# router.register(r'v1/admin/vmcluster', vmviews.VMClusterViewSet)
# User/Account
# router.register(r'v1/my/user', authviews.UserViewSet, basename='user')
# router.register(r'v1/admin/user', authviews.AdminUserViewSet, basename='useradmin')
# router.register(r'v1/user/register', authviews.AccountManagementViewSet, basename='user/register')
################################################################################ ################################################################################
# v2 # v2

View file

@ -1,4 +1,13 @@
from django.views.generic.base import TemplateView from django.views.generic.base import TemplateView
from uncloud_pay.selectors import get_balance_for_user
class UncloudIndex(TemplateView): class UncloudIndex(TemplateView):
template_name = "uncloud/index.html" template_name = "uncloud/index.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
print(context)
if self.request.user.is_authenticated:
context['balance'] = get_balance_for_user(self.request.user)
return context

View file

@ -13,12 +13,15 @@
By submitting I authorise to send instructions to By submitting I authorise to send instructions to
the financial institution that issued my card to take the financial institution that issued my card to take
payments from my card account in accordance with the payments from my card account in accordance with the
terms of my agreement with you. terms of my agreement with you.
</p> </p>
<span id="message"></span> <span id="message"></span>
<div id="card-element"></div> <div id="card-element"></div>
<div id="card-errors" role="alert"></div>
<button type='button' id="card-button">Save</button> <button type='button' id="card-button">Save</button>
<div id="ungleichmessage">The card will be registered with stripe.</div> <div id="ungleichmessage">The card will be registered with stripe.</div>
<div id="goback" style="display: none;"> <div id="goback" style="display: none;">
@ -30,8 +33,8 @@
<!-- Enable Stripe from UI elements - standard code --> <!-- Enable Stripe from UI elements - standard code -->
<script> <script>
var stripe = Stripe('{{ stripe_pk }}'); var stripe = Stripe('{{ stripe_pk }}');
var elements = stripe.elements(); var elements = stripe.elements();
var cardElement = elements.create('card'); var cardElement = elements.create('card');
cardElement.mount('#card-element'); cardElement.mount('#card-element');

View file

@ -2,4 +2,4 @@ from django.apps import AppConfig
class UngleichServiceConfig(AppConfig): class UngleichServiceConfig(AppConfig):
name = 'ungleich_service' name = 'uncloud_service'