diff --git a/app/controllers/groups_controller.rb b/app/controllers/user_groups_controller.rb similarity index 77% rename from app/controllers/groups_controller.rb rename to app/controllers/user_groups_controller.rb index 4651be9b..83107035 100644 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/user_groups_controller.rb @@ -1,4 +1,4 @@ -class GroupsController < BasicController +class UserGroupsController < BasicController only_set_object @model_class = Group diff --git a/app/models/group.rb b/app/models/user_group.rb similarity index 68% rename from app/models/group.rb rename to app/models/user_group.rb index 4ec5c97b..e3d14127 100644 --- a/app/models/group.rb +++ b/app/models/user_group.rb @@ -1,12 +1,12 @@ -# Group representents a set of {User Users} that are interested in particular +# UserGroup represents a set of {User Users} that are interested in particular # studies # # === Properties # * group_type # * label # * study -class Group < ApplicationRecord - # Each Group can have multiple {User Users} +class UserGroup < ApplicationRecord + # Each UserGroup can have multiple {User Users} has_many :users # Study can hold either a String or an Array, but is still stored in a single @@ -18,7 +18,7 @@ class Group < ApplicationRecord private # Private methods - # Incase more than just the study label is submitted extract the label for + # In case more than just the study label is submitted extract the label for # saving def remove_study_labelling if study.is_a? Array diff --git a/app/views/groups/external.json.jbuilder b/app/views/user_groups/external.json.jbuilder similarity index 100% rename from app/views/groups/external.json.jbuilder rename to app/views/user_groups/external.json.jbuilder diff --git a/app/views/groups/index.json.jbuilder b/app/views/user_groups/index.json.jbuilder similarity index 100% rename from app/views/groups/index.json.jbuilder rename to app/views/user_groups/index.json.jbuilder diff --git a/app/views/groups/show.json.jbuilder b/app/views/user_groups/show.json.jbuilder similarity index 100% rename from app/views/groups/show.json.jbuilder rename to app/views/user_groups/show.json.jbuilder diff --git a/config/routes.rb b/config/routes.rb index 9d23a853..124390a8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -33,7 +33,7 @@ end end - resources :groups, constraints: -> (r) { (r.format == :json) } do + resources :user_groups, constraints: -> (r) { (r.format == :json) } do collection do get 'external' end diff --git a/db/migrate/20170517105644_rename_groups_to_user_groups.rb b/db/migrate/20170517105644_rename_groups_to_user_groups.rb new file mode 100644 index 00000000..f2a72817 --- /dev/null +++ b/db/migrate/20170517105644_rename_groups_to_user_groups.rb @@ -0,0 +1,5 @@ +class RenameGroupsToUserGroups < ActiveRecord::Migration[5.0] + def change + rename_table 'groups', 'user_groups' + end +end diff --git a/db/structure.sql b/db/structure.sql index 00a6e680..ba660337 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -481,39 +481,6 @@ CREATE VIEW dv_mappings AS JOIN variables s ON (((s.id = m.source_id) AND ((m.source_type)::text = 'Variable'::text)))); --- --- Name: groups; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE groups ( - id integer NOT NULL, - group_type character varying, - label character varying, - study character varying, - created_at timestamp without time zone NOT NULL, - updated_at timestamp without time zone NOT NULL -); - - --- --- Name: groups_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE groups_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE groups_id_seq OWNED BY groups.id; - - -- -- Name: identifiers; Type: TABLE; Schema: public; Owner: - -- @@ -1046,6 +1013,39 @@ CREATE SEQUENCE topics_id_seq ALTER SEQUENCE topics_id_seq OWNED BY topics.id; +-- +-- Name: user_groups; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE user_groups ( + id integer NOT NULL, + group_type character varying, + label character varying, + study character varying, + created_at timestamp without time zone NOT NULL, + updated_at timestamp without time zone NOT NULL +); + + +-- +-- Name: user_groups_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE user_groups_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: user_groups_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE user_groups_id_seq OWNED BY user_groups.id; + + -- -- Name: users; Type: TABLE; Schema: public; Owner: - -- @@ -1193,13 +1193,6 @@ ALTER TABLE ONLY datasets ALTER COLUMN id SET DEFAULT nextval('datasets_id_seq': ALTER TABLE ONLY documents ALTER COLUMN id SET DEFAULT nextval('documents_id_seq'::regclass); --- --- Name: id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY groups ALTER COLUMN id SET DEFAULT nextval('groups_id_seq'::regclass); - - -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- @@ -1305,6 +1298,13 @@ ALTER TABLE ONLY response_units ALTER COLUMN id SET DEFAULT nextval('response_un ALTER TABLE ONLY topics ALTER COLUMN id SET DEFAULT nextval('topics_id_seq'::regclass); +-- +-- Name: id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY user_groups ALTER COLUMN id SET DEFAULT nextval('user_groups_id_seq'::regclass); + + -- -- Name: id; Type: DEFAULT; Schema: public; Owner: - -- @@ -1463,14 +1463,6 @@ ALTER TABLE ONLY response_units ADD CONSTRAINT encapsulate_unique_for_response_units UNIQUE (id, instrument_id); --- --- Name: groups_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY groups - ADD CONSTRAINT groups_pkey PRIMARY KEY (id); - - -- -- Name: identifiers_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -1599,6 +1591,14 @@ ALTER TABLE ONLY rds_qs ADD CONSTRAINT unique_for_rd_order_within_question UNIQUE (question_id, question_type, rd_order) DEFERRABLE INITIALLY DEFERRED; +-- +-- Name: user_groups_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY user_groups + ADD CONSTRAINT user_groups_pkey PRIMARY KEY (id); + + -- -- Name: users_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -2262,7 +2262,7 @@ ALTER TABLE ONLY control_constructs -- ALTER TABLE ONLY users - ADD CONSTRAINT fk_rails_f40b3f4da6 FOREIGN KEY (group_id) REFERENCES groups(id); + ADD CONSTRAINT fk_rails_f40b3f4da6 FOREIGN KEY (group_id) REFERENCES user_groups(id); -- @@ -2331,6 +2331,7 @@ INSERT INTO schema_migrations (version) VALUES ('20161213091354'), ('20170302132603'), ('20170302132849'), -('20170505135010'); +('20170505135010'), +('20170517105644');