integrate bootstrap

This commit is contained in:
Nico Schottelius 2021-01-01 13:25:52 +01:00
parent 6c15d2086e
commit 48ce21f833
7 changed files with 88 additions and 45 deletions

View file

@ -2,6 +2,7 @@
django
djangorestframework
django-auth-ldap
django-bootstrap4
psycopg2
ldap3

View file

@ -51,6 +51,7 @@ INSTALLED_APPS = [
'django.contrib.staticfiles',
'django_extensions',
'rest_framework',
'bootstrap4',
'uncloud',
'uncloud_pay',
'uncloud_auth',
@ -164,6 +165,11 @@ USE_TZ = True
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static") ]
STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]
# XML-RPC interface of opennebula
OPENNEBULA_URL = 'https://opennebula.example.com:2634/RPC2'

View file

@ -1,3 +1,8 @@
{% extends 'bootstrap4/bootstrap4.html' %}
{% load bootstrap4 %}
<!doctype html>
<html lang="en">
<head>
@ -5,10 +10,17 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>{% block title %}Welcome to uncloud{% endblock %}</title>
{% block bootstrap4_title %}{% block title %}Welcome to uncloud{% endblock %}{% endblock %}
{% block header %}{% endblock %}
</head>
<body>
{% block bootstrap4_content %}
<div class="container">
{% block body %}{% endblock %}
</div>
{% autoescape off %}{% bootstrap_messages %}{% endautoescape %}
{% endblock %}
</body>
</html>

View file

@ -2,19 +2,61 @@
{% block title %}{% endblock %}
{% block body %}
<div>
<div id="content">
<h1>Welcome to uncloud</h1>
Welcome to uncloud, checkout the following locations:
<div id="intro">
Welcome to uncloud, the Open Source cloud management
system by <a href="https://ungleich.ch">ungleich</a>.
It is an <a href="{% url 'api-root' %}">API</a> driven system with
some convience views provided by
the <a href="https://www.django-rest-framework.org/">Django Rest
Framework</a>. You can
freely <a href="https://code.ungleich.ch/uncloud/uncloud/">access
the source code of uncloud</a>.
<div id="creditcards">
<h2>Credit cards</h2>
<div>
Credit cards are registered with stripe. We only save a the
last 4 digits and the expiry date of the card to make
identification for you easier.
</div>
<div>
<ul>
<li><a href="{% url 'api-root' %}">The uncloud API</a>
<li><a href="{% url 'cc_register' %}">Register a credit card</a>
(this is required to be done via Javascript so that we never see
your credit card, but it is sent directly to stripe)
<li><a href="{% url 'stripecreditcard-list' %}">You can list your
credit cards</a>
By default the first credit card is used for charging
("active: true") and later added cards will not be
used. To change this, first disable the active flag and
then set it on another credit card.
</div>
</div>
<div id="pay">
<h2>Payments and Balance</h2>
To trigger a payment
You can list your credit card via the API.
<ul>
<li><a href="{% url 'payment-list' %}">Make a payment or list your payments</a>
<li><a href="{% url 'payment-balance-list' %}">Show your balance</a>
</ul>
</div>
<div id="net">
<h2>Networking</h2>
With uncloud you can use a variety of network related services.
<ul>
<li>You can <a href="{% url 'wireguardvpnnetwork-list' %}">list or
create VPNs</a> based on wireguard
<li>You can also <a href="{% url 'wireguardvpnnetworksizes-list'
%}">list which network sizes are available</a>
</ul>
</div>
</div>
{% endblock %}

View file

@ -26,38 +26,27 @@ router = routers.DefaultRouter()
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')
# creates VM from os image
#router.register(r'vm/ipv6onlyvm', vmviews.VMProductViewSet, basename='vmproduct')
# ... AND adds IPv4 mapping
#router.register(r'vm/dualstackvm', vmviews.VMProductViewSet, basename='vmproduct')
# 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')
# 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/address', payviews.BillingAddressViewSet, basename='billingaddress')
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', payviews.PaymentViewSet, basename='payment')
router.register(r'v1/my/payment-method', payviews.PaymentMethodViewSet, basename='payment-method')
# router.register(r'v1/my/address', payviews.BillingAddressViewSet, basename='billingaddress')
# 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/payment', payviews.AdminPaymentViewSet, basename='admin/payment')
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)
#router.register(r'v1/admin/vpnpool', netviews.VPNPoolViewSet)
#router.register(r'v1/admin/opennebula', oneviews.VMViewSet, basename='opennebula')
# 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')
@ -73,7 +62,7 @@ router.register(r'v2/net/wireguardvpn', netviews.WireGuardVPNViewSet, basename='
router.register(r'v2/net/wireguardvpnsizes', netviews.WireGuardVPNSizes, basename='wireguardvpnnetworksizes')
# Payment related
router.register(r'v2/payment/credit-card', payviews.CreditCardViewSet, basename='credit-card')
router.register(r'v2/payment/credit-card', payviews.CreditCardViewSet, basename='stripecreditcard')
router.register(r'v2/payment/payment', payviews.PaymentViewSet, basename='payment')
router.register(r'v2/payment/balance', payviews.BalanceViewSet, basename='payment-balance')

View file

@ -10,7 +10,7 @@ from uncloud import AMOUNT_DECIMALS, AMOUNT_MAX_DIGITS
###
# 2020-12 Checked code
class StripeCreditCardSerializer(serializers.ModelSerializer):
class StripeCreditCardSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = StripeCreditCard
exclude = [ "card_id", "owner" ]

View file

@ -2,13 +2,6 @@
{% block header %}
<script src="https://js.stripe.com/v3/"></script>
<style>
#content {
width: 400px;
margin: auto;
}
</style>
{% endblock %}
{% block body %}