Skip to content

Commit

Permalink
Merge 75a1e74 into master-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored Nov 19, 2021
2 parents 5422b9c + 75a1e74 commit 95610af
Show file tree
Hide file tree
Showing 19 changed files with 329 additions and 29 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/Dajango.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ jobs:

steps:


# Step 1, add the IP address
- name: Add IP address to trusted source (managed database)
uses: GarreauArthur/manage-digital-ocean-managed-database-trusted-sources-gh-action@main
with:
action: "add"
database_id: 3ece3463-8ce9-4bb2-9362-f6b3fd8e4c42
digitalocean_token: aad056c20d6d9da0beadbf3028abc712fda675cadbe1b651e1b155736de45bd7


# Step 2, do whatever you need to do with you database
- uses: actions/checkout@v2

# - name: Set up Python ${{ matrix.python-version }}
Expand All @@ -28,9 +39,20 @@ jobs:

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python3 -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run Tests
run: |
python manage.py test --noinput
python3 manage.py test --noinput
# Step 3, remove the IP address
- name: Remove IP address to trusted source (managed database)
if: always()
uses: GarreauArthur/manage-digital-ocean-managed-database-trusted-sources-gh-action@main
with:
action: "remove"
database_id: 3ece3463-8ce9-4bb2-9362-f6b3fd8e4c42
digitalocean_token: aad056c20d6d9da0beadbf3028abc712fda675cadbe1b651e1b155736de45bd7
2 changes: 1 addition & 1 deletion bb_accounts/templates/registration/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% block registration %}

<div class="row justify-content-center">
<div class="col-lg-3 col-md-6">
<div class="col-xl-2 col-lg-4 col-md-6 col-sm-6">
<div class="card">

<div class="card-header">
Expand Down
18 changes: 18 additions & 0 deletions bb_data/migrations/0024_colocationclient_stripe_account_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.9 on 2021-11-18 19:29

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('bb_data', '0023_alter_colocationclientowner_unique_together'),
]

operations = [
migrations.AddField(
model_name='colocationclient',
name='stripe_account_id',
field=models.CharField(blank=True, max_length=128, null=True),
),
]
2 changes: 2 additions & 0 deletions bb_data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class ColocationClient(models.Model):
related_name='client_owners'
)

stripe_account_id = models.CharField(max_length=128, blank=True, null=True)

vast_api_key = models.CharField(max_length = 64, blank=True, null=True)
eth_deposit_address = models.CharField(max_length = 64, blank=True, null=True)

Expand Down
Empty file added bb_webhook/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions bb_webhook/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
''' bb_webhook - Admin interface for the webhook module '''

# from django.contrib import admin

# Register your models here.
12 changes: 12 additions & 0 deletions bb_webhook/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
''' bb_webhook app settings '''

from django.apps import AppConfig


class BbWebhookConfig(AppConfig):
'''
app specific configuration
'''
name = 'bb_webhook'
default_auto_field = 'django.db.models.BigAutoField'
name = 'bb_webhook'
Empty file.
12 changes: 12 additions & 0 deletions bb_webhook/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'''urls.py for bb_webhook'''

from django.urls import path

from bb_webhook import views_stripe

app_name = 'bb_webhook'

urlpatterns = [
# ------------------------- Stripe Webhook Endpoints ------------------------- #
path('stripe/account', views_stripe.account_event, name='webhook_stripe_account'),
]
50 changes: 50 additions & 0 deletions bb_webhook/views_stripe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
''' Processes webhooks from Stripe '''

import json
import stripe

from django.shortcuts import HttpResponse

from django.views.decorators.csrf import csrf_exempt


@csrf_exempt
def account_event(request):
'''
URL: webhook/stripe/account
'''
payload = request.body
event = None

try:
event = stripe.Event.construct_from(
json.loads(payload), stripe.api_key
)
except ValueError:
# Invalid payload
return HttpResponse(status=400)

# Account Updated
if event.type == 'account.updated':
account = event.data.object.id
print(account)




# Handle the event
if event.type == 'payment_intent.succeeded':
payment_intent = event.data.object # contains a stripe.PaymentIntent
print(payment_intent)
# Then define and call a method to handle the successful payment intent.
# handle_payment_intent_succeeded(payment_intent)
elif event.type == 'payment_method.attached':
payment_method = event.data.object # contains a stripe.PaymentMethod
print(payment_method)
# Then define and call a method to handle the successful attachment of a PaymentMethod.
# handle_payment_method_attached(payment_method)
# ... handle other event types
else:
print(f'Unhandled event type {event.type}')

return HttpResponse(status=200)
57 changes: 41 additions & 16 deletions brickbox/settings.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
''' Django settings for brickbox.io project. '''

import os
import sys

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand Down Expand Up @@ -41,6 +42,7 @@
'bb_dashboard', # Users dashboard
'bb_data', # Collection of data
'bb_vm', # Virtual Machine Rentals
'bb_webhook', # Handle incoming and outgoing webhook events

# Other Apps
'puller', # CI/CD Automation Tool
Expand Down Expand Up @@ -144,20 +146,37 @@

if DEBUG:
DB_NAME = 'debug-brickbox-db'
DB_USER = 'doadmin'
DB_PASSWORD = 'dadi8xb2jd71ffx9'
else:
DB_NAME = 'brickbox-db'

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': DB_NAME,
'USER': 'doadmin',
'PASSWORD': 'dadi8xb2jd71ffx9',
'HOST': 'brickbox-db-postgresql-do-user-9465762-0.b.db.ondigitalocean.com',
'PORT': '25060',
'test': {'NAME': 'brickbox-ci'},
DB_USER = 'doadmin'
DB_PASSWORD = 'dadi8xb2jd71ffx9'

if 'test' in sys.argv:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'brickbox-ci',
'USER': 'GitHub-Action',
'PASSWORD': '4kXOjCvhh5a3wWV7',
'HOST': 'brickbox-db-postgresql-do-user-9465762-0.b.db.ondigitalocean.com',
'PORT': '25060',
'TEST': {'NAME': 'brickbox-ci'},
}
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': DB_NAME,
'USER': DB_USER,
'PASSWORD': DB_PASSWORD,
'HOST': 'brickbox-db-postgresql-do-user-9465762-0.b.db.ondigitalocean.com',
'PORT': '25060',
'TEST': {'NAME': 'brickbox-ci'},
}
}
}


# Password validation
Expand Down Expand Up @@ -306,9 +325,15 @@
# ---------------------------------------------------------------------------- #

# ----------------------- Stripe Debug/Test Credentials ---------------------- #
# CLIENT_ID_TEST =
STRIPE_SECRET_KEY_TEST = '''sk_test_51Jb9T1AFJmW5oMdbI6NszFIEwIHNynAa
1pHqeUkBRMWAqFUj2XguaLzfFqspuarRB5uqVZPuFkyDb4f5k7WuJ3EE00OqwKdoI4'''
CLIENT_ID_TEST = 'ca_KbUZTFe8KqC56Ngh7b4hQUBu0fifyban'

STRIPE_SECRET_KEY_TEST = 'sk_test_51Jb9T1AFJmW5oMdbI6NszFIEwIHNynAa1pHqeUkBRMWAqFUj2XguaLzfFqspuarRB5uqVZPuFkyDb4f5k7WuJ3EE00OqwKdoI4' # pylint: disable=line-too-long

STRIPE_PUBLISHABLE_KEY_TEST = 'pk_test_51Jb9T1AFJmW5oMdbOtpNv8mEKgXZZjdVScjhh1l7wMJ4h2UynWpnIl1tlsmX0Hgt33lE8hyoiKer85GgfHnNjagK00aZMtPtzX' # pylint: disable=line-too-long

# ---------------------------- Stripe Credentials ---------------------------- #
CLIENT_ID = 'ca_KbUZatPIraDbaExd7VA0jkTR6Cb2et76'

STRIPE_SECRET_KEY = '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' # pylint: disable=line-too-long

STRIPE_PUBLISHABLE_KEY_TEST = '''pk_test_51Jb9T1AFJmW5oMdbOtpNv8mEKgXZZ
jdVScjhh1l7wMJ4h2UynWpnIl1tlsmX0Hgt33lE8hyoiKer85GgfHnNjagK00aZMtPtzX'''
STRIPE_PUBLISHABLE_KEY = 'pk_live_51Jb9T1AFJmW5oMdb3WcUDAIySK9NYUmd3JrP4rb7NvDupmnM8HfVYdpWHxoNf1HFLcwTAcXGmM23D9VKjfu2vTnz00LAAcLjtx' # pylint: disable=line-too-long
1 change: 1 addition & 0 deletions brickbox/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
path('dashboard/', include('bb_dashboard.urls')), # bb_dashboard
path('dash/', include('django_dash_black.urls')),
path('data/', include('bb_data.urls')), # bb_data
path('webhook/', include('bb_webhook.urls')), # bb_webhook

# ---------------------------- Virtulization URLS ---------------------------- #
path('vm/', include('bb_vm.urls')), # bb_vm
Expand Down
8 changes: 8 additions & 0 deletions django_dash_black/static/assets/js/colo/onboarding.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ function TermsAgreement() {
xhttp.send(formData);
});
}

function ETH_Address() {
$("#eth_address").modal('toggle');
$("#confirm_button").click(function () {
$("#eth_address").modal('toggle');

});
}
26 changes: 24 additions & 2 deletions django_dash_black/templates/colo.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
{% block stylesheets %}{% endblock stylesheets %}

{% block content %}

<div class="row">

<div class="col-xl-3 col-lg-3 col-md-6 col-sm-12">
Expand Down Expand Up @@ -39,9 +38,30 @@ <h4 class="card-title">2 | Payout Info</h4>
<div class="card-body">
<p class="card-text">
Please provide the account information for where you would like to receive your payout.
<br>
Stripe - USD Payments
<br>
ETH - Cypto Payments
</p>
</div>

<div class="card-footer text-center">
{% if stripe_link_url is not False %}
<a href="{{ stripe_link_url }}">
<button type="button" class="btn btn-success"> Connect Stripe </button>
</a>
{% else %}
<button type="button" class="btn btn-success" disabled> Stripe Connected </button>
{% endif %}

{% if first_colo.eth_deposit_address is None %}
<button type="button" class="btn btn-success" onclick="ETH_Address()"> ETH Address </button>
{% else %}
<button type="button" class="btn btn-success" disabled> ETH Address </button>
{% endif %}

</div>

</div>
</div>

Expand Down Expand Up @@ -71,7 +91,8 @@ <h4 class="card-title">4 | Confirm Insurance</h4>
<div class="card-body">
<p class="card-text">
As stated in the agreement, you will be required to provide us with a valid insurance policy for the equipment.
You can either go through our insurace provider or upload a copy of your proff of insurance.
<br>
You can either go through our insurance provider or upload a copy of your proof of insurance.
</p>
</div>

Expand All @@ -81,6 +102,7 @@ <h4 class="card-title">4 | Confirm Insurance</h4>
</div>

{% include "modals/colo_terms_signature.html" %}
{% include "modals/colo_eth_address.html" %}

{% endblock content %}

Expand Down
21 changes: 21 additions & 0 deletions django_dash_black/templates/modals/colo_eth_address.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="eth_address">

<div class="modal-dialog modal-xl" style="transform: translate(0, 0)">
<div class="modal-content">
<div class="modal-body">

<!-- An input field for eth address -->
<div class="form-group">
<label for="eth_address">ETH Address</label>
<input type="text" class="form-control" id="eth_address" placeholder="0x..." style="color: black;">
</div>

</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-danger" id="confirm_eth_address_button">Confirm</button>
</div>
</div>
</div>

</div>
19 changes: 14 additions & 5 deletions django_dash_black/templates/page-user.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,40 @@ <h5 class="title">Edit Profile</h5>
</div>
</div> -->
{% endcomment %}
{% if request.user.username != request.user.email %}
<div class="col-md-3 pr-md-1">
<div class="form-group">
<label>Username</label>
<input type="text" class="form-control" value="{{ request.user.username }}">
<input type="text" class="form-control" value="{{ request.user.username }}" disabled>
</div>
</div>
<div class="col-md-4 px-md-1">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" value="{{ request.user.email }}">
<input type="email" class="form-control" value="{{ request.user.email }}" disabled>
</div>
</div>
{% else %}
<div class="col-md-3 pr-md-1">
<div class="form-group">
<label>Email/Username</label>
<input type="text" class="form-control" value="{{ request.user.email }}" disabled>
</div>
</div>
{% endif %}
</div>

<div class="row">
<div class="col-md-6 pr-md-1">
<div class="form-group">
<label>First Name</label>
<input type="text" class="form-control" placeholder="Company" value="{{ request.user.first_name }}">
<input type="text" class="form-control" placeholder="Company" value="{{ request.user.first_name }}" disabled>
</div>
</div>
<div class="col-md-6 pl-md-1">
<div class="form-group">
<label>Last Name</label>
<input type="text" class="form-control" placeholder="Last Name" value="{{ request.user.last_name }}">
<input type="text" class="form-control" placeholder="Last Name" value="{{ request.user.last_name }}" disabled>
</div>
</div>
</div>
Expand Down Expand Up @@ -101,7 +110,7 @@ <h5 class="title">Edit Profile</h5>
</form>
</div>
<div class="card-footer">
<button type="submit" class="btn btn-fill btn-primary">Save</button>
<button type="submit" class="btn btn-fill btn-primary" disabled>Save</button>
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit 95610af

Please sign in to comment.