#5: Started work on roles switching
This commit is contained in:
parent
68bb22bd31
commit
e425c56ec2
14 changed files with 661 additions and 19 deletions
218
doc/specification/database.md
Normal file
218
doc/specification/database.md
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
# Database Specification
|
||||
|
||||
Note that this is a work in progress. Read it in concert with the Entity-Relationship Diagram.
|
||||
|
||||
Tables are listed in alphabetical order.
|
||||
|
||||
## Address
|
||||
|
||||
The postal address of a dwelling at which electors are registered.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS addresses (
|
||||
id integer NOT NULL,
|
||||
address character varying(256) NOT NULL,
|
||||
postcode character varying(16),
|
||||
phone character varying(16),
|
||||
district_id integer,
|
||||
latitude real,
|
||||
longitude real
|
||||
);
|
||||
|
||||
## Authority
|
||||
|
||||
An *oauth* authority which authenticates canvassers. *Note that* there will need to be substantially more in this table but I don't yet know what.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS authorities (
|
||||
id character varying(32) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
## Canvasser
|
||||
|
||||
A user of the system.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS canvassers (
|
||||
id serial,
|
||||
username character varying(32) NOT NULL,
|
||||
fullname character varying(64) NOT NULL,
|
||||
elector_id integer,
|
||||
address_id integer NOT NULL,
|
||||
phone character varying(16),
|
||||
email character varying(128),
|
||||
authority_id character varying(32) NOT NULL,
|
||||
authorised boolean
|
||||
);
|
||||
|
||||
|
||||
## District
|
||||
|
||||
An electoral district.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS districts (
|
||||
id integer NOT NULL,
|
||||
name character varying(64) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
## Elector
|
||||
|
||||
Someone entitled to cast a vote in the referendum.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS electors (
|
||||
id integer NOT NULL,
|
||||
name character varying(64) NOT NULL,
|
||||
address_id integer NOT NULL,
|
||||
phone character varying(16),
|
||||
email character varying(128)
|
||||
);
|
||||
|
||||
## Followup Action
|
||||
|
||||
An action performed by an issue expert in response to a followup request.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS followupactions (
|
||||
id integer NOT NULL,
|
||||
request_id integer NOT NULL,
|
||||
actor integer NOT NULL,
|
||||
date timestamp with time zone DEFAULT now() NOT NULL,
|
||||
notes text,
|
||||
closed boolean
|
||||
);
|
||||
|
||||
## Followup Method
|
||||
|
||||
A method for responding to a followup request; reference data.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS followupmethods (
|
||||
id character varying(32) NOT NULL
|
||||
);
|
||||
|
||||
insert into followupmethods values ('Telephone');
|
||||
insert into followupmethods values ('eMail');
|
||||
insert into followupmethods values ('Post');
|
||||
|
||||
## Followup Request
|
||||
|
||||
A request recorded by a canvasser for an issue expert to contact an elector with regard to a particular issue.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS followuprequests (
|
||||
id integer NOT NULL,
|
||||
elector_id integer NOT NULL,
|
||||
visit_id integer NOT NULL,
|
||||
issue_id character varying(32) NOT NULL,
|
||||
method_id character varying(32) NOT NULL
|
||||
);
|
||||
|
||||
## Intention
|
||||
|
||||
An intention, by an elector, to vote for an option; captured by a canvasser during a visit.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS intentions (
|
||||
id serial not null,
|
||||
elector integer not null references elector(id),
|
||||
option varchar(32) not null references option(id),
|
||||
visit integer not null references visit(id),
|
||||
date timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
|
||||
|
||||
## Issue
|
||||
|
||||
An issue which might affect electors' decisions regarding their intention.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS issues (
|
||||
id character varying(32) NOT NULL,
|
||||
url character varying(256),
|
||||
content varchar(1024),
|
||||
current default false
|
||||
);
|
||||
|
||||
|
||||
## Issue expertise
|
||||
|
||||
Expertise of a canvasser able to use a method, in an issue.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS issueexpertise (
|
||||
canvasser_id integer NOT NULL,
|
||||
issue_id character varying(32) NOT NULL,
|
||||
method_id character varying(32) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
## Option
|
||||
|
||||
An option for which an elector may have an intention to vote.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS options (
|
||||
id character varying(32) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
## Role
|
||||
|
||||
A role (other than basic *Canvasser*) that a user may have in the system. Reference data.
|
||||
|
||||
create table if not exists roles (
|
||||
id serial primary key,
|
||||
name varchar(64) not null
|
||||
);
|
||||
|
||||
|
||||
## Role Member
|
||||
|
||||
Membership of a user (*Canvasser*) of an additional role; link table.
|
||||
|
||||
create table if not exists rolememberships (
|
||||
role_id integer not null references roles(id),
|
||||
canvasser_id integer not null references canvassers(id)
|
||||
);
|
||||
|
||||
|
||||
## Team
|
||||
|
||||
A team of canvassers in a locality who are known to one another and frequently
|
||||
canvas together.
|
||||
|
||||
create table if not exists teams (
|
||||
id serial primary key,
|
||||
name varchar(64) not null,
|
||||
district_id integer not null references districts(id),
|
||||
latitude real,
|
||||
longitude real
|
||||
);
|
||||
|
||||
|
||||
## Team Member
|
||||
|
||||
Membership of a user (*Canvasser*) of a particular team. Canvassers may join multiple teams. Link table.
|
||||
|
||||
create table if not exists teammemberships (
|
||||
team_id integer not null references teams(id),
|
||||
canvasser_id integer not null references canvassers(id)
|
||||
);
|
||||
|
||||
|
||||
## Team Organiser
|
||||
|
||||
A relationship which defines a user (*Canvasser*) as an organiser of a team. A team may
|
||||
have more than one organiser. An organiser (if they also have the role 'Recruiter', which
|
||||
they often will have) may recruit additional Canvassers as members of their team, or
|
||||
accept applications by canvassers to join their team. An organiser may promote a member of
|
||||
the team to organiser of the team, and may also exclude a member from the team.
|
||||
|
||||
create table if not exists teamorganiserships (
|
||||
team_id integer not null references teams(id),
|
||||
canvasser_id integer not null references canvassers(id)
|
||||
);
|
||||
|
||||
|
||||
## Visit
|
||||
|
||||
A visit by a canvasser to an address on a date to solicit intentions from electors.
|
||||
|
||||
CREATE TABLE IF NOT EXISTS visits (
|
||||
id integer NOT NULL,
|
||||
address_id integer NOT NULL,
|
||||
canvasser_id integer NOT NULL,
|
||||
date timestamp with time zone DEFAULT now() NOT NULL
|
||||
);
|
||||
|
|
@ -25,9 +25,9 @@
|
|||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="1.979899"
|
||||
inkscape:cx="833.70674"
|
||||
inkscape:cy="324.89697"
|
||||
inkscape:zoom="2.8"
|
||||
inkscape:cx="764.16287"
|
||||
inkscape:cy="256.90499"
|
||||
inkscape:document-units="px"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="true"
|
||||
|
|
@ -58,12 +58,13 @@
|
|||
id="layer1"
|
||||
transform="translate(0,-308.26772)">
|
||||
<rect
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#060000;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.51906158"
|
||||
id="rect4428"
|
||||
style="display:none;opacity:1;fill:#ffffff;fill-opacity:1;stroke:#060000;stroke-width:1.324;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:0.51906158"
|
||||
id="matte"
|
||||
width="1030"
|
||||
height="730"
|
||||
x="232.23355"
|
||||
y="376.0018" />
|
||||
x="8.484766"
|
||||
y="312.36221"
|
||||
sodipodi:insensitive="true" />
|
||||
<text
|
||||
xml:space="preserve"
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:20px;line-height:125%;font-family:Arial;-inkscape-font-specification:'Arial Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
|
||||
|
|
@ -124,7 +125,7 @@
|
|||
y="563.88513"
|
||||
x="230.18532"
|
||||
id="tspan4156"
|
||||
sodipodi:role="line">Addresss</tspan></text>
|
||||
sodipodi:role="line">Address</tspan></text>
|
||||
<rect
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.4000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect4158"
|
||||
|
|
@ -566,7 +567,7 @@
|
|||
sodipodi:nodetypes="ccc" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 222.5,781.65662 -10,10 10,10 0,0"
|
||||
d="m 219.72208,781.65662 -10,10 10,10 0,0"
|
||||
id="path4347"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccc" />
|
||||
|
|
@ -613,14 +614,14 @@
|
|||
y="394.48404"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:15px;font-family:Arial;-inkscape-font-specification:Arial"><tspan
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:'Arial Bold'"
|
||||
id="tspan4371">Version: </tspan>0.2</tspan><tspan
|
||||
id="tspan4371">Version: </tspan>0.3</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="472.0152"
|
||||
y="413.23404"
|
||||
id="tspan4365"
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:15px;font-family:Arial;-inkscape-font-specification:Arial"><tspan
|
||||
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-family:Arial;-inkscape-font-specification:'Arial Bold'"
|
||||
id="tspan4373">Date: </tspan>20170315</tspan><tspan
|
||||
id="tspan4373">Date: </tspan>20170401</tspan><tspan
|
||||
sodipodi:role="line"
|
||||
x="472.0152"
|
||||
y="431.98404"
|
||||
|
|
@ -1159,5 +1160,49 @@
|
|||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
<rect
|
||||
style="opacity:1;fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.4000001;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
||||
id="rect4338"
|
||||
width="100"
|
||||
height="60"
|
||||
x="42.398472"
|
||||
y="896.52991" />
|
||||
<text
|
||||
sodipodi:linespacing="125%"
|
||||
id="text4341"
|
||||
y="926.52985"
|
||||
x="54.166237"
|
||||
style="font-style:italic;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:20px;line-height:125%;font-family:'URW Chancery L';-inkscape-font-specification:'URW Chancery L Bold Italic';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
xml:space="preserve"><tspan
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:15px;font-family:Arial;-inkscape-font-specification:Arial"
|
||||
y="926.52985"
|
||||
x="54.166237"
|
||||
id="tspan4343"
|
||||
sodipodi:role="line">Followup</tspan><tspan
|
||||
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:15px;font-family:Arial;-inkscape-font-specification:Arial"
|
||||
y="945.27985"
|
||||
x="54.166237"
|
||||
sodipodi:role="line"
|
||||
id="tspan4345">Method</tspan></text>
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 120,897.36221 0,-80 100,0"
|
||||
id="path4348"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 220,807.36221 -10,10 10,10"
|
||||
id="path4350"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 110,887.36221 20,0"
|
||||
id="path4352"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
inkscape:connector-curvature="0"
|
||||
id="path4354"
|
||||
d="m 900,792.1255 -10,10 10,10"
|
||||
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
|
||||
</g>
|
||||
</svg>
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 63 KiB |
Loading…
Add table
Add a link
Reference in a new issue