Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
9fd9d9d
Added to user model, and simple validation
shenyang44 Feb 26, 2020
f75569c
Fixed validation and typo.
shenyang44 Feb 26, 2020
0b4d77b
password check and installed flask-wtf
shenyang44 Feb 26, 2020
c576a40
CSRF protection added
shenyang44 Feb 26, 2020
d7f8e5c
Update views.py
shenyang44 Feb 26, 2020
8d15ea1
js file to handle keyup, password validation
shenyang44 Feb 26, 2020
dc411a4
sign in form, flash added.
shenyang44 Feb 26, 2020
7630f5c
made html file for users/index
shenyang44 Feb 27, 2020
ddff478
moved sign in handling to sessions folder. And implemented sessions
shenyang44 Feb 27, 2020
25d980f
changed session to flask_login
shenyang44 Feb 27, 2020
61b3438
Merge pull request #1 from shenyang44/flask-login
shenyang44 Feb 27, 2020
06733d9
added navbar to control signin/up and logout
shenyang44 Feb 27, 2020
4e46604
404 and 500 error pages up and running
shenyang44 Feb 27, 2020
90f1ada
update form up and running.
shenyang44 Feb 28, 2020
ecab14d
profile picture upload
shenyang44 Feb 28, 2020
3f2820d
WIP file checking
shenyang44 Feb 29, 2020
88c70c7
Update views.py
shenyang44 Feb 29, 2020
62fcaf5
Read desc.
shenyang44 Mar 2, 2020
19f12ec
altered profile HTML
shenyang44 Mar 2, 2020
62fd159
moved out gallery images into own blueprint
shenyang44 Mar 2, 2020
dbb6c9d
some useless shiz
shenyang44 Mar 2, 2020
fd553d6
blueprints and model for donos
shenyang44 Mar 3, 2020
b7a8ed0
adding donation form
shenyang44 Mar 3, 2020
c827c4e
payment gateway working.
shenyang44 Mar 3, 2020
142d4a4
working email notifier
shenyang44 Mar 3, 2020
199d9c3
Added categories for flash messages.
shenyang44 Mar 3, 2020
2e63a47
User index displays all posts if not signed in
shenyang44 Mar 4, 2020
8d7fbff
flash categories finally working.
shenyang44 Mar 4, 2020
798a36b
google login implemented
shenyang44 Mar 4, 2020
a41695f
added protection for donations
shenyang44 Mar 4, 2020
3afe670
modals for viewing images upclose.
shenyang44 Mar 4, 2020
71dc7c9
created models for comments and follows
shenyang44 Mar 5, 2020
8d12406
follows and shit
shenyang44 Mar 5, 2020
8e6196a
listing fans and idols.
shenyang44 Mar 5, 2020
4687e40
added messages if peeps dont have followers or folliwiowfj
shenyang44 Mar 5, 2020
0ba1481
added authorized but no other code
shenyang44 Mar 6, 2020
0d93d6c
Update requirements.txt
shenyang44 Mar 6, 2020
5e172d6
removed pwdbev
shenyang44 Mar 6, 2020
b8560d3
yeah
shenyang44 Mar 6, 2020
fb4a47c
remved pwdbev
shenyang44 Mar 6, 2020
19ae1d9
removed procfile
shenyang44 Mar 6, 2020
cd6ea7c
added back pwdbev and procfile
shenyang44 Mar 6, 2020
d4b73e0
asidj
shenyang44 Mar 6, 2020
b80a44f
n
shenyang44 Mar 6, 2020
5b119f1
Update config.py
shenyang44 Mar 6, 2020
efd450f
asd
shenyang44 Mar 6, 2020
953613e
simple api call
shenyang44 Mar 9, 2020
d484c2e
placed block content into a tag and gave padding
shenyang44 Apr 18, 2020
d81750f
slight improvements to profile page layout and ui
shenyang44 Apr 18, 2020
2a03be2
styled index a bit more. fixed navbar to top of window
shenyang44 Apr 20, 2020
c207eaa
removing modal onclick on index and new hover effect
shenyang44 Apr 22, 2020
a030570
Captions, hovers, dollar sign.
shenyang44 Apr 23, 2020
7019e5e
donation available in prof pg
shenyang44 Apr 26, 2020
659eecf
moved image upload to its own pg
shenyang44 Apr 27, 2020
3bea9b6
to heroku
shenyang44 Apr 27, 2020
5a223ac
new image form updated. along with small profile changes
shenyang44 Apr 29, 2020
0a69761
filename check
shenyang44 May 1, 2020
2096a7b
function buttonUpdate.
shenyang44 May 2, 2020
66f937f
WIP search function
shenyang44 May 2, 2020
519df2c
completed search function
shenyang44 May 3, 2020
ca215c7
search results into grid
shenyang44 May 5, 2020
3d0cac1
monopoly board visuals, no logic
shenyang44 May 9, 2020
9f92b13
Merge pull request #2 from shenyang44/monopoly-board
shenyang44 May 9, 2020
b87181e
made new model for monopoly users. and sign up page
shenyang44 May 9, 2020
34e24e4
Merge pull request #3 from shenyang44/monopoly-board
shenyang44 May 9, 2020
1dc7447
moved properties into user model and passed positions into html
shenyang44 May 9, 2020
cede5df
Merge pull request #4 from shenyang44/monopoly-board
shenyang44 May 9, 2020
a794e60
dice rolling with effect on player position. reset button WIP propert…
shenyang44 May 10, 2020
4b16d13
Merge pull request #5 from shenyang44/monopoly-board
shenyang44 May 10, 2020
a86d1f3
form for new property name, auto jail if land on 30
shenyang44 May 10, 2020
3d09c54
Merge pull request #6 from shenyang44/monopoly-board
shenyang44 May 10, 2020
f318221
resets for houses and users jail counter and disabled some stuff if i…
shenyang44 May 10, 2020
cc12032
Merge pull request #7 from shenyang44/monopoly-board
shenyang44 May 10, 2020
f901df5
double rolls when in jail will move the player. altering jail status …
shenyang44 May 11, 2020
59b3f9d
Merge pull request #8 from shenyang44/monopoly-board
shenyang44 May 11, 2020
3321eaf
1500 on reset, 200 upon passing go. moved location display. banker no…
shenyang44 May 11, 2020
48822b1
Merge pull request #9 from shenyang44/monopoly-board
shenyang44 May 11, 2020
aefadff
form for payment
shenyang44 May 11, 2020
6ad83eb
Merge pull request #10 from shenyang44/monopoly-board
shenyang44 May 11, 2020
cc56586
small
shenyang44 May 11, 2020
b0a6819
for heroku
shenyang44 May 11, 2020
5ffac39
missed banker option
shenyang44 May 11, 2020
970d954
changed click listener to class instead of option tag
shenyang44 May 11, 2020
48022bf
payment method up and running
shenyang44 May 12, 2020
5b302de
fixed conflicts
shenyang44 May 12, 2020
4769dca
rolling doubles into jail and out of jail
shenyang44 May 15, 2020
9c1f360
Merge pull request #11 from shenyang44/monopoly-board
shenyang44 May 15, 2020
8bd3402
fixed regex, reformed jaill freeing and rolls
shenyang44 May 16, 2020
cdec436
Merge pull request #12 from shenyang44/monopoly-board
shenyang44 May 16, 2020
aaaf4fe
changed tooltip to p.text()
shenyang44 May 17, 2020
ee32054
rolls, jail rolls, jail payment all working cohesively
shenyang44 May 17, 2020
6b1af39
Merge pull request #13 from shenyang44/monopoly-board
shenyang44 May 17, 2020
cf90b41
removed unnecessary file, display if prop is owned
shenyang44 May 21, 2020
aebc40a
Merge pull request #14 from shenyang44/monopoly-board
shenyang44 May 21, 2020
acdc0dc
hover function, added classes, deleted useless files
shenyang44 May 24, 2020
da9b2de
Merge pull request #15 from shenyang44/monopoly-board
shenyang44 May 24, 2020
28dcac2
removed commented out code in mon/views
shenyang44 May 24, 2020
1beee0a
fixed syntax error
shenyang44 May 24, 2020
cc3c342
Merge pull request #16 from shenyang44/monopoly-board
shenyang44 May 24, 2020
7a901ab
added missing ecntype, image url for props are now returned as f
shenyang44 May 24, 2020
2d61004
Merge pull request #17 from shenyang44/monopoly-board
shenyang44 May 25, 2020
5466d48
gave id to all prop sections, image modal, trigerring.
shenyang44 May 25, 2020
9bb0b8c
id fix, and spelling correction piccadilly
shenyang44 May 25, 2020
46172b0
Merge pull request #18 from shenyang44/monopoly-board
shenyang44 May 25, 2020
3dfbbd7
uncommented img in html1
shenyang44 May 25, 2020
7769e61
app and start changes for socketio
shenyang44 May 26, 2020
e3d000b
messin with procfile
shenyang44 May 27, 2020
b24f956
reverted to app.run
shenyang44 May 27, 2020
1561f23
Merge pull request #19 from shenyang44/sockets
shenyang44 May 27, 2020
a3b40d2
removed module:app from procfile
shenyang44 May 27, 2020
330595f
emit to send 'message'
shenyang44 May 28, 2020
a881c85
changed send to give one argument
shenyang44 May 28, 2020
9a02063
send func in js only gives one arg
shenyang44 May 30, 2020
00efbf9
server sending back info to client socketio
shenyang44 May 30, 2020
5ed3dfd
spelling error
shenyang44 May 30, 2020
7c4bffe
removing return redirect from rolling func.
shenyang44 May 30, 2020
6e7f673
Update views.py
shenyang44 May 30, 2020
467749a
reverting last change. keeping return for roll f.
shenyang44 May 30, 2020
50635ac
changing pay form and activity update to use socket
shenyang44 May 30, 2020
d6b8333
Merge pull request #20 from shenyang44/sockets
shenyang44 May 30, 2020
67056f1
removed reference of monop.pay
shenyang44 May 30, 2020
44b658a
console logging to check values, toggling modal upon clicking btn
shenyang44 May 30, 2020
2dff6e6
js pay gives 1 arg, json to dict on py side
shenyang44 May 30, 2020
256eb05
hide modal from toggle
shenyang44 May 30, 2020
598425d
moved socket listeners inside doc ready
shenyang44 May 30, 2020
38fd3af
removed undef f
shenyang44 May 30, 2020
cf019fd
alert element added. And overwrote the close btn...
shenyang44 May 31, 2020
7b451d9
auto alert timeout. f for show and hide alert
shenyang44 Jun 1, 2020
44821b9
Merge pull request #21 from shenyang44/sockets
shenyang44 Jun 1, 2020
3c8a0bb
removing show from initial alert ele.
shenyang44 Jun 1, 2020
ef671b5
removing timeout temporarily
shenyang44 Jun 1, 2020
e5a955a
removing brackets from f call in timeout
shenyang44 Jun 1, 2020
1b21979
2 to 5
shenyang44 Jun 1, 2020
b3e5d1c
activities log fully managed via sockets
shenyang44 Jun 1, 2020
6114714
Merge pull request #22 from shenyang44/sockets
shenyang44 Jun 1, 2020
e354825
parentheses to curly brackets for string literal
shenyang44 Jun 1, 2020
e609e07
calls update all f on connection
shenyang44 Jun 1, 2020
6b277b2
user positions handled by sockets
shenyang44 Jun 1, 2020
c2ad64c
WIP get sock to work on local too
shenyang44 Jun 1, 2020
22612d0
Merge pull request #23 from shenyang44/sockets
shenyang44 Jun 1, 2020
0666dea
removed message from on connect and trying new start shit
shenyang44 Jun 1, 2020
700fabe
put socket.connected in if statement.
shenyang44 Jun 1, 2020
4f767b3
added hr
shenyang44 Jun 1, 2020
54af132
cleared containers upon update to prevent endless appends.
shenyang44 Jun 2, 2020
09dbd18
changing roll from form to sockets.
shenyang44 Jun 2, 2020
14605f8
Merge pull request #24 from shenyang44/sockets
shenyang44 Jun 2, 2020
372d6a6
changed redirect in roll f
shenyang44 Jun 2, 2020
5dfad78
from innerhtml to html
shenyang44 Jun 2, 2020
508a938
temporary bypass, forgot password
shenyang44 Jun 2, 2020
f9e05e9
removing sign in backdoor
shenyang44 Jun 2, 2020
fe91241
added order by for update pos
shenyang44 Jun 2, 2020
f393963
Property modal. sending owned props thru sock
shenyang44 Jun 2, 2020
6c76474
added foreach to append prop info into propRow
shenyang44 Jun 3, 2020
1c3b43b
Merge pull request #25 from shenyang44/sockets
shenyang44 Jun 3, 2020
e8465e4
handling house buying added
shenyang44 Jun 4, 2020
1cef8d8
money update in modal via sockets.
shenyang44 Jun 4, 2020
2fd79e8
Merge pull request #26 from shenyang44/sockets
shenyang44 Jun 4, 2020
85c8723
resizing img in prop modal
shenyang44 Jun 4, 2020
ae60f7e
adding if statement for house price 0
shenyang44 Jun 4, 2020
0e4f904
fix syntax error
shenyang44 Jun 4, 2020
86d7301
using not() to prepend house btn
shenyang44 Jun 5, 2020
0d1d71c
fixed some errors
shenyang44 Jun 5, 2020
f3b875a
fixed syntax error
shenyang44 Jun 5, 2020
fc99b2f
added static dropdown to transfer-btn
shenyang44 Jun 5, 2020
66d41c4
added other alerts, appending users to transfer prop
shenyang44 Jun 5, 2020
770c1aa
Merge pull request #27 from shenyang44/sockets
shenyang44 Jun 5, 2020
0ec21fa
moved money update in modal to request upon modal open
shenyang44 Jun 5, 2020
0f03d2d
confirm prompt for transferring properties.
shenyang44 Jun 5, 2020
2161f31
Merge pull request #28 from shenyang44/sockets
shenyang44 Jun 5, 2020
c5667bc
usernames clickable to view other owned props
shenyang44 Jun 6, 2020
0f3b58d
removed whitespaces
shenyang44 Jun 6, 2020
81d7769
added socket to handle jail pay
shenyang44 Jun 6, 2020
d011804
removed pay form elements, and jinja if statements
shenyang44 Jun 6, 2020
ca2db99
showing different roll btn with sock
shenyang44 Jun 6, 2020
3c4ea9a
Merge pull request #29 from shenyang44/sockets
shenyang44 Jun 6, 2020
c474ad9
removed a comment
shenyang44 Jun 7, 2020
e6e2059
moved mon property into own blueprint
shenyang44 Jun 7, 2020
7d55de1
Merge pull request #30 from shenyang44/sockets
shenyang44 Jun 7, 2020
bd8f156
new model cards and created page to upload pics
shenyang44 Jun 7, 2020
a8e8778
upload and view facility for cards
shenyang44 Jun 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
release: python migrate.py
web: gunicorn start:app --worker-class eventlet -w 1 --preload
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ Since this app uses Pooled Connections, you may also want to set:

```
DB_TIMEOUT=300 # 5 minutes
DB_POOL=5
DB_POOL=10
```

_(see `database.py`)_
Expand Down
18 changes: 18 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
from flask_wtf.csrf import CSRFProtect
import os
import config
from flask import Flask
from models.base_model import db
from flask_socketio import SocketIO, emit

# import logging
# import redis
# import gevent
# from flask_sockets import Sockets

# REDIS_URL = os.environ['REDIS_URL']
# REDIS_CHAN = 'chat'

# app.debug = 'DEBUG' in os.environ

# sockets = Sockets(app)
# redis = redis.from_url(REDIS_URL)

web_dir = os.path.join(os.path.dirname(
os.path.abspath(__file__)), 'instagram_web')

app = Flask('NEXTAGRAM', root_path=web_dir)
csrf = CSRFProtect(app)
socketio = SocketIO(app)


if os.getenv('FLASK_ENV') == 'production':
app.config.from_object("config.ProductionConfig")
Expand Down
15 changes: 15 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,21 @@ class Config(object):
'SECRET_KEY') or os.urandom(32)


S3_BUCKET = os.environ.get("S3_BUCKET")
S3_KEY = os.environ.get("S3_KEY")
S3_SECRET = os.environ.get("S3_SECRET_ACCESS_KEY")
S3_LOCATION = 'http://{}.s3.amazonaws.com/'.format(S3_BUCKET)

SECRET_KEY = os.environ.get('SECRET_KEY') or os.urandom(32)
DEBUG = True
PORT = 5000


class ProductionConfig(Config):
DEBUG = False
ASSETS_DEBUG = False
GOOGLE_CLIENT_ID = os.getenv('GC_ID')
GOOGLE_CLIENT_SECRET = os.getenv('GC_SECRET')


class StagingConfig(Config):
Expand All @@ -24,6 +36,9 @@ class DevelopmentConfig(Config):
DEVELOPMENT = True
DEBUG = True
ASSETS_DEBUG = False
GOOGLE_CLIENT_ID = os.getenv('GC_ID')
GOOGLE_CLIENT_SECRET = os.getenv('GC_SECRET')


class TestingConfig(Config):
TESTING = True
Expand Down
24 changes: 24 additions & 0 deletions helpers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import boto3
import botocore
from config import S3_KEY, S3_SECRET, S3_BUCKET

s3 = boto3.client(
"s3",
aws_access_key_id=S3_KEY,
aws_secret_access_key=S3_SECRET
)


def upload_file_to_s3(file, bucket_name):
try:
s3.upload_fileobj(
file,
bucket_name,
file.filename,
ExtraArgs={
"ACL": "public-read",
"ContentType": file.content_type
}
)
except Exception as e:
return e
20 changes: 16 additions & 4 deletions instagram_api/blueprints/users/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
from flask import Blueprint
from flask import Blueprint, jsonify
from models.user import User
from playhouse.shortcuts import model_to_dict


users_api_blueprint = Blueprint('users_api',
__name__,
template_folder='templates')
__name__,
template_folder='templates')


@users_api_blueprint.route('/', methods=['GET'])
def index():
return "USERS API"
users = User.select()
user_list = []
for user in users:
user = model_to_dict(user)
user_list.append(user)
# data = (user.__dict__)
# user_list.append(data['__data__'])

return jsonify(user_list)
27 changes: 25 additions & 2 deletions instagram_web/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,42 @@
from app import app
from flask import render_template
from flask import render_template, redirect, url_for
from instagram_web.blueprints.users.views import users_blueprint
from instagram_web.blueprints.sessions.views import sessions_blueprint
from flask_assets import Environment, Bundle
from .util.assets import bundles
from instagram_web.blueprints.images.views import images_blueprint
from instagram_web.blueprints.donations.views import donations_blueprint
from instagram_web.util.google_oauth import oauth
from instagram_web.blueprints.follows.views import follows_blueprint
from instagram_web.blueprints.monopoly.views import monopoly_blueprint
from instagram_web.blueprints.mon_prop.views import mon_prop_blueprint
from instagram_web.blueprints.cards.views import cards_blueprint

assets = Environment(app)
assets.register(bundles)
oauth.init_app(app)

app.register_blueprint(users_blueprint, url_prefix="/users")
app.register_blueprint(sessions_blueprint, url_prefix="/sessions")
app.register_blueprint(images_blueprint, url_prefix='/images')
app.register_blueprint(donations_blueprint, url_prefix='/donations')
app.register_blueprint(follows_blueprint, url_prefix='/follows')
app.register_blueprint(monopoly_blueprint, url_prefix='/monopoly')
app.register_blueprint(mon_prop_blueprint, url_prefix='/mon_prop')
app.register_blueprint(cards_blueprint, url_prefix='/cards')


@app.errorhandler(500)
def internal_server_error(e):
return render_template('500.html'), 500


@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html'), 404


@app.route("/")
def home():
return render_template('home.html')
# return render_template('home.html')
return redirect(url_for('users.index'))
19 changes: 19 additions & 0 deletions instagram_web/blueprints/cards/templates/cards/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>

<body>
{% for card in cards %}
<p>
<img src="{{card.image_url}}" width='300px' alt="">
{{card.category}}
</p>
{% endfor %}
</body>

</html>
48 changes: 48 additions & 0 deletions instagram_web/blueprints/cards/templates/cards/new.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% assets "home_css" %}
<link rel="stylesheet" href="{{ ASSET_URL }}">
{% endassets %}
{% assets "home_js" %}
<script src="https://kit.fontawesome.com/1816c993a6.js" crossorigin="anonymous"></script>
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}
<title>New Property!</title>
</head>

<body>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<div class=flashes>
{% for category, message in messages %}
<div class="alert alert-{{category}}">{{ message }}</div>
{% endfor %}
</div>
{% endif %}
{% endwith %}
<form action="{{url_for('cards.create')}}" method='POST' enctype="multipart/form-data">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<label for="description-input">Description:</label>
<input type="text" name="description" id='description-input'>
<label for="category-input">Category(chance or community)</label>
<input type="text" name='category' id='category-input'>
<hr>
<input type="file" name="image-file" id="image-file">
<img src="" width='300px' id='mon-preview' alt="">
<button type="submit">Submit</button>
</form>
<script>
$(document).ready(() => {
$('#image-file').change((e) => {
$('#mon-preview').attr('src', URL.createObjectURL(e.target.files[0]))
console.log(e.target)
})
})
</script>
</body>

</html>
44 changes: 44 additions & 0 deletions instagram_web/blueprints/cards/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
from flask import request, redirect, url_for, render_template, flash, Blueprint
from models.cards import Card
import json
from flask_socketio import send, emit
from app import socketio
from flask_login import current_user
from models.user import User
from werkzeug.utils import secure_filename
from helpers import upload_file_to_s3
from config import S3_BUCKET

cards_blueprint = Blueprint('cards', __name__, template_folder='templates')


@cards_blueprint.route('/new')
def new():
return render_template('cards/new.html')


@cards_blueprint.route('/create', methods=['POST'])
def create():
description = request.form.get('description')
category = request.form.get('category')
if 'image-file' not in request.files:
flash('no file was chosen!', 'warning')
return redirect(request.referrer)
file = request.files.get('image-file')
file_name = secure_filename(file.filename)
img_upload_err = str(upload_file_to_s3(file, S3_BUCKET))
new_card = Card(description=description,
category=category, image=file_name)

if new_card.save():
flash('new card was saved', 'success')
else:
flash(f'saving failed, {img_upload_err}', 'danger')

return redirect(request.referrer)


@cards_blueprint.route('/')
def index():
cards = Card.select()
return render_template('cards/index.html', cards=cards)
53 changes: 53 additions & 0 deletions instagram_web/blueprints/donations/templates/donations/new.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% extends '_layout.html' %}

{% block header %}
<script src="https://js.braintreegateway.com/web/dropin/1.22.1/js/dropin.min.js"></script>
{% endblock %}

{% block content%}
<main>
<form action="{{url_for('donations.create', image_id=image_id)}}" method="POST" id='payment_form'>
<input type="hidden" name='csrf_token' value="{{ csrf_token() }}">
<input type='hidden' id='payment_nonce' name='payment_nonce'>
<div id="dropin-container"></div>
<label for="amount">Donation amount:</label>
<div id='amount-warning'></div>
<input type="number" name='amount'>
</form>
<summary>
100% of the donations will go to user you have chosen to donate to.
<br>
Non-refundable.
<br>
Please be noted no exchange of goods is occuring.
</summary>
<hr>
<button class="btn-primary" id="dono-button">Confirm</button>
</main>
<div>
{{result}}
</div>

<script>
const button = document.querySelector('#dono-button');

braintree.dropin.create({
authorization: '{{client_token}}',
container: '#dropin-container'
}, function (createErr, instance) {
button.addEventListener('click', function () {
instance.requestPaymentMethod(function (err, payload) {
if (payload) {
//implement amount checking please.
$('#payment_nonce').val(payload.nonce)
$('#payment_form').submit()
}
console.log(err)
console.log(payload)
});
});
});


</script>
{% endblock %}
Loading