Skip to content

Commit

Permalink
Allow members to modify their payment amounts.
Browse files Browse the repository at this point in the history
* Display choice of concessionary rate / member of other hackspace fields
* Calculate rates live and allow overrides
* Members can also edit rates on profiles
* Voluntary rate may not be more than calculated rate
* Ensure dev doesnt CC emails to info@ (setting in accesssystem_api_local.conf)
* Add missing help strings and bootstrap theme adaption
  • Loading branch information
castaway committed Apr 6, 2018
1 parent 7e95b51 commit 1716fa2
Show file tree
Hide file tree
Showing 21 changed files with 1,114 additions and 46 deletions.
23 changes: 23 additions & 0 deletions AccessSystem-Schema-2.0-3.0-MySQL.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- Convert schema './AccessSystem-Schema-2.0-MySQL.sql' to 'AccessSystem::Schema v3.0':;

BEGIN;

ALTER TABLE allowed CHANGE COLUMN is_admin is_admin enum('0','1') NOT NULL;

ALTER TABLE communications CHANGE COLUMN content content text NOT NULL;

ALTER TABLE login_tokens DROP FOREIGN KEY login_tokens_fk_person_id;

ALTER TABLE login_tokens ADD CONSTRAINT login_tokens_fk_person_id FOREIGN KEY (person_id) REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE;

ALTER TABLE message_log CHANGE COLUMN message message text NOT NULL;

ALTER TABLE people ADD COLUMN payment_override float NULL,
CHANGE COLUMN opt_in opt_in enum('0','1') NOT NULL DEFAULT '0',
CHANGE COLUMN address address text NOT NULL,
CHANGE COLUMN member_of_other_hackspace member_of_other_hackspace enum('0','1') NOT NULL DEFAULT '0';


COMMIT;


15 changes: 15 additions & 0 deletions AccessSystem-Schema-2.0-3.0-PostgreSQL.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Convert schema './AccessSystem-Schema-2.0-PostgreSQL.sql' to './AccessSystem-Schema-3.0-PostgreSQL.sql':;

BEGIN;

ALTER TABLE login_tokens DROP CONSTRAINT login_tokens_fk_person_id;

ALTER TABLE login_tokens ADD CONSTRAINT login_tokens_fk_person_id FOREIGN KEY (person_id)
REFERENCES people (id) ON DELETE cascade ON UPDATE cascade DEFERRABLE;

ALTER TABLE people ADD COLUMN payment_override float(20);


COMMIT;


13 changes: 13 additions & 0 deletions AccessSystem-Schema-2.0-3.0-SQLite.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-- Convert schema './AccessSystem-Schema-2.0-SQLite.sql' to './AccessSystem-Schema-3.0-SQLite.sql':;

BEGIN;

DROP INDEX ;


ALTER TABLE "people" ADD COLUMN "payment_override" float;


COMMIT;


153 changes: 153 additions & 0 deletions AccessSystem-Schema-3.0-MySQL.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
--
-- Created by SQL::Translator::Producer::MySQL
-- Created on Wed Apr 4 11:21:20 2018
--
SET foreign_key_checks=0;

DROP TABLE IF EXISTS accessible_things;

--
-- Table: accessible_things
--
CREATE TABLE accessible_things (
id varchar(40) NOT NULL,
name varchar(255) NOT NULL,
assigned_ip varchar(15) NOT NULL,
PRIMARY KEY (id),
UNIQUE name (name)
) ENGINE=InnoDB;

DROP TABLE IF EXISTS people;

--
-- Table: people
--
CREATE TABLE people (
id integer NOT NULL auto_increment,
parent_id integer NULL,
name varchar(255) NOT NULL,
email varchar(255) NULL,
opt_in enum('0','1') NOT NULL DEFAULT '0',
dob datetime NOT NULL,
address text NOT NULL,
github_user varchar(255) NULL,
concessionary_rate_override varchar(255) NULL DEFAULT '',
payment_override float NULL,
member_of_other_hackspace enum('0','1') NOT NULL DEFAULT '0',
created_date datetime NOT NULL,
end_date datetime NULL,
INDEX people_idx_parent_id (parent_id),
PRIMARY KEY (id),
CONSTRAINT people_fk_parent_id FOREIGN KEY (parent_id) REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;

DROP TABLE IF EXISTS access_tokens;

--
-- Table: access_tokens
--
CREATE TABLE access_tokens (
id varchar(255) NOT NULL,
person_id integer NOT NULL,
type varchar(20) NOT NULL,
INDEX access_tokens_idx_person_id (person_id),
PRIMARY KEY (person_id, id),
CONSTRAINT access_tokens_fk_person_id FOREIGN KEY (person_id) REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;

DROP TABLE IF EXISTS communications;

--
-- Table: communications
--
CREATE TABLE communications (
person_id integer NOT NULL auto_increment,
sent_on datetime NOT NULL,
type varchar(50) NOT NULL,
content text NOT NULL,
INDEX communications_idx_person_id (person_id),
PRIMARY KEY (person_id, sent_on),
CONSTRAINT communications_fk_person_id FOREIGN KEY (person_id) REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;

DROP TABLE IF EXISTS dues;

--
-- Table: dues
--
CREATE TABLE dues (
person_id integer NOT NULL,
paid_on_date datetime NOT NULL,
expires_on_date datetime NOT NULL,
amount_p integer NOT NULL,
added_on datetime NOT NULL,
INDEX dues_idx_person_id (person_id),
PRIMARY KEY (person_id, paid_on_date),
CONSTRAINT dues_fk_person_id FOREIGN KEY (person_id) REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;

DROP TABLE IF EXISTS login_tokens;

--
-- Table: login_tokens
--
CREATE TABLE login_tokens (
person_id integer NOT NULL,
login_token varchar(36) NOT NULL,
INDEX login_tokens_idx_person_id (person_id),
PRIMARY KEY (person_id, login_token),
CONSTRAINT login_tokens_fk_person_id FOREIGN KEY (person_id) REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;

DROP TABLE IF EXISTS message_log;

--
-- Table: message_log
--
CREATE TABLE message_log (
accessible_thing_id varchar(40) NOT NULL,
message text NOT NULL,
from_ip varchar(15) NOT NULL,
written_date datetime NOT NULL,
INDEX message_log_idx_accessible_thing_id (accessible_thing_id),
PRIMARY KEY (accessible_thing_id, written_date),
CONSTRAINT message_log_fk_accessible_thing_id FOREIGN KEY (accessible_thing_id) REFERENCES accessible_things (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;

DROP TABLE IF EXISTS allowed;

--
-- Table: allowed
--
CREATE TABLE allowed (
person_id integer NOT NULL,
accessible_thing_id varchar(40) NOT NULL,
is_admin enum('0','1') NOT NULL,
INDEX allowed_idx_accessible_thing_id (accessible_thing_id),
INDEX allowed_idx_person_id (person_id),
PRIMARY KEY (person_id, accessible_thing_id),
CONSTRAINT allowed_fk_accessible_thing_id FOREIGN KEY (accessible_thing_id) REFERENCES accessible_things (id) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT allowed_fk_person_id FOREIGN KEY (person_id) REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;

DROP TABLE IF EXISTS usage_log;

--
-- Table: usage_log
--
CREATE TABLE usage_log (
person_id integer NULL,
accessible_thing_id varchar(40) NOT NULL,
token_id varchar(255) NOT NULL,
status varchar(20) NOT NULL,
accessed_date datetime NOT NULL,
INDEX usage_log_idx_accessible_thing_id (accessible_thing_id),
INDEX usage_log_idx_person_id (person_id),
PRIMARY KEY (accessible_thing_id, accessed_date),
CONSTRAINT usage_log_fk_accessible_thing_id FOREIGN KEY (accessible_thing_id) REFERENCES accessible_things (id),
CONSTRAINT usage_log_fk_person_id FOREIGN KEY (person_id) REFERENCES people (id)
) ENGINE=InnoDB;

SET foreign_key_checks=1;


164 changes: 164 additions & 0 deletions AccessSystem-Schema-3.0-PostgreSQL.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
--
-- Created by SQL::Translator::Producer::PostgreSQL
-- Created on Wed Apr 4 11:21:22 2018
--
--
-- Table: accessible_things
--
DROP TABLE accessible_things CASCADE;
CREATE TABLE accessible_things (
id character varying(40) NOT NULL,
name character varying(255) NOT NULL,
assigned_ip character varying(15) NOT NULL,
PRIMARY KEY (id),
CONSTRAINT name UNIQUE (name)
);

--
-- Table: people
--
DROP TABLE people CASCADE;
CREATE TABLE people (
id serial NOT NULL,
parent_id integer,
name character varying(255) NOT NULL,
email character varying(255),
opt_in boolean DEFAULT '0' NOT NULL,
dob timestamp NOT NULL,
address character varying(1024) NOT NULL,
github_user character varying(255),
concessionary_rate_override character varying(255) DEFAULT '',
payment_override float,
member_of_other_hackspace boolean DEFAULT '0' NOT NULL,
created_date timestamp NOT NULL,
end_date timestamp,
PRIMARY KEY (id)
);
CREATE INDEX people_idx_parent_id on people (parent_id);

--
-- Table: access_tokens
--
DROP TABLE access_tokens CASCADE;
CREATE TABLE access_tokens (
id character varying(255) NOT NULL,
person_id integer NOT NULL,
type character varying(20) NOT NULL,
PRIMARY KEY (person_id, id)
);
CREATE INDEX access_tokens_idx_person_id on access_tokens (person_id);

--
-- Table: communications
--
DROP TABLE communications CASCADE;
CREATE TABLE communications (
person_id serial NOT NULL,
sent_on timestamp NOT NULL,
type character varying(50) NOT NULL,
content character varying(10240) NOT NULL,
PRIMARY KEY (person_id, sent_on)
);
CREATE INDEX communications_idx_person_id on communications (person_id);

--
-- Table: dues
--
DROP TABLE dues CASCADE;
CREATE TABLE dues (
person_id integer NOT NULL,
paid_on_date timestamp NOT NULL,
expires_on_date timestamp NOT NULL,
amount_p integer NOT NULL,
added_on timestamp NOT NULL,
PRIMARY KEY (person_id, paid_on_date)
);
CREATE INDEX dues_idx_person_id on dues (person_id);

--
-- Table: login_tokens
--
DROP TABLE login_tokens CASCADE;
CREATE TABLE login_tokens (
person_id integer NOT NULL,
login_token character varying(36) NOT NULL,
PRIMARY KEY (person_id, login_token)
);
CREATE INDEX login_tokens_idx_person_id on login_tokens (person_id);

--
-- Table: message_log
--
DROP TABLE message_log CASCADE;
CREATE TABLE message_log (
accessible_thing_id character varying(40) NOT NULL,
message character varying(2048) NOT NULL,
from_ip character varying(15) NOT NULL,
written_date timestamp NOT NULL,
PRIMARY KEY (accessible_thing_id, written_date)
);
CREATE INDEX message_log_idx_accessible_thing_id on message_log (accessible_thing_id);

--
-- Table: allowed
--
DROP TABLE allowed CASCADE;
CREATE TABLE allowed (
person_id integer NOT NULL,
accessible_thing_id character varying(40) NOT NULL,
is_admin boolean NOT NULL,
PRIMARY KEY (person_id, accessible_thing_id)
);
CREATE INDEX allowed_idx_accessible_thing_id on allowed (accessible_thing_id);
CREATE INDEX allowed_idx_person_id on allowed (person_id);

--
-- Table: usage_log
--
DROP TABLE usage_log CASCADE;
CREATE TABLE usage_log (
person_id integer,
accessible_thing_id character varying(40) NOT NULL,
token_id character varying(255) NOT NULL,
status character varying(20) NOT NULL,
accessed_date timestamp NOT NULL,
PRIMARY KEY (accessible_thing_id, accessed_date)
);
CREATE INDEX usage_log_idx_accessible_thing_id on usage_log (accessible_thing_id);
CREATE INDEX usage_log_idx_person_id on usage_log (person_id);

--
-- Foreign Key Definitions
--

ALTER TABLE people ADD CONSTRAINT people_fk_parent_id FOREIGN KEY (parent_id)
REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;

ALTER TABLE access_tokens ADD CONSTRAINT access_tokens_fk_person_id FOREIGN KEY (person_id)
REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;

ALTER TABLE communications ADD CONSTRAINT communications_fk_person_id FOREIGN KEY (person_id)
REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;

ALTER TABLE dues ADD CONSTRAINT dues_fk_person_id FOREIGN KEY (person_id)
REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;

ALTER TABLE login_tokens ADD CONSTRAINT login_tokens_fk_person_id FOREIGN KEY (person_id)
REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;

ALTER TABLE message_log ADD CONSTRAINT message_log_fk_accessible_thing_id FOREIGN KEY (accessible_thing_id)
REFERENCES accessible_things (id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;

ALTER TABLE allowed ADD CONSTRAINT allowed_fk_accessible_thing_id FOREIGN KEY (accessible_thing_id)
REFERENCES accessible_things (id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;

ALTER TABLE allowed ADD CONSTRAINT allowed_fk_person_id FOREIGN KEY (person_id)
REFERENCES people (id) ON DELETE CASCADE ON UPDATE CASCADE DEFERRABLE;

ALTER TABLE usage_log ADD CONSTRAINT usage_log_fk_accessible_thing_id FOREIGN KEY (accessible_thing_id)
REFERENCES accessible_things (id) DEFERRABLE;

ALTER TABLE usage_log ADD CONSTRAINT usage_log_fk_person_id FOREIGN KEY (person_id)
REFERENCES people (id) DEFERRABLE;


Loading

0 comments on commit 1716fa2

Please sign in to comment.