Skip to content

Commit

Permalink
Renamed Groups to UserGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
wpoynter committed May 17, 2017
1 parent 80c0d30 commit 61f7c36
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class GroupsController < BasicController
class UserGroupsController < BasicController
only_set_object

@model_class = Group
Expand Down
8 changes: 4 additions & 4 deletions app/models/group.rb → app/models/user_group.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20170517105644_rename_groups_to_user_groups.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RenameGroupsToUserGroups < ActiveRecord::Migration[5.0]
def change
rename_table 'groups', 'user_groups'
end
end
101 changes: 51 additions & 50 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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: -
--
Expand Down Expand Up @@ -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: -
--
Expand Down Expand Up @@ -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: -
--
Expand Down Expand Up @@ -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: -
--
Expand Down Expand Up @@ -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: -
--
Expand Down Expand Up @@ -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: -
--
Expand Down Expand Up @@ -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);


--
Expand Down Expand Up @@ -2331,6 +2331,7 @@ INSERT INTO schema_migrations (version) VALUES
('20161213091354'),
('20170302132603'),
('20170302132849'),
('20170505135010');
('20170505135010'),
('20170517105644');


0 comments on commit 61f7c36

Please sign in to comment.