commiting current progress on paypal integration
22
Dockerfile
|
@ -6,28 +6,24 @@ FROM ubuntu:14.04
|
|||
MAINTAINER Oliver Marks "olymk2@gmail.com"
|
||||
|
||||
# make sure the package repository is up to date
|
||||
|
||||
RUN \
|
||||
apt-get update && \
|
||||
apt-get upgrade -y && \
|
||||
apt-get install -y libssl-dev libffi-dev && \
|
||||
apt-get install -y software-properties-common python-software-properties && \
|
||||
apt-get install -y python-pip python-requests python-lxml python-flask python-flask-login python-misaka python-tz python-mysqldb python-psycopg2 python-requests-oauthlib
|
||||
|
||||
RUN add-apt-repository -y ppa:oly/ppa
|
||||
RUN apt-get update
|
||||
RUN apt-get install -y python-scaffold
|
||||
RUN pip install gocardless
|
||||
|
||||
ADD site /var/www/
|
||||
apt-get install -y python-pip python-dev python-requests python-lxml python-flask python-flask-login && \
|
||||
apt-get install -y cssmin slimit && \
|
||||
add-apt-repository -y ppa:oly/ppa && \
|
||||
apt-get update && \
|
||||
apt-get install -y python-scaffold
|
||||
|
||||
RUN pip install gocardless paypalrestsdk
|
||||
|
||||
#allow access to flask
|
||||
EXPOSE 5000 5000
|
||||
EXPOSE 5000 5002
|
||||
|
||||
#RUN /bin/sh -c 'cd /var/www; python index.py'
|
||||
|
||||
ENTRYPOINT /bin/sh -c 'cd /var/www; python index.py'
|
||||
|
||||
#ENTRYPOINT /bin/sh -c 'cd /var/www; python index.py'
|
||||
|
||||
#docker build -t mhackspace .
|
||||
#docker run -d --name=mhackspace_container --restart=always mhackspace
|
||||
|
|
20
README.md
|
@ -26,11 +26,27 @@ To generate static content you can run the code below.
|
|||
``` python generate.py ```
|
||||
|
||||
|
||||
Testing the payment systems
|
||||
---------------------------
|
||||
|
||||
Both paypal and gocardless clearly show that you are using the sandbox in the url.
|
||||
|
||||
for paypal you can use this email and password
|
||||
|
||||
email = contact-buyer@maidstone-hackspace.org.uk
|
||||
password = mhackspace
|
||||
|
||||
To test the gocardless integration you can use these card details
|
||||
|
||||
sortcode = 200000
|
||||
account number = 55779911
|
||||
|
||||
|
||||
|
||||
Run locally with uwsgi on port 9090
|
||||
|
||||
uwsgi --plugins python --http-socket :9090 -w wsgi
|
||||
uwsgi --plugins python --http-socket :9090 -w wsgi
|
||||
|
||||
Run locally with flask
|
||||
python index.py
|
||||
|
||||
python index.py
|
||||
|
|
|
@ -4,3 +4,4 @@ requests
|
|||
pytz
|
||||
pip install -e bzr+lp:scaffold#egg=scaffold
|
||||
python-requests-oauthlib
|
||||
paypalrestsdk
|
||||
|
|
|
@ -11,7 +11,7 @@ from flask import request
|
|||
from flask import Blueprint
|
||||
from flask.ext.login import LoginManager, login_required, UserMixin, login_user, logout_user, make_secure_token
|
||||
from requests_oauthlib import OAuth2Session
|
||||
|
||||
from requests_oauthlib.compliance_fixes import facebook_compliance_fix
|
||||
|
||||
from scaffold import web
|
||||
from libs.mail import sendmail
|
||||
|
@ -140,12 +140,12 @@ def register_submit():
|
|||
web.template.body.append(web.page.render())
|
||||
return make_response(footer())
|
||||
|
||||
@authorize_pages.route("/oauth", methods=['GET'])
|
||||
@authorize_pages.route("/oauth/", methods=['GET'])
|
||||
@authorize_pages.route("/oauth/<provider>/<state>", methods=['GET'])
|
||||
@authorize_pages.route("/oauth/<provider>/<state>/", methods=['GET'])
|
||||
@authorize_pages.route("/oauth/<provider>", methods=['GET'])
|
||||
def oauth(provider=None):
|
||||
def oauth(provider, state=None):
|
||||
oauth_verify = True
|
||||
oauth_provider = oauth_conf.get('google')
|
||||
oauth_provider = oauth_conf.get(provider)
|
||||
oauth_access_type = ''
|
||||
oauth_approval_prompt = ''
|
||||
if oauth_live is False:
|
||||
|
@ -153,14 +153,16 @@ def oauth(provider=None):
|
|||
oauth_access_type = 'offline'
|
||||
oauth_approval_prompt = "force"
|
||||
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
|
||||
|
||||
if provider:
|
||||
print provider
|
||||
print '#####'
|
||||
if state:
|
||||
oauth_session = OAuth2Session(
|
||||
oauth_provider.get('client_id'),
|
||||
scope=oauth_provider.get('scope'),
|
||||
redirect_uri=oauth_provider.get('redirect_uri'))
|
||||
|
||||
if provider == 'facebook':
|
||||
oauth_session = facebook_compliance_fix(oauth_session)
|
||||
|
||||
# offline for refresh token
|
||||
# force to always make user click authorize
|
||||
# generate the google url we will use to authorize and redirect there
|
||||
|
@ -174,15 +176,26 @@ def oauth(provider=None):
|
|||
session['oauth_state'] = state
|
||||
session.modified = True
|
||||
print session
|
||||
print authorization_url
|
||||
return redirect(authorization_url)
|
||||
|
||||
print '-----'
|
||||
print provider
|
||||
print session
|
||||
print session['oauth_state']
|
||||
# allready authorised so lets handle the callback
|
||||
oauth_session = OAuth2Session(
|
||||
oauth_provider.get('client_id'),
|
||||
state=session['oauth_state'],
|
||||
redirect_uri=oauth_provider.get('redirect_uri'))
|
||||
|
||||
#~ if provider == 'facebook':
|
||||
#~ oauth_session = facebook_compliance_fix(oauth_session)
|
||||
|
||||
print '@@@@@@@'
|
||||
print request.url
|
||||
print oauth_provider.get('redirect_uri')
|
||||
# code error is todo with authorisation response
|
||||
oauth_session.fetch_token(
|
||||
oauth_provider.get('token_uri'),
|
||||
client_secret=oauth_provider.get('client_secret'),
|
||||
|
@ -190,9 +203,12 @@ def oauth(provider=None):
|
|||
verify=oauth_verify)
|
||||
|
||||
# Fetch a protected resource, i.e. user profile
|
||||
r = oauth_session.get('https://www.googleapis.com/oauth2/v1/userinfo')
|
||||
r = oauth_session.get(oauth_provider.get('user_uri'))
|
||||
|
||||
|
||||
|
||||
oauth_user = r.json()
|
||||
print oauth_user
|
||||
user_details = site_user.get_by_email({
|
||||
'email': oauth_user.get('email')
|
||||
}).get()
|
||||
|
|
|
@ -28,21 +28,15 @@ oauth_live = False
|
|||
oauth_redirect_uri = app_domain + '/oauth'
|
||||
oauth_conf = {
|
||||
'google': {},
|
||||
'twitter': {}
|
||||
}
|
||||
|
||||
|
||||
gocardless_environment = 'sandbox'
|
||||
gocardless_redirect_uri = 'https://test.maidstone-hackspace.org.uk'
|
||||
gocardless_credentials = {
|
||||
'app_id': '',
|
||||
'app_secret': '',
|
||||
'access_token': '',
|
||||
'merchant_id': ''
|
||||
}
|
||||
|
||||
google_calendar_id = 'contact@maidstone-hackspace.org.uk'
|
||||
google_calendar_api_key = 'AIzaSyA98JvRDmplA9lVLZeKwrs1f2k17resLy0'
|
||||
|
||||
payment_providers = {}
|
||||
|
||||
if os.path.exists('config/settings_dev.py'):
|
||||
print 'Using settings for dev enviroment'
|
||||
from settings_dev import *
|
||||
|
|
|
@ -68,6 +68,15 @@ email_server = {
|
|||
'from': 'support@maidstone-hackspace.org.uk',
|
||||
'to': 'support@maidstone-hackspace.org.uk'}
|
||||
|
||||
badge_lookup = {
|
||||
1: 'member',
|
||||
2: 'backer',
|
||||
3: 'teacher',
|
||||
4: 'chairman',
|
||||
5: 'treasurer',
|
||||
6: 'secretary'
|
||||
}
|
||||
|
||||
|
||||
url_home= '/'
|
||||
url_profile = '/profile'
|
||||
|
|
|
@ -31,7 +31,7 @@ class add_pledge(insert_data):
|
|||
class add_payment(insert_data):
|
||||
debug = True
|
||||
table = 'pledge_amounts'
|
||||
required = {'pledge_id', 'reference', 'amount', 'environment'}
|
||||
columns = {'pledge_id', 'reference', 'amount', 'environment'}
|
||||
required = {'provider_id', 'pledge_id', 'reference', 'amount', 'environment'}
|
||||
columns = {'provider_id', 'pledge_id', 'reference', 'amount', 'environment'}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import os
|
||||
from scaffold.core.data.select import select_data
|
||||
#~ from scaffold.core.data.insert import insert_data
|
||||
#~ from scaffold.core.data.update import update_data
|
||||
from scaffold.core.data.update import update_data
|
||||
#~ from scaffold.core.data.delete import delete_data
|
||||
from scaffold.core.data.sql import query_builder
|
||||
|
||||
|
@ -13,8 +13,24 @@ class get_members(select_data):
|
|||
query_file = 'member_list.sql'
|
||||
columns = {}
|
||||
|
||||
|
||||
class get_member_profile(select_data):
|
||||
required = {'id'}
|
||||
query_file = 'get_users.sql'
|
||||
columns_where = {'id'}
|
||||
|
||||
class fetch_member_badges(select_data):
|
||||
required = {'id'}
|
||||
query_file = 'fetch_user_badges.sql'
|
||||
columns_where = {'id'}
|
||||
|
||||
class update_membership_status(update_data):
|
||||
debug = True
|
||||
query_str = "update `users` set `status`=%(status)s where id=%(user_id)s"
|
||||
required = {'user_id', 'status'}
|
||||
columns_where = {}
|
||||
|
||||
class fetch_member_subscription(select_data):
|
||||
debug = True
|
||||
required = {'user_id'}
|
||||
query_str = 'select provider_id, subscription_reference from user_membership'
|
||||
columns_where = {'user_id'}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import os
|
||||
|
||||
#~ from scaffold.core.data.select import select_data
|
||||
from scaffold.core.data.select import select_data
|
||||
from scaffold.core.data.insert import insert_data
|
||||
from scaffold.core.data.update import update_data
|
||||
#~ from scaffold.core.data.delete import delete_data
|
||||
|
@ -8,7 +8,8 @@ from scaffold.core.data.sql import query_builder
|
|||
|
||||
query_builder.query_path = os.path.abspath('./data/sql/')
|
||||
|
||||
|
||||
class fetch_users(select_data):
|
||||
query_file = 'get_users.sql'
|
||||
|
||||
class update_description(update_data):
|
||||
debug = True
|
||||
|
|
|
@ -9,6 +9,19 @@ from scaffold.core.data.sql import query_builder
|
|||
query_builder.query_path = os.path.abspath('./data/sql/')
|
||||
|
||||
|
||||
class create_basic_user(insert_data):
|
||||
"""not able to actually log in but registered on the system"""
|
||||
table = 'users'
|
||||
required = {'email', 'first_name', 'last_name'}
|
||||
columns = {'email','first_name', 'last_name'}
|
||||
|
||||
def calculated_data(self):
|
||||
return {'created': time.strftime('%Y-%m-%d %H:%M:%S')}
|
||||
|
||||
def set(self, data):
|
||||
data['created'] = time.strftime('%Y-%m-%d %H:%M:%S')
|
||||
super(create_basic_user, self).set(data)
|
||||
|
||||
class create(insert_data):
|
||||
table = 'users'
|
||||
required = {'email', 'password', 'username', 'first_name', 'last_name', 'created'}
|
||||
|
@ -36,17 +49,24 @@ class update_membership_status(update_data):
|
|||
required = {'user_id', 'status'}
|
||||
columns_where = {}
|
||||
|
||||
class create_membership(insert_data):
|
||||
debug = True
|
||||
table = 'user_membership'
|
||||
required = {'user_id', 'subscription_reference', 'status', 'amount', 'join_date'}
|
||||
columns = {'user_id', 'subscription_reference', 'status', 'amount', 'join_date'}
|
||||
columns_where = {}
|
||||
|
||||
class update_membership(update_data):
|
||||
debug = True
|
||||
query_str = """
|
||||
update `user_membership` set
|
||||
`status`=%(status)s,
|
||||
subscription_id=%(subscription_is),
|
||||
query_str = u"""
|
||||
update user_membership set
|
||||
status=%(status)s,
|
||||
subscription_reference=%(subscription_reference)s,
|
||||
amount=%(amount)s,
|
||||
join_date=%(join_date)s
|
||||
where id=%(user_id)s"""
|
||||
required = {'subscription_id', 'status', 'amount', 'join_date'}
|
||||
columns_where = {'user_id'}
|
||||
required = {'subscription_reference', 'status', 'amount', 'join_date'}
|
||||
columns_where = {}
|
||||
|
||||
class delete_password_reset(delete_data):
|
||||
"""clean up expired password resets"""
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
select users.id as user_id, status, first_name, last_name, users.profile_image, description, skills
|
||||
select users.id as user_id, status, email, first_name, last_name, users.profile_image, description, skills
|
||||
from users
|
||||
left join user_detail on user_detail.user_id=users.id
|
||||
|
|
|
@ -19,7 +19,7 @@ from pages.equipment import equipment_pages
|
|||
from pages.profile import profile_pages
|
||||
from authorize import authorize_pages, login_manager
|
||||
|
||||
web_app = Flask(__name__, static_url_path='/static')
|
||||
web_app = Flask(__name__)
|
||||
web_app.config['PROPAGATE_EXCEPTIONS'] = True
|
||||
web_app.secret_key = settings.flask_secret_key
|
||||
login_manager.init_app(web_app)
|
||||
|
@ -30,6 +30,10 @@ web_app.register_blueprint(profile_pages)
|
|||
web_app.register_blueprint(google_groups_pages)
|
||||
web_app.register_blueprint(donate_pages)
|
||||
|
||||
@web_app.route('/static/<path:path>')
|
||||
def send_js(path):
|
||||
print path
|
||||
return send_from_directory('/static_resources', path)
|
||||
|
||||
# local testing server, add your pages here
|
||||
@web_app.route("/examples/", methods=['GET'])
|
||||
|
|
|
@ -7,7 +7,7 @@ from scaffold.core.data.database import db
|
|||
db.config(settings.database)
|
||||
from scaffold.core.data.migrations import export_schema, import_schema
|
||||
|
||||
export_schema()
|
||||
export_schema(os.path.abspath('./sql/migrations/'))
|
||||
#import_schema()
|
||||
|
||||
|
||||
|
|
|
@ -5,8 +5,9 @@ from flask import redirect, abort
|
|||
from scaffold import web
|
||||
from scaffold.core.validate import validate
|
||||
from pages import header, footer
|
||||
from data import donate
|
||||
from data import donate, site_user, badges, members
|
||||
|
||||
from libs.payments import payment
|
||||
from config.settings import *
|
||||
|
||||
donate_pages = Blueprint('donate_pages', __name__, template_folder='templates')
|
||||
|
@ -23,91 +24,132 @@ def index():
|
|||
We may run pledges in the future for equipment in which case use the reference for the equipment your pledging towards.""")
|
||||
|
||||
web.page.section(web.paragraph.render())
|
||||
for item in donate.get_pledges({'environment':int(gocardless_environment=='production')}):
|
||||
web.paragraph.create(
|
||||
"""Currently raised £%.2f towards %s target is £%.2f.""" % (
|
||||
item.get('total', 0) if item.get('total', 0) else 0.0,
|
||||
item.get('name'),
|
||||
item.get('target', 0)))
|
||||
web.page.section(web.paragraph.render())
|
||||
#~ for item in donate.get_pledges({'environment':int(gocardless_environment=='production')}):
|
||||
#~ web.paragraph.create(
|
||||
#~ """Currently raised £%.2f towards %s target is £%.2f.""" % (
|
||||
#~ item.get('total', 0) if item.get('total', 0) else 0.0,
|
||||
#~ item.get('name'),
|
||||
#~ item.get('target', 0)))
|
||||
#~ web.page.section(web.paragraph.render())
|
||||
|
||||
|
||||
web.form.create('Donate to Maidstone Hackspace', '/donate/submit')
|
||||
web.form.append(name='provider', label='GoCardless', placeholder='gocardless', value='gocardless', input_type='radio')
|
||||
web.form.append(name='provider', label='PayPal', placeholder='', value='paypal', input_type='radio')
|
||||
web.form.append(name='reference', label='Reference', placeholder='#lair', value='#lair', input_type='select')
|
||||
web.form.append(name='amount', label='Donation Amount', placeholder='50.00', value='50.00')
|
||||
|
||||
web.page.append(web.form.render())
|
||||
|
||||
web.template.body.append(web.page.render())
|
||||
return footer()
|
||||
|
||||
|
||||
@donate_pages.route("/donate/populate", methods=['GET'])
|
||||
def populate_by_name():
|
||||
web.template.create('Maidstone Hackspace')
|
||||
header('Maidstone Hackspace Donations')
|
||||
|
||||
pledge = donate.get_pledge({'name': '#lair'}).get()
|
||||
print pledge
|
||||
|
||||
import gocardless
|
||||
gocardless.environment = gocardless_environment
|
||||
gocardless.set_details(**gocardless_credentials)
|
||||
merchant = gocardless.client.merchant()
|
||||
|
||||
web.template.body.append('Adding Badges')
|
||||
badges.create_badge().execute({'name': 'member'})
|
||||
badges.create_badge().execute({'name': 'backer'})
|
||||
badges.create_badge().execute({'name': 'teacher'})
|
||||
badges.create_badge().execute({'name': 'chairman'})
|
||||
badges.create_badge().execute({'name': 'treasurer'})
|
||||
badges.create_badge().execute({'name': 'secretary'})
|
||||
|
||||
web.template.body.append('Populating users')
|
||||
user_list = {}
|
||||
#make sure we have all users in the system
|
||||
print '--------------'
|
||||
#~ users_emails = []
|
||||
for user in merchant.users():
|
||||
#~ print dir(user)
|
||||
user_list[user.id] = user.email
|
||||
#~ users_emails.append(user.email)
|
||||
site_user.create_basic_user().execute({
|
||||
'email': user.email,
|
||||
'first_name': user.first_name,
|
||||
'last_name': user.last_name
|
||||
})
|
||||
|
||||
#get the users ids and emails
|
||||
#~ users = {}
|
||||
#~ for member in members.get_members():
|
||||
#~ for key, value in user_list.items():
|
||||
#~ if value == member.get('email'):
|
||||
#~ user_list[key] = member.get('user_id')
|
||||
|
||||
badge_lookup = {badge.get('name'):badge.get('id') for badge in badges.fetch_badges()}
|
||||
|
||||
web.template.body.append('Setting Donation Badges')
|
||||
environment = int(gocardless_environment=='production')
|
||||
for bill in merchant.bills():
|
||||
environment = int(gocardless_environment=='production')
|
||||
donate.add_payment().execute({'pledge_id': pledge.get('id') , 'reference': bill.id, 'amount': bill.amount_minus_fees, 'environment': environment})
|
||||
return abort(404)
|
||||
web.template.body.append(str(bill))
|
||||
|
||||
matched_user = None
|
||||
for user_id, user_email in user_list.items():
|
||||
if user_email == user.email:
|
||||
matched_user = user_id
|
||||
|
||||
donate.add_payment().execute({'user_id': matched_user,'pledge_id': pledge.get('id') , 'reference': bill.id, 'amount': bill.amount_minus_fees, 'environment': environment})
|
||||
|
||||
if matched_user:
|
||||
badges.assign_badge().execute({'badge_id': badge_lookup.get('backer'), 'user_id': matched_user})
|
||||
|
||||
return footer()
|
||||
|
||||
|
||||
@donate_pages.route("/donate/submit", methods=['POST'])
|
||||
def submit_donation():
|
||||
#~ if request.form.get('amount'):
|
||||
|
||||
#~ return index()
|
||||
|
||||
import gocardless
|
||||
gocardless.environment = gocardless_environment
|
||||
gocardless.set_details(**gocardless_credentials)
|
||||
url = gocardless.client.new_bill_url(
|
||||
request.form.get('amount'),
|
||||
name=request.form.get('reference'),
|
||||
redirect_uri='%s/donate/success' % app_domain)
|
||||
#~ redirect_uri='%s/donate/success' % gocardless_redirect_uri if gocardless_redirect_uri else app_domain)
|
||||
provider = payment(
|
||||
provider='paypal',
|
||||
style='payment')
|
||||
|
||||
url = provider.make_donation(
|
||||
amount=request.form.get('amount'),
|
||||
reference=request.form.get('reference', ''),
|
||||
redirect_success='%s/donate/success' % app_domain,
|
||||
redirect_failure='%s/donate/failure' % app_domain
|
||||
)
|
||||
|
||||
return redirect(url)
|
||||
|
||||
|
||||
@donate_pages.route("/donate/success", methods=['GET'])
|
||||
def success_donation():
|
||||
# confirm the payment
|
||||
|
||||
bill_id = request.args.get('resource_id')
|
||||
try:
|
||||
import gocardless
|
||||
gocardless.environment = gocardless_environment
|
||||
gocardless.set_details(**gocardless_credentials)
|
||||
gocardless.client.confirm_resource(request.args)
|
||||
|
||||
provider = payment(
|
||||
provider='paypal',
|
||||
style='payment')
|
||||
|
||||
bill = provider.confirm(request.args)
|
||||
if bill:
|
||||
pledge = donate.get_pledge({'name': bill.get('name')}).get()
|
||||
|
||||
environment = int(provider.environment=='production')
|
||||
donate.add_payment().execute({
|
||||
'provider_id': provider.provider_id,
|
||||
'pledge_id': pledge.get('id',''),
|
||||
'reference': bill.get('reference'),
|
||||
'amount': bill.get('amount'),
|
||||
'environment': environment})
|
||||
|
||||
web.page.create('Thanks for your donation')
|
||||
web.paragraph.create(
|
||||
"""Thanks your payment has been recieved.""")
|
||||
except:
|
||||
# TODO log what actually has gone wrong
|
||||
else:
|
||||
web.page.create('Something went wrong')
|
||||
web.paragraph.create(
|
||||
"""We could not confirm the payment something may have gone terribly wrong.""")
|
||||
|
||||
if bill_id:
|
||||
bill = gocardless.client.bill(bill_id)
|
||||
pledge = donate.get_pledge({'name': bill.name}).get()
|
||||
|
||||
#~ print dir(bill)
|
||||
|
||||
print bill.amount
|
||||
print bill.amount_minus_fees
|
||||
print bill.charge_customer_at
|
||||
print bill.created_at
|
||||
print bill.name
|
||||
print bill.payout
|
||||
print bill.status
|
||||
print bill.user
|
||||
environment = int(gocardless_environment=='production')
|
||||
donate.add_payment().execute({'pledge_id':pledge.get('id','') , 'reference': bill_id, 'amount': bill.amount_minus_fees, 'environment': environment})
|
||||
|
||||
|
||||
web.template.create('Maidstone Hackspace')
|
||||
header('Maidstone Hackspace Donations')
|
||||
web.page.create('Thanks for your donation')
|
||||
|
|
|
@ -3,7 +3,10 @@ from flask.ext.login import login_required
|
|||
from pages import web
|
||||
from pages import header, footer
|
||||
from data import members
|
||||
from data import badges
|
||||
from constants import badge_lookup
|
||||
|
||||
b = {'1':'test', '2': 'abc'}
|
||||
|
||||
@login_required
|
||||
def index():
|
||||
|
@ -12,20 +15,29 @@ def index():
|
|||
web.page.create('Members')
|
||||
web.member_tiles.create()
|
||||
|
||||
members_badges = badges.fetch_user_badges_grouped()
|
||||
count_users = 0
|
||||
count_members = 0
|
||||
for item in members.get_members():
|
||||
badges = []
|
||||
print item
|
||||
if item.get('status') == 1:
|
||||
badges.append('member')
|
||||
|
||||
member_badges = [
|
||||
badge_lookup.get(b, '')
|
||||
for b in members_badges.get(item.get('user_id'), [])]
|
||||
|
||||
name = '%s %s' % (item.get('first_name'), item.get('last_name'))
|
||||
web.member_tiles.append(
|
||||
name = name,
|
||||
image = item.get('profile_image'),
|
||||
description=item.get('description') or 'Reclusive raccoon',
|
||||
link=item.get('user_id'),
|
||||
badges=badges,
|
||||
badges=member_badges,
|
||||
skills=item.get('skills') or 'badger taunting')
|
||||
count_users += 1
|
||||
if item.get('status') is 1:
|
||||
count_members += 1
|
||||
print count_members
|
||||
web.page.section('Members %d' % count_members)
|
||||
web.page.section('Users %d' % count_users)
|
||||
|
||||
web.container.create(web.member_tiles.render()).set_classes('members')
|
||||
web.page.section(web.container.render())
|
||||
web.template.body.append(web.page.render())
|
||||
|
|
|
@ -2,15 +2,25 @@ from flask import Blueprint
|
|||
from flask import request
|
||||
from flask import redirect
|
||||
from flask.ext.login import current_user, login_required
|
||||
import gocardless
|
||||
|
||||
from constants import badge_lookup
|
||||
|
||||
from pages import web
|
||||
from pages import header, footer
|
||||
from data.site_user import get_user_details, update_membership_status, get_user_bio
|
||||
from data.profile import update_description, create_description
|
||||
from data.site_user import get_user_details, update_membership, update_membership_status, get_user_bio, create_membership
|
||||
from data.profile import update_description, create_description, fetch_users
|
||||
from data import badges
|
||||
from data import members
|
||||
from config.settings import gocardless_environment, gocardless_credentials
|
||||
from config.settings import app_domain
|
||||
|
||||
from libs.payments import payment
|
||||
from config.settings import *
|
||||
|
||||
#~ import gocardless
|
||||
#~ gocardless.environment = gocardless_environment
|
||||
#~ gocardless.set_details(**gocardless_credentials)
|
||||
|
||||
profile_pages = Blueprint('profile_pages', __name__, template_folder='templates')
|
||||
|
||||
|
||||
|
@ -66,55 +76,93 @@ def index():
|
|||
web.template.body.append('<script type="type/javascript">document.cookie = "status=1";</script>')
|
||||
return footer()
|
||||
|
||||
@profile_pages.route("/profile/setup", methods=['GET'])
|
||||
@login_required
|
||||
def setup():
|
||||
"""utility url, insert new data and refresh user details"""
|
||||
web.template.body.append('Adding badge Types')
|
||||
for badge_id, badge_name in badge_lookup.items():
|
||||
badges.create_badge().execute({'id': badge_id, 'name': badge_name})
|
||||
|
||||
user_lookup = {}
|
||||
for member in fetch_users():
|
||||
user_lookup[member.get('email')] = member.get('user_id')
|
||||
|
||||
provider = payment(provider='paypal', style='payment')
|
||||
for item in provider.fetch_subscriptions():
|
||||
print item
|
||||
|
||||
print user_lookup
|
||||
merchant = gocardless.client.merchant()
|
||||
#https://jsfiddle.net/api/post/library/pure/
|
||||
for paying_member in merchant.subscriptions():
|
||||
print dir(paying_member)
|
||||
print paying_member.user()
|
||||
print paying_member.amount
|
||||
user=paying_member.user()
|
||||
|
||||
print '---------------'
|
||||
print user.email
|
||||
user_id = user_lookup.get(user.email)
|
||||
print user_id
|
||||
update_membership_status().execute({'user_id': user_id, 'status': '1'})
|
||||
create_membership().execute({'user_id': user_id, 'status': '1', 'join_date': paying_member.created_at, 'amount': paying_member.amount, 'subscription_id': paying_member.id})
|
||||
|
||||
|
||||
return footer()
|
||||
|
||||
@profile_pages.route("/profile/membership", methods=['POST'])
|
||||
@login_required
|
||||
def pay_membership():
|
||||
import gocardless
|
||||
|
||||
user = get_user_details({'id': current_user.get_id()}).get()
|
||||
user_code = str(user.get('user_id')).zfill(5)
|
||||
|
||||
gocardless.environment = gocardless_environment
|
||||
gocardless.set_details(**gocardless_credentials)
|
||||
url = gocardless.client.new_subscription_url(
|
||||
amount=request.form.get('amount'),
|
||||
interval_length=1,
|
||||
interval_unit="month",
|
||||
|
||||
selected_provider = request.form.get('provider', 'gocardless')
|
||||
provider = payment(provider=selected_provider, style='payment')
|
||||
success_url = '%s/profile/membership/%s/success' % (app_domain, selected_provider)
|
||||
failure_url = '%s/profile/membership/%s/failure' % (app_domain, selected_provider)
|
||||
url = provider.subscribe(
|
||||
amount=request.form.get('amount'),
|
||||
name="Membership your membership id is MH%s" % user_code,
|
||||
redirect_uri='%s/profile/gocardless' % app_domain)
|
||||
redirect_success=success_url,
|
||||
redirect_failure=failure_url
|
||||
)
|
||||
|
||||
|
||||
return redirect(url)
|
||||
|
||||
|
||||
@profile_pages.route("/profile/membership/failure", methods=['GET'])
|
||||
@profile_pages.route("/profile/membership/cancel", methods=['GET'])
|
||||
@login_required
|
||||
def cancel_membership():
|
||||
import gocardless
|
||||
|
||||
user = get_user_details({'id': current_user.get_id()}).get()
|
||||
user_code = str(user.get('user_id')).zfill(5)
|
||||
|
||||
gocardless.environment = gocardless_environment
|
||||
gocardless.set_details(**gocardless_credentials)
|
||||
subscription = members.fetch_member_subscription({'user_id': current_user.get_id()}).get()
|
||||
print subscription.get('provider_id')
|
||||
print subscription.get('subscription_reference')
|
||||
|
||||
|
||||
provider = payment(provider='paypal', style='payment')
|
||||
provider.lookup_provider_by_id(1)
|
||||
url = provider.unsubscribe(reference=subscription.get('subscription_reference'))
|
||||
|
||||
subscription = gocardless.client.subscription('0540QD22SKND')
|
||||
subscription.cancel()
|
||||
return redirect(url)
|
||||
members.update_membership_status().execute({'user_id':current_user.get_id(), 'status': '0'})
|
||||
|
||||
return redirect('/profile')
|
||||
|
||||
@profile_pages.route("/profile/gocardless", methods=['GET'])
|
||||
@profile_pages.route("/profile/membership/<provider>/success", methods=['GET'])
|
||||
@profile_pages.route("/profile/membership/<provider>/success/", methods=['GET'])
|
||||
@login_required
|
||||
def gocardless_signup():
|
||||
def membership_signup(provider):
|
||||
web.template.create('Maidstone Hackspace')
|
||||
header('Maidstone Hackspace Member registration')
|
||||
|
||||
# confirm the payment
|
||||
bill_id = request.args.get('resource_id')
|
||||
provider = payment(provider=provider, style='payment')
|
||||
|
||||
payment_details = provider.subscribe_confirm(request.args)
|
||||
try:
|
||||
import gocardless
|
||||
gocardless.environment = gocardless_environment
|
||||
gocardless.set_details(**gocardless_credentials)
|
||||
print gocardless.client.confirm_resource(request.args)
|
||||
web.page.create('Thanks for becoming a member.')
|
||||
web.paragraph.create(
|
||||
"""Your membership request has been recieved and will be active shortly.""")
|
||||
|
@ -124,14 +172,41 @@ def gocardless_signup():
|
|||
web.paragraph.create(
|
||||
"""We could not confirm the payment something may have gone terribly wrong.""")
|
||||
|
||||
if payment_details is None:
|
||||
return redirect('/profile/membership/failure')
|
||||
|
||||
update_membership_status().execute({'user_id': current_user.get_id(), 'status': '1'})
|
||||
update_membership().execute({'user_id': current_user.get_id(), 'status': '1', 'join_date': '', 'amount': '', 'subscription_id': ''})
|
||||
#update_membership().execute({'user_id': str(current_user.get_id()), 'status': '1', 'join_date': details.get('start_date'), 'amount': details.get('amount'), 'subscription_reference': details.get('reference')})
|
||||
|
||||
#update_membership_status().execute({'user_id': user_id, 'status': '1'})
|
||||
create_membership().execute({
|
||||
'user_id': current_user.get_id(),
|
||||
'status': '1',
|
||||
'join_date': payment_details.get('start_date'),
|
||||
'amount': payment_details.get('amount'),
|
||||
'subscription_reference': payment_details.get('reference')})
|
||||
|
||||
|
||||
|
||||
web.page.section(web.paragraph.render())
|
||||
web.template.body.append(web.page.render())
|
||||
return footer()
|
||||
|
||||
|
||||
@profile_pages.route("/profiles/generate", methods=['GET'])
|
||||
@login_required
|
||||
def update_profiles():
|
||||
"""this is used to sync up older accounts"""
|
||||
for user in get_users():
|
||||
print user
|
||||
|
||||
for payment in get_users():
|
||||
print user
|
||||
|
||||
return web.form.render()
|
||||
|
||||
|
||||
|
||||
|
||||
@profile_pages.route("/profile/details", methods=['GET'])
|
||||
@login_required
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
table_name, column_name, column_type, default
|
||||
#badges
|
||||
ALTER TABLE badges ADD INDEX name_UNIQUE (name ASC);
|
||||
|
||||
|
||||
#members
|
||||
ALTER TABLE members ADD INDEX user_id_UNIQUE (user_id ASC);
|
||||
ALTER TABLE members ADD UNIQUE INDEX user_id_UNIQUE (user_id ASC);
|
||||
|
||||
|
||||
#pledges
|
||||
|
@ -9,27 +13,37 @@ ALTER TABLE pledges ADD INDEX id_UNIQUE (id ASC);
|
|||
|
||||
#pledge_amounts
|
||||
ALTER TABLE pledge_amounts ADD INDEX id_UNIQUE (id ASC);
|
||||
ALTER TABLE pledge_amounts ADD UNIQUE INDEX reference_UNIQUE (reference ASC);
|
||||
ALTER TABLE pledge_amounts ADD INDEX reference_UNIQUE (reference ASC);
|
||||
|
||||
|
||||
#requests
|
||||
ALTER TABLE requests ADD INDEX id_UNIQUE (id ASC);
|
||||
ALTER TABLE requests ADD UNIQUE INDEX id_UNIQUE (id ASC);
|
||||
|
||||
|
||||
#users
|
||||
ALTER TABLE users ADD INDEX id_UNIQUE (id ASC);
|
||||
ALTER TABLE users ADD UNIQUE INDEX email_UNIQUE (email ASC);
|
||||
ALTER TABLE users ADD INDEX member_reference_UNIQUE (member_reference ASC);
|
||||
ALTER TABLE users ADD INDEX email_UNIQUE (email ASC);
|
||||
|
||||
|
||||
#user_badges
|
||||
|
||||
|
||||
#user_detail
|
||||
ALTER TABLE user_detail ADD INDEX id_UNIQUE (id ASC);
|
||||
ALTER TABLE user_detail ADD UNIQUE INDEX user_id_UNIQUE (user_id ASC);
|
||||
ALTER TABLE user_detail ADD UNIQUE INDEX member_id_UNIQUE (member_id ASC);
|
||||
ALTER TABLE user_detail ADD INDEX user_id_UNIQUE (user_id ASC);
|
||||
ALTER TABLE user_detail ADD INDEX member_id_UNIQUE (member_id ASC);
|
||||
|
||||
|
||||
#user_membership
|
||||
ALTER TABLE user_membership ADD INDEX id_UNIQUE (id ASC);
|
||||
ALTER TABLE user_membership ADD INDEX subscription_id_UNIQUE (subscription_id ASC);
|
||||
ALTER TABLE user_membership ADD INDEX user_id_UNIQUE (user_id ASC);
|
||||
|
||||
|
||||
#user_password_reset
|
||||
ALTER TABLE user_password_reset ADD INDEX id_UNIQUE (id ASC);
|
||||
ALTER TABLE user_password_reset ADD UNIQUE INDEX password_UNIQUE (reset_code ASC);
|
||||
ALTER TABLE user_password_reset ADD UNIQUE INDEX user_id_UNIQUE (user_id ASC);
|
||||
ALTER TABLE user_password_reset ADD INDEX user_id_UNIQUE (user_id ASC);
|
||||
ALTER TABLE user_password_reset ADD INDEX password_UNIQUE (reset_code ASC);
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
table_name, column_name, column_type, default
|
||||
#badges
|
||||
ALTER TABLE badges ADD COLUMN id int(10) unsigned PRIMARY KEY (`id`) AUTO_INCREMENT ;
|
||||
ALTER TABLE badges CHANGE COLUMN id id int(10) unsigned PRIMARY KEY (`id`) AUTO_INCREMENT ;
|
||||
ALTER TABLE badges ADD COLUMN name varchar(25) ;
|
||||
ALTER TABLE badges CHANGE COLUMN name name varchar(25) ;
|
||||
|
||||
|
||||
#members
|
||||
ALTER TABLE members ADD COLUMN id int(4) unsigned zerofill PRIMARY KEY (`id`) AUTO_INCREMENT ;
|
||||
ALTER TABLE members CHANGE COLUMN id id int(4) unsigned zerofill PRIMARY KEY (`id`) AUTO_INCREMENT ;
|
||||
ALTER TABLE members ADD COLUMN id int(5) unsigned zerofill PRIMARY KEY (`id`) ;
|
||||
ALTER TABLE members CHANGE COLUMN id id int(5) unsigned zerofill PRIMARY KEY (`id`) ;
|
||||
ALTER TABLE members ADD COLUMN user_id varchar(45) NULL ;
|
||||
ALTER TABLE members CHANGE COLUMN user_id user_id varchar(45) NULL ;
|
||||
|
||||
|
@ -30,6 +37,10 @@ ALTER TABLE pledge_amounts ADD COLUMN pledge_id int(10) NULL ;
|
|||
ALTER TABLE pledge_amounts CHANGE COLUMN pledge_id pledge_id int(10) NULL ;
|
||||
ALTER TABLE pledge_amounts ADD COLUMN reference varchar(255) NULL ;
|
||||
ALTER TABLE pledge_amounts CHANGE COLUMN reference reference varchar(255) NULL ;
|
||||
ALTER TABLE pledge_amounts ADD COLUMN type int(11) DEFAULT 1;
|
||||
ALTER TABLE pledge_amounts CHANGE COLUMN type type int(11) DEFAULT 1;
|
||||
ALTER TABLE pledge_amounts ADD COLUMN user_id int(11) NULL ;
|
||||
ALTER TABLE pledge_amounts CHANGE COLUMN user_id user_id int(11) NULL ;
|
||||
|
||||
|
||||
#requests
|
||||
|
@ -52,18 +63,20 @@ ALTER TABLE requests CHANGE COLUMN user_id user_id int(10) unsigned NULL ;
|
|||
#users
|
||||
ALTER TABLE users ADD COLUMN created timestamp NULL ;
|
||||
ALTER TABLE users CHANGE COLUMN created created timestamp NULL ;
|
||||
ALTER TABLE users ADD COLUMN email varchar(255) NULL ;
|
||||
ALTER TABLE users CHANGE COLUMN email email varchar(255) NULL ;
|
||||
ALTER TABLE users ADD COLUMN email varchar(255) ;
|
||||
ALTER TABLE users CHANGE COLUMN email email varchar(255) ;
|
||||
ALTER TABLE users ADD COLUMN first_name varchar(45) NULL ;
|
||||
ALTER TABLE users CHANGE COLUMN first_name first_name varchar(45) NULL ;
|
||||
ALTER TABLE users ADD COLUMN id int(10) unsigned PRIMARY KEY (`id`) AUTO_INCREMENT ;
|
||||
ALTER TABLE users CHANGE COLUMN id id int(10) unsigned PRIMARY KEY (`id`) AUTO_INCREMENT ;
|
||||
ALTER TABLE users ADD COLUMN id int(10) unsigned PRIMARY KEY (`id`) ;
|
||||
ALTER TABLE users CHANGE COLUMN id id int(10) unsigned PRIMARY KEY (`id`) ;
|
||||
ALTER TABLE users ADD COLUMN last_login varchar(45) NULL ;
|
||||
ALTER TABLE users CHANGE COLUMN last_login last_login varchar(45) NULL ;
|
||||
ALTER TABLE users ADD COLUMN last_name varchar(45) NULL ;
|
||||
ALTER TABLE users CHANGE COLUMN last_name last_name varchar(45) NULL ;
|
||||
ALTER TABLE users ADD COLUMN memberid varchar(45) NULL ;
|
||||
ALTER TABLE users CHANGE COLUMN memberid memberid varchar(45) NULL ;
|
||||
ALTER TABLE users ADD COLUMN member_reference int(5) unsigned zerofill AUTO_INCREMENT ;
|
||||
ALTER TABLE users CHANGE COLUMN member_reference member_reference int(5) unsigned zerofill AUTO_INCREMENT ;
|
||||
ALTER TABLE users ADD COLUMN password varchar(160) NULL ;
|
||||
ALTER TABLE users CHANGE COLUMN password password varchar(160) NULL ;
|
||||
ALTER TABLE users ADD COLUMN profile_image varchar(255) NULL ;
|
||||
|
@ -76,6 +89,15 @@ ALTER TABLE users ADD COLUMN username varchar(25) NULL ;
|
|||
ALTER TABLE users CHANGE COLUMN username username varchar(25) NULL ;
|
||||
|
||||
|
||||
#user_badges
|
||||
ALTER TABLE user_badges ADD COLUMN badge_id int(10) unsigned ;
|
||||
ALTER TABLE user_badges CHANGE COLUMN badge_id badge_id int(10) unsigned ;
|
||||
ALTER TABLE user_badges ADD COLUMN id int(10) unsigned PRIMARY KEY (`id`) AUTO_INCREMENT ;
|
||||
ALTER TABLE user_badges CHANGE COLUMN id id int(10) unsigned PRIMARY KEY (`id`) AUTO_INCREMENT ;
|
||||
ALTER TABLE user_badges ADD COLUMN user_id int(10) unsigned ;
|
||||
ALTER TABLE user_badges CHANGE COLUMN user_id user_id int(10) unsigned ;
|
||||
|
||||
|
||||
#user_detail
|
||||
ALTER TABLE user_detail ADD COLUMN description text NULL ;
|
||||
ALTER TABLE user_detail CHANGE COLUMN description description text NULL ;
|
||||
|
@ -93,6 +115,21 @@ ALTER TABLE user_detail ADD COLUMN user_id int(11) unsigned NULL ;
|
|||
ALTER TABLE user_detail CHANGE COLUMN user_id user_id int(11) unsigned NULL ;
|
||||
|
||||
|
||||
#user_membership
|
||||
ALTER TABLE user_membership ADD COLUMN amount decimal(10,2) DEFAULT 0.00;
|
||||
ALTER TABLE user_membership CHANGE COLUMN amount amount decimal(10,2) DEFAULT 0.00;
|
||||
ALTER TABLE user_membership ADD COLUMN id int(10) unsigned PRIMARY KEY (`id`) ;
|
||||
ALTER TABLE user_membership CHANGE COLUMN id id int(10) unsigned PRIMARY KEY (`id`) ;
|
||||
ALTER TABLE user_membership ADD COLUMN join_date datetime NULL ;
|
||||
ALTER TABLE user_membership CHANGE COLUMN join_date join_date datetime NULL ;
|
||||
ALTER TABLE user_membership ADD COLUMN status tinyint(4) ;
|
||||
ALTER TABLE user_membership CHANGE COLUMN status status tinyint(4) ;
|
||||
ALTER TABLE user_membership ADD COLUMN subscription_id varchar(45) ;
|
||||
ALTER TABLE user_membership CHANGE COLUMN subscription_id subscription_id varchar(45) ;
|
||||
ALTER TABLE user_membership ADD COLUMN user_id int(10) unsigned ;
|
||||
ALTER TABLE user_membership CHANGE COLUMN user_id user_id int(10) unsigned ;
|
||||
|
||||
|
||||
#user_password_reset
|
||||
ALTER TABLE user_password_reset ADD COLUMN created timestamp NULL DEFAULT CURRENT_TIMESTAMP;
|
||||
ALTER TABLE user_password_reset CHANGE COLUMN created created timestamp NULL DEFAULT CURRENT_TIMESTAMP;
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
CREATE TABLE IF NOT EXISTS badges;
|
||||
CREATE TABLE IF NOT EXISTS members;
|
||||
CREATE TABLE IF NOT EXISTS pledges;
|
||||
CREATE TABLE IF NOT EXISTS pledge_amounts;
|
||||
CREATE TABLE IF NOT EXISTS requests;
|
||||
CREATE TABLE IF NOT EXISTS users;
|
||||
CREATE TABLE IF NOT EXISTS user_badges;
|
||||
CREATE TABLE IF NOT EXISTS user_detail;
|
||||
CREATE TABLE IF NOT EXISTS user_membership;
|
||||
CREATE TABLE IF NOT EXISTS user_password_reset;
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
.icon-content-white{background-image:url('/static/images/css/sprite-content-white.png')}.icon-content-white-ic_inbox_white_24dp{background-position:-5px -5px;width:24px;height:24px}.icon-content-white-ic_add_box_white_24dp{background-position:-39px -5px;width:24px;height:24px}.icon-content-white-ic_add_circle_white_24dp{background-position:-5px -39px;width:24px;height:24px}.icon-content-white-ic_add_white_24dp{background-position:-39px -39px;width:24px;height:24px}.icon-content-white-ic_archive_white_24dp{background-position:-73px -5px;width:24px;height:24px}.icon-content-white-ic_backspace_white_24dp{background-position:-73px -39px;width:24px;height:24px}.icon-content-white-ic_block_white_24dp{background-position:-5px -73px;width:24px;height:24px}.icon-content-white-ic_clear_white_24dp{background-position:-39px -73px;width:24px;height:24px}.icon-content-white-ic_content_copy_white_24dp{background-position:-73px -73px;width:24px;height:24px}.icon-content-white-ic_content_cut_white_24dp{background-position:-107px -5px;width:24px;height:24px}.icon-content-white-ic_content_paste_white_24dp{background-position:-107px -39px;width:24px;height:24px}.icon-content-white-ic_create_white_24dp{background-position:-107px -73px;width:24px;height:24px}.icon-content-white-ic_drafts_white_24dp{background-position:-5px -107px;width:24px;height:24px}.icon-content-white-ic_filter_list_white_24dp{background-position:-39px -107px;width:24px;height:24px}.icon-content-white-ic_flag_white_24dp{background-position:-73px -107px;width:24px;height:24px}.icon-content-white-ic_forward_white_24dp{background-position:-107px -107px;width:24px;height:24px}.icon-content-white-ic_gesture_white_24dp{background-position:-141px -5px;width:24px;height:24px}.icon-content-white-ic_add_circle_outline_white_24dp{background-position:-141px -39px;width:24px;height:24px}.icon-content-white-ic_link_white_24dp{background-position:-141px -73px;width:24px;height:24px}.icon-content-white-ic_mail_white_24dp{background-position:-141px -107px;width:24px;height:24px}.icon-content-white-ic_markunread_white_24dp{background-position:-5px -141px;width:24px;height:24px}.icon-content-white-ic_redo_white_24dp{background-position:-39px -141px;width:24px;height:24px}.icon-content-white-ic_remove_circle_outline_white_24dp{background-position:-73px -141px;width:24px;height:24px}.icon-content-white-ic_remove_circle_white_24dp{background-position:-107px -141px;width:24px;height:24px}.icon-content-white-ic_remove_white_24dp{background-position:-141px -141px;width:24px;height:24px}.icon-content-white-ic_reply_all_white_24dp{background-position:-175px -5px;width:24px;height:24px}.icon-content-white-ic_reply_white_24dp{background-position:-175px -39px;width:24px;height:24px}.icon-content-white-ic_report_white_24dp{background-position:-175px -73px;width:24px;height:24px}.icon-content-white-ic_save_white_24dp{background-position:-175px -107px;width:24px;height:24px}.icon-content-white-ic_select_all_white_24dp{background-position:-175px -141px;width:24px;height:24px}.icon-content-white-ic_send_white_24dp{background-position:-5px -175px;width:24px;height:24px}.icon-content-white-ic_sort_white_24dp{background-position:-39px -175px;width:24px;height:24px}.icon-content-white-ic_text_format_white_24dp{background-position:-73px -175px;width:24px;height:24px}.icon-content-white-ic_undo_white_24dp{background-position:-107px -175px;width:24px;height:24px}
|
|
@ -0,0 +1 @@
|
|||
.icon-navigation-white{background-image:url('/static/images/css/sprite-navigation-white.png')}.icon-navigation-white-ic_close_white_24dp{background-position:-5px -5px;width:24px;height:24px}.icon-navigation-white-ic_apps_white_24dp{background-position:-39px -5px;width:24px;height:24px}.icon-navigation-white-ic_arrow_drop_down_circle_white_24dp{background-position:-5px -39px;width:24px;height:24px}.icon-navigation-white-ic_arrow_drop_down_white_24dp{background-position:-39px -39px;width:24px;height:24px}.icon-navigation-white-ic_arrow_drop_up_white_24dp{background-position:-73px -5px;width:24px;height:24px}.icon-navigation-white-ic_arrow_forward_white_24dp{background-position:-73px -39px;width:24px;height:24px}.icon-navigation-white-ic_cancel_white_24dp{background-position:-5px -73px;width:24px;height:24px}.icon-navigation-white-ic_check_white_24dp{background-position:-39px -73px;width:24px;height:24px}.icon-navigation-white-ic_chevron_left_white_24dp{background-position:-73px -73px;width:24px;height:24px}.icon-navigation-white-ic_chevron_right_white_24dp{background-position:-107px -5px;width:24px;height:24px}.icon-navigation-white-ic_arrow_back_white_24dp{background-position:-107px -39px;width:24px;height:24px}.icon-navigation-white-ic_expand_less_white_24dp{background-position:-107px -73px;width:24px;height:24px}.icon-navigation-white-ic_expand_more_white_24dp{background-position:-5px -107px;width:24px;height:24px}.icon-navigation-white-ic_fullscreen_exit_white_24dp{background-position:-39px -107px;width:24px;height:24px}.icon-navigation-white-ic_fullscreen_white_24dp{background-position:-73px -107px;width:24px;height:24px}.icon-navigation-white-ic_menu_white_24dp{background-position:-107px -107px;width:24px;height:24px}.icon-navigation-white-ic_more_horiz_white_24dp{background-position:-141px -5px;width:24px;height:24px}.icon-navigation-white-ic_more_vert_white_24dp{background-position:-141px -39px;width:24px;height:24px}.icon-navigation-white-ic_refresh_white_24dp{background-position:-141px -73px;width:24px;height:24px}.icon-navigation-white-ic_unfold_less_white_24dp{background-position:-141px -107px;width:24px;height:24px}.icon-navigation-white-ic_unfold_more_white_24dp{background-position:-5px -141px;width:24px;height:24px}
|
After Width: | Height: | Size: 6.9 KiB |
After Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 945 B |
After Width: | Height: | Size: 1003 B |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 983 B |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 256 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 76 KiB |
After Width: | Height: | Size: 65 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 97 KiB |
After Width: | Height: | Size: 215 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 13 KiB |
|
@ -0,0 +1 @@
|
|||
document.onkeypress=function(a){a=a||window.event;kcode=a.keyCode||a.which;if(kcode==32&&K==0){L=8;b.innerHTML=parseInt(b.innerHTML)+1;}console.log(kcode);};var a=document.getElementById("scene");var b=document.getElementById("score");var c=a.getContext("2d");var d=a.width;var e=a.height;var f=d/2;var g=e/2;var h=c.createLinearGradient(0,g,0,e);c.lineWidth=10;c.strokeStyle='#ff0000';var i=10;var j=d;var k=6.0;var l=30.0;var m=parseFloat(d);var n=m/k;var o=1;window.addEventListener('resize',p,false);function p(){a.width=window.innerWidth;d=a.width;e=a.height;y=e/2;f=d/2;g=e/2;h=c.createLinearGradient(0,g,0,e);h.addColorStop(0,"#0087A8");h.addColorStop(1,"#0087A8");c.fillStyle=h;}p();var q=0;var r=Math.PI*2.0;var s=r*k;function t(a,b){var c=0;wavelength_max=Math.ceil(a/b);while(true){if(c>wavelength_max)c=0;c+=b;}}function u(a,b,c){wavelength_max=Math.ceil(b/c)*c;a+=c;if(a>wavelength_max)a=c;return a;}function v(a,b,c,d,e,f){cr=Math.cos((s*((b+a)/f)));new_y=c+d*cr;return [b,new_y,cr];}function w(a,b){a1=b[0]-a[0];a2=b[1]-a[1];length=Math.sqrt((a1*a1)+(a2*a2));return [a1/length,a2/length];}function x(a,b,c){}function y(a,b,c){a=w(a,b);b=w(a,c);dot=a[0]*b[0]+a[1]*b[1];return Math.acos(dot);}function z(a,b){if(a[1]>b[1])F=-y([a[0]-10,a[1]],b,a);else F=y([a[0]-10,a[1]],b,a);return F;}function A(a,b){c.save();c.translate(a[0],a[1]-16);c.rotate(b);c.drawImage(H,-16,-16,32,32);c.restore();}function B(){c.beginPath();c.moveTo(0,e);for(p=0;p<D.length;p=p+1)c.lineTo(parseInt(D[p][0]),parseInt(D[p][1]));c.lineTo(d,e);c.lineWidth=10;c.stroke();c.fill();}function C(){c.beginPath();for(p=0;p<D.length;p=p+1)c.arc(parseInt(D[p][0]),parseInt(D[p][1]),2,0,2*Math.PI);c.stroke();}var D=new Array();var E=null;for(x_pos=0;x_pos<d+1;x_pos=x_pos+10){for(p=0;p<D.length;p=p+1)D[p][0]=D[p][0]-i;E=v(time=q,x=d,y=g,l=l,k=k,j=j);D.push([E[0],E[1]]);q=u(q,n,o);}var F=null;var G=Math.ceil(D.length/2);var H=new Image();H.src='/static/images/icon.png';var I=0;var J=0.75;var K=0;var L=0;function M(){c.clearRect(0,0,d,e);for(p=0;p<D.length;p=p+1)D[p][0]=D[p][0]-i;D.shift();D.push(v(time=q,x=d,y=g,l=l,k=k,j=j));if(K>0||L>0){K+=L;L-=J;}else{L=0;K=0;}I=I+0.1;A([D[G][0],D[G][1]-K],I);B();q=u(q,n,o);requestAnimationFrame(M);}M();
|
|
@ -0,0 +1 @@
|
|||
$(document).ready(function(){$('.ajaxPopup, .ajax-form').on('click',function(a){a.preventDefault();$.ajax({url:$(this).attr('href'),context:document.body}).done(function(a){$(this).addClass("done");$('#ajaxPopup > div.content').html(a);$('#ajaxPopup').show();});});$('.closePopup').on('click',function(a){a.preventDefault();$('#ajaxPopup').hide();});});
|
|
@ -9,6 +9,7 @@ label {color:#fff;text-align:left;}
|
|||
input {line-height:40px;float:right;margin:0px;color:#000;padding-left:10px;}
|
||||
select {float:right;margin:0px;color:#000;padding:10px;}
|
||||
p {margin:25px;line-height:150%;}
|
||||
h1 {margin-left:25px;color:#fff;}
|
||||
h2 {margin-left:25px;color:#fff;}
|
||||
h3 {color:#fff;}
|
||||
li {padding-bottom:10px;line-height:150%;}
|
||||
|
@ -245,10 +246,12 @@ height:48px;width:48px; -webkit-animation:spin 2s linear infinite ;-moz-animatio
|
|||
}
|
||||
|
||||
#membercard .date {position:absolute;margin:25px;top:0px;left:0px;}
|
||||
#membercard p {margin:0px;}
|
||||
#membercard .container {position:relative;top:50%; width:100%;}
|
||||
#membercard .middle {color:#000;position:absolute;top:-38px;width:100%;text-align:center;font-size:28px;}
|
||||
#membercard label {text-align:left;line-height:48px;color:#000;}
|
||||
#membercard input {width:140px;}
|
||||
#membercard select {width:155px;}
|
||||
#membercard .button {margin:0px;}
|
||||
#membercard button {margin-top:30px;}
|
||||
#membercard legend {margin-top:10px;margin-bottom:10px;font-weight:strong;}
|
||||
|
|
|
@ -34,7 +34,12 @@ class control(base_widget):
|
|||
item)
|
||||
htm += '</select></label></p>'
|
||||
continue
|
||||
htm+='<p><label for="%s">%s<input type="%s" name="%s" placeholder="%s" value="%s"></label></p>' % (name, label, input_type ,name, placeholder, value)
|
||||
checked = ''
|
||||
if input_type == 'radio':
|
||||
if placeholder == value:
|
||||
checked = ' checked="checked"'
|
||||
|
||||
htm+='<p><label for="%s">%s<input type="%s" name="%s" placeholder="%s" value="%s"%s></label></p>' % (name, label, input_type ,name, placeholder, value, checked)
|
||||
htm+='<p class="bottom full_width"><button type="submit">%s</button></p>' % self.button
|
||||
htm+='</fieldset></form>'
|
||||
return htm
|
||||
|
|
|
@ -16,10 +16,12 @@ class control(base_widget):
|
|||
htm += '<p>Please login with one of the oauth provider below, which is more secure and does not store passwords on our system.</p>'
|
||||
if self.oauth_enabled:
|
||||
htm += '<div class="providers">'
|
||||
|
||||
htm += '<a title="Login with Google" href="/oauth/google"><img src="/static/images/oauth/google.png" /></a><br />'
|
||||
#htm += '<a title="Login with facebook" href="/oauth/github">Facebook</a>.<br />'
|
||||
#htm += '<a title="Login with twitter" href="/oauth/teitter">Twitter</a>.<br />'
|
||||
if 'google' in self.oauth_enabled:
|
||||
htm += '<a title="Login with Google" href="/oauth/google/login"><img src="/static/images/oauth/google.png" /></a><br />'
|
||||
if 'facebook' in self.oauth_enabled:
|
||||
htm += '<a title="Login with facebook" href="/oauth/facebook">Facebook</a>.<br />'
|
||||
if 'github' in self.oauth_enabled:
|
||||
htm += '<a title="Login with twitter" href="/oauth/github/login">GitHub</a><br />'
|
||||
htm += '</div>'
|
||||
|
||||
htm += '<p>Or alternatively login with your previously created account.</p>'
|
||||
|
|
|
@ -17,6 +17,7 @@ class control(base_widget_extended):
|
|||
<div class="container">
|
||||
<div class="middle">
|
||||
<p>MHS%s</p><p>%s</p>
|
||||
<a href="/profile/membership/cancel">Cancel Membership</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>''' % (self.reference, self.name)
|
||||
|
@ -26,6 +27,7 @@ class control(base_widget_extended):
|
|||
<form action="/profile/membership" method="post">
|
||||
<fieldset>
|
||||
<legend>Join Maidstone Hackspace</legend>
|
||||
<p><label for="amount">Payment provider<select name="provider"><option value="gocardless">GoCardless</option><option value="paypal">PayPal</option></select></label></p>
|
||||
<p><label for="amount">Subscription Amount<input name="amount" placeholder="20.00" value="20.00" type="text"></label></p>
|
||||
<p class="button"><button type="submit">submit</button></p>
|
||||
</fieldset>
|
||||
|
|