4 May 2012 13:35
[mb-commits] branch, schema-change-2012-05-04, created. Merge branch 'mbs-1798' into schema-change-2012-05-04 Add 20120411-add-work-l...
MusicBrainz Git Server <noreply <at> musicbrainz.org>
2012-05-04 11:35:58 GMT
2012-05-04 11:35:58 GMT
The branch, schema-change-2012-05-04 has been created
at 6a12656ce2c7dfe889833d81fe2d3bce5c71d97e (commit)
- Log -----------------------------------------------------------------
commit 6a12656ce2c7dfe889833d81fe2d3bce5c71d97e
Merge: d7beea2 8672693
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri May 4 12:35:18 2012 +0100
Merge branch 'mbs-1798' into schema-change-2012-05-04
* mbs-1798:
Add 20120411-add-work-language.sql to upgrade.sh
MBS-1798, display work language when present, use "Lyrics Language" as label.
MBS-1798, reference language.id in CreateTables.sql for the benefit of GenerateSQL. Do the database update in a transaction.
MBS-1798, add l() function back in in lib/MusicBrainz/Server/Form/ReleaseEditor/Information.pm.
MBS-1798, Add Lyrics language for works
MBS-1798, Add language column to work table.
Conflicts:
lib/MusicBrainz/Server/Controller/WS/2/Work.pm
lib/MusicBrainz/Server/Data/Work.pm
lib/MusicBrainz/Server/Edit/Work/Create.pm
lib/MusicBrainz/Server/Edit/Work/Edit.pm
lib/MusicBrainz/Server/Entity/Work.pm
lib/MusicBrainz/Server/Form/Work.pm
lib/MusicBrainz/Server/WebService/XMLSerializer.pm
root/work/layout.tt
t/lib/t/MusicBrainz/Server/Controller/Work/Create.pm
t/lib/t/MusicBrainz/Server/Edit/Work/Create.pm
diff --cc admin/sql/CreateTables.sql
index 847b055,d886620..47c97ec
--- a/admin/sql/CreateTables.sql
+++ b/admin/sql/CreateTables.sql
<at> <at> <at> -1268,7 -1184,9 +1268,8 <at> <at> <at> CREATE TABLE work
name INTEGER NOT NULL, -- references work_name.id
artist_credit INTEGER, -- no longer in use
type INTEGER, -- references work_type.id
- iswc CHAR(15) CHECK (iswc IS NULL OR iswc ~ E'^T-?\\d{3}\.?\\d{3}\.?\\d{3}[-.]?\\d$'),
comment VARCHAR(255),
+ language INTEGER, -- references language.id
edits_pending INTEGER NOT NULL DEFAULT 0 CHECK (edits_pending >= 0),
last_updated TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
diff --cc lib/MusicBrainz/Server/Controller/Artist.pm
index 6c64670,8bcf484..f77e5f0
--- a/lib/MusicBrainz/Server/Controller/Artist.pm
+++ b/lib/MusicBrainz/Server/Controller/Artist.pm
<at> <at> <at> -253,8 -253,8 +253,9 <at> <at> <at> sub works : Chained('load'
});
$c->model('Work')->load_writers( <at> $works);
$c->model('Work')->load_recording_artists( <at> $works);
+ $c->model('ISWC')->load_for_works( <at> $works);
$c->model('WorkType')->load( <at> $works);
+ $c->model('Language')->load( <at> $works);
if ($c->user_exists) {
$c->model('Work')->rating->load_user_ratings($c->user->id, <at> $works);
}
diff --cc lib/MusicBrainz/Server/Controller/WS/2/Work.pm
index a50270e,27cabb1..3f54f94
--- a/lib/MusicBrainz/Server/Controller/WS/2/Work.pm
+++ b/lib/MusicBrainz/Server/Controller/WS/2/Work.pm
<at> <at> <at> -47,7 -47,7 +47,8 <at> <at> <at> sub work_topleve
}
$c->model('WorkType')->load($work);
+ $c->model('ISWC')->load_for_works($work);
+ $c->model('Language')->load($work);
}
sub base : Chained('root') PathPart('work') CaptureArgs(0) { }
diff --cc lib/MusicBrainz/Server/Data/Work.pm
index 13c7c41,aec8754..9bca47c
--- a/lib/MusicBrainz/Server/Data/Work.pm
+++ b/lib/MusicBrainz/Server/Data/Work.pm
<at> <at> <at> -39,8 -39,8 +39,8 <at> <at> <at> sub _table_join_name
sub _columns
{
- return 'work.id, work.gid, work.type AS type_id, name.name, work.comment,
- work.edits_pending, work.last_updated';
+ return 'work.id, work.gid, work.type AS type_id, work.language AS language_id,
- name.name, work.iswc, work.comment, work.edits_pending, work.last_updated';
++ name.name, work.comment, work.edits_pending, work.last_updated';
}
sub _id_column
<at> <at> <at> -194,7 -182,8 +194,8 <at> <at> <at> sub _hash_to_ro
my ($self, $work, $names) = <at> _;
my $row = hash_to_row($work, {
type => 'type_id',
+ language => 'language_id',
- map { $_ => $_ } qw( iswc comment )
+ map { $_ => $_ } qw( comment )
});
$row->{name} = $names->{$work->{name}}
diff --cc lib/MusicBrainz/Server/Edit/Work/Create.pm
index 0c1456e,0a9eeea..2081af5
--- a/lib/MusicBrainz/Server/Edit/Work/Create.pm
+++ b/lib/MusicBrainz/Server/Edit/Work/Create.pm
<at> <at> <at> -43,6 -45,8 +45,7 <at> <at> <at> sub build_display_dat
name => $self->data->{name},
comment => $self->data->{comment},
type => $self->data->{type_id} && $loaded->{WorkType}->{ $self->data->{type_id} },
+ language => $self->data->{language_id} && $loaded->{Language}->{ $self->data->{language_id} },
- iswc => $self->data->{iswc},
work => $loaded->{Work}{ $self->entity_id }
|| Work->new( name => $self->data->{name} )
};
diff --cc lib/MusicBrainz/Server/Edit/Work/Edit.pm
index c46407b,b18c455..6cade2c
--- a/lib/MusicBrainz/Server/Edit/Work/Edit.pm
+++ b/lib/MusicBrainz/Server/Edit/Work/Edit.pm
<at> <at> <at> -63,9 -65,11 +65,10 <at> <at> <at> sub build_display_dat
my ($self, $loaded) = <at> _;
my %map = (
- name => 'name',
- comment => 'comment',
- type => [ qw( type_id WorkType ) ]
+ name => 'name',
+ comment => 'comment',
+ type => [ qw( type_id WorkType ) ],
+ language => [ qw( language_id Language ) ],
- iswc => 'iswc',
);
my $data = changed_display_data($self->data, $loaded, %map);
diff --cc lib/MusicBrainz/Server/Entity/Work.pm
index e082a1e,7904e9d..8189b1f7
--- a/lib/MusicBrainz/Server/Entity/Work.pm
+++ b/lib/MusicBrainz/Server/Entity/Work.pm
<at> <at> <at> -29,6 -29,21 +29,16 <at> <at> <at> sub type_nam
return $self->type ? $self->type->name : undef;
}
+ has 'language_id' => (
+ is => 'rw',
+ isa => 'Int'
+ );
+
+ has 'language' => (
+ is => 'rw',
+ isa => 'Language'
+ );
+
-has 'iswc' => (
- is => 'rw',
- isa => 'Str'
-);
-
has 'comment' => (
is => 'rw',
isa => 'Str'
diff --cc lib/MusicBrainz/Server/Form/Work.pm
index 9e0ec20,af3be39..3ee5bac
--- a/lib/MusicBrainz/Server/Form/Work.pm
+++ b/lib/MusicBrainz/Server/Form/Work.pm
<at> <at> <at> -20,8 -30,9 +26,9 <at> <at> <at> has_field 'comment' =>
maxlength => 255
);
- sub edit_field_names { qw( type_id name comment artist_credit ) }
-sub edit_field_names { qw( type_id language_id name iswc comment artist_credit ) }
++sub edit_field_names { qw( type_id language_id name comment artist_credit ) }
- sub options_type_id { shift->_select_all('WorkType') }
+ sub options_type_id { shift->_select_all('WorkType') }
+ sub options_language_id { return language_options (shift->ctx); }
1;
diff --cc lib/MusicBrainz/Server/WebService/XMLSerializer.pm
index 161d4c0,25abb87..c2f233c
--- a/lib/MusicBrainz/Server/WebService/XMLSerializer.pm
+++ b/lib/MusicBrainz/Server/WebService/XMLSerializer.pm
<at> <at> <at> -361,12 -360,8 +361,13 <at> <at> <at> sub _serialize_wor
my <at> list;
push <at> list, $gen->title($work->name);
- push <at> list, $gen->iswc($iswc) if $iswc;
+ if ($work->all_iswcs) {
+ push <at> list, $gen->iswc_list(map {
+ $gen->iswc($_->iswc);
+ } $work->all_iswcs);
+ }
+
+ push <at> list, $gen->language($work->language->iso_code_3 // $work->language->iso_code_2t) if $work->language;
push <at> list, $gen->disambiguation($work->comment) if ($work->comment);
$self->_serialize_alias(\ <at> list, $gen, $opts->{aliases}, $inc, $opts)
diff --cc root/work/edit_form.tt
index 6633a24,60e039e..d629b79
--- a/root/work/edit_form.tt
+++ b/root/work/edit_form.tt
<at> <at> <at> -6,7 -6,9 +6,8 <at> <at> <at>
<legend>[%- l('Work Details') -%]</legend>
[%- form_row_text_long(r, 'name', l('Name:')) -%]
[%- form_row_text_long(r, 'comment', l('Disambiguation:')) -%]
- [%- form_row_text_long(r, 'iswc', l('ISWC:')) -%]
[%- form_row_select(r, 'type_id', l('Type:')) -%]
+ [%- form_row_select(r, 'language_id', l('Lyrics Language:')) -%]
</fieldset>
[%- INCLUDE 'forms/edit-note.tt' -%]
diff --cc root/work/layout.tt
index 551c80a,f355442..11c7475
--- a/root/work/layout.tt
+++ b/root/work/layout.tt
<at> <at> <at> -5,9 -5,12 +5,12 <at> <at> <at>
[%- WRAPPER "layout.tt" usesRDFa=1 title=title ? main_title _ " - ${title}" : main_title -%]
[% WRAPPER 'layout/sidebar.tt' %]
- [% IF work.type || work.iswcs.size %]
- [% IF work.type || work.iswc || work.language %]
++ [% IF work.type || work.iswcs.size || work.language %]
<h2>[% l('Work information') %]</h2>
[% WRAPPER 'layout/sidebar/properties.tt' %]
+ [% INCLUDE 'layout/sidebar/property.tt' label=l('Lyrics Language:')
+ content=html_escape(l(work.language.name))
+ IF work.language -%]
[% INCLUDE 'layout/sidebar/property.tt' label=l('Type:')
content=html_escape(l(work.type.name))
IF work.type -%]
diff --cc t/lib/t/MusicBrainz/Server/Controller/Work/Create.pm
index bc34e80,1cf9dea..9a3b7b1
--- a/t/lib/t/MusicBrainz/Server/Controller/Work/Create.pm
+++ b/t/lib/t/MusicBrainz/Server/Controller/Work/Create.pm
<at> <at> <at> -34,7 -35,9 +34,8 <at> <at> <at> isa_ok($edit, 'MusicBrainz::Server::Edi
is_deeply($edit->data, {
name => 'Enchanted',
comment => 'A comment!',
- type_id => 1
+ type_id => 1,
+ language_id => undef,
- iswc => 'T-000.000.001-0',
});
$mech->get_ok('/edit/' . $edit->id, 'Fetch the edit page');
diff --cc t/lib/t/MusicBrainz/Server/Edit/Work/Create.pm
index c27fafb,8546d28..004732c
--- a/t/lib/t/MusicBrainz/Server/Edit/Work/Create.pm
+++ b/t/lib/t/MusicBrainz/Server/Edit/Work/Create.pm
<at> <at> <at> -32,6 -33,8 +33,7 <at> <at> <at> ok(defined $work)
is($work->name, 'Mrs. Bongo');
is($work->comment => 'Work comment');
is($work->type_id, 1);
+ is($work->language_id, 1);
-is($work->iswc, 'T-000.000.001-0');
is($work->edits_pending, 0);
is($edit->status, $STATUS_APPLIED, 'add work edits should be autoedits');
<at> <at> <at> -46,7 -49,9 +48,8 <at> <at> <at> sub create_edi
edit_type => $EDIT_WORK_CREATE,
name => 'Mrs. Bongo',
comment => 'Work comment',
- type_id => 1
+ type_id => 1,
+ language_id => 1,
- iswc => 'T-000.000.001-0'
);
}
diff --cc t/lib/t/MusicBrainz/Server/Edit/Work/Edit.pm
index aab667e,91fbea6..0e958e2
--- a/t/lib/t/MusicBrainz/Server/Edit/Work/Edit.pm
+++ b/t/lib/t/MusicBrainz/Server/Edit/Work/Edit.pm
<at> <at> <at> -45,7 -46,9 +46,8 <at> <at> <at> accept_edit($c, $edit)
$work = $c->model('Work')->get_by_id(1);
is($work->name, 'Edited name');
is($work->comment, 'Edited comment');
-is($work->iswc, 'T-000.000.001-0');
is($work->type_id, 1);
+ is($work->language_id, 1);
is($work->edits_pending, 0);
};
<at> <at> <at> -114,7 -117,9 +116,8 <at> <at> <at> sub create_edit
to_edit => $work,
name => 'Edited name',
comment => 'Edited comment',
- iswc => 'T-000.000.001-0',
type_id => 1,
+ language_id => 1,
);
}
commit d7beea2dd20b308ed5637461209966d4d3e0231a
Merge: 5f58442 863e7c5
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri May 4 12:30:51 2012 +0100
Merge branch 'mbs-1799' into schema-change-2012-05-04
* mbs-1799:
Add ISO 639-3 upgrade scripts to upgrade.sh
MBS-1799, add constraint to make sure one of iso_code_2t and iso_code_3 isn't NULL. Comment on using 'qaa' in iso_code_3 column for artificial languages.
MBS-1799, fix several typos, remove 'NOT NULL' constraint on Part 2 columns in the language table.
MBS-1799, missing comma in admin/sql/InsertTestData.sql
MBS-1799, re-use the existing artificial language row, instead of creating a new one.
MBS-1799, Replace occurances of iso_code_3t with iso_code_3.
MBS-1799, database update scripts to add iso-693-3 to the database.
Conflicts:
upgrade.sh
diff --cc upgrade.sh
index c94f07b,435cc19..3d67011
--- a/upgrade.sh
+++ b/upgrade.sh
<at> <at> <at> -19,27 -19,12 +19,33 <at> <at> <at> the
./admin/psql READWRITE < ./admin/sql/DropReplicationTriggers.sql
fi
+echo `date` : Applying 20120420-editor-improvements.sql
+./admin/psql < admin/sql/updates/20120420-editor-improvements.sql
+
+echo `date` : Appyling 20120417-improved-aliases.sql
+./admin/psql < admin/sql/updates/20120417-improved-aliases.sql
+
+echo `date` : Applying 20120423-release-group-types.sql
+./admin/psql < admin/sql/updates/20120423-release-group-types.sql
+
+echo `date` : Applying 20120320-remove-url-refcount.sql
+./admin/psql < admin/sql/updates/20120320-remove-url-refcount.sql
+
+echo `date` : 20120410-multiple-iswcs-per-work.sql
+./admin/psql < admin/sql/updates/20120410-multiple-iswcs-per-work.sql
+
+echo `date` : 20120430-timeline-events.sql
+./admin/psql < admin/sql/updates/20120430-timeline-events.sql
+
+echo `date` : 20120501-timeline-events.sql
+./admin/psql < admin/sql/updates/20120501-timeline-events.sql
+
+ echo `date` : Applying 20120405-rename-language-columns.sql
+ ./admin/psql < admin/sql/updates/20120405-rename-language-columns.sql
+
+ echo `date` : Running 20120406-update-language-codes.pl
+ ./admin/sql/updates/20120406-update-language-codes.pl
+
if [ "$REPLICATION_TYPE" = "$RT_MASTER" ]
then
echo `date` : Create replication triggers
commit 5f58442b3d35d172f43614b3ffbb9c4834b08a32
Merge: 0c1d5cb ff28ef4
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri May 4 12:30:28 2012 +0100
Merge branch 'mbs-2851' into schema-change-2012-05-04
* mbs-2851:
Add timeline event SQL upgrades to upgrade.sh
Do not assume the application is running at /, and use a relative path for /ws/js/events
Fix overlapping events correctly
Add statistic_event table to replication, import and export
Switch timeline.js to use the /ws/js/events JSON
Add the /ws/js/events end point
Add a SQL file to prepopulate all events
Add the statistics_event table
Conflicts:
upgrade.sh
diff --cc upgrade.sh
index 24965c8,4d26563..c94f07b
--- a/upgrade.sh
+++ b/upgrade.sh
<at> <at> <at> -19,21 -19,12 +19,27 <at> <at> <at> the
./admin/psql READWRITE < ./admin/sql/DropReplicationTriggers.sql
fi
+echo `date` : Applying 20120420-editor-improvements.sql
+./admin/psql < admin/sql/updates/20120420-editor-improvements.sql
+
+echo `date` : Appyling 20120417-improved-aliases.sql
+./admin/psql < admin/sql/updates/20120417-improved-aliases.sql
+
+echo `date` : Applying 20120423-release-group-types.sql
+./admin/psql < admin/sql/updates/20120423-release-group-types.sql
+
+echo `date` : Applying 20120320-remove-url-refcount.sql
+./admin/psql < admin/sql/updates/20120320-remove-url-refcount.sql
+
+echo `date` : 20120410-multiple-iswcs-per-work.sql
+./admin/psql < admin/sql/updates/20120410-multiple-iswcs-per-work.sql
+
+ echo `date` : 20120430-timeline-events.sql
+ ./admin/psql < admin/sql/updates/20120430-timeline-events.sql
+
+ echo `date` : 20120501-timeline-events.sql
+ ./admin/psql < admin/sql/updates/20120501-timeline-events.sql
+
if [ "$REPLICATION_TYPE" = "$RT_MASTER" ]
then
echo `date` : Create replication triggers
commit 0c1d5cb498c2b00cbeffbdb6818f7a535928f5de
Merge: c7995cd 36cc43f
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri May 4 12:30:11 2012 +0100
Merge branch 'mbs-2885' into schema-change-2012-05-04
* mbs-2885: (28 commits)
Add 20120410-multiple-iswcs-per-work.sql to upgrade.sh
Display work iswcs in the sidebar, even if the work does not have a type
Add the ISWC table to replication and import/export
Remove ISWC from work form
Remove duplicate rdfa_work_iswc
Correctly merge ISWCs for works
Update CreateSimpleViews now that the iswc column has been dropped
Fix remaining tests
Work around patch to show ISWCs in indexed searches until the search server gets updated
Show ISWCs in direct searchs
Fix controller tests
Remove what can be removed from the add/edit work edit types
Integrate multiple ISWCs into /ws/2
Show ISWCs in the artist works list
Add support for removing ISWCs
Support viewing ISWCs
Get the 'Add ISWC' form working
Test and implement RemoveISWC edit type
Add an AddISWC edit type
Show ISWCs on the works page
...
Conflicts:
upgrade.sh
diff --cc t/sql/webservice.sql
index db01bbe,487409c..8b0e189
--- a/t/sql/webservice.sql
+++ b/t/sql/webservice.sql
<at> <at> <at> -3791,10 -3789,10 +3791,10 <at> <at> <at> INSERT INTO work (last_updated, name, e
UPDATE work_meta SET rating_count = NULL, rating = NULL WHERE id = 211564;
INSERT INTO l_recording_work (link, last_updated, entity1, entity0, edits_pending, id) VALUES (23865, '2011-01-18 16:15:33.876477+00', 211564, 2726275, 0, 8120);
INSERT INTO work_name (name, id) VALUES ('Asleep From Day', 80234);
- INSERT INTO work (last_updated, name, edits_pending, artist_credit, iswc, comment, id, type, gid) VALUES (NULL, 80234, 0, NULL, NULL, NULL, 2726277, NULL, 'c473ece7-4858-3f4f-9d7a-a1e026400887');
+ INSERT INTO work (last_updated, name, edits_pending, artist_credit, comment, id, type, gid) VALUES (NULL, 80234, 0, NULL, NULL, 2726277, NULL, 'c473ece7-4858-3f4f-9d7a-a1e026400887');
UPDATE work_meta SET rating_count = NULL, rating = NULL WHERE id = 2726277;
INSERT INTO l_recording_work (link, last_updated, entity1, entity0, edits_pending, id) VALUES (23865, '2011-01-18 16:15:33.876477+00', 2726277, 2726277, 0, 230405);
-INSERT INTO url (last_updated, url, edits_pending, ref_count, id, description, gid) VALUES ('2011-01-18 16:23:38+00', 'http://en.wikipedia.org/wiki/The_Love_Bug_(song)', 0, 1, 615313, '', '5e766c4e-16dd-47f2-b032-d96ef23c0cf1');
+INSERT INTO url (last_updated, url, edits_pending, id , description, gid) VALUES ('2011-01-18 16:23:38+00', 'http://en.wikipedia.org/wiki/The_Love_Bug_(song)', 0, 615313, '', '5e766c4e-16dd-47f2-b032-d96ef23c0cf1');
INSERT INTO link_type (priority, last_updated, parent, name, description, short_link_phrase, link_phrase, entity_type1, entity_type0, id, reverse_link_phrase, child_order, gid) VALUES (0, '2011-01-18 15:31:00.495651+00', NULL, 'other databases', '', 'other databases', 'other databases', 'url', 'release_group', 101, 'other databases', 3, '87d1e331-d265-3e73-b98c-6f3cb69f07a4');
INSERT INTO link_type (priority, last_updated, parent, name, description, short_link_phrase, link_phrase, entity_type1, entity_type0, id, reverse_link_phrase, child_order, gid) VALUES (0, '2011-01-18 15:31:00.495651+00', 101, 'wikipedia', 'Points to the Wikipedia page for this album. (<a href="http://musicbrainz.org/doc/Wikipedia_Relationship_Type">Details</a>)', 'wikipedia', 'Wikipedia', 'url', 'release_group', 94, 'Wikipedia page for', 0, '6578f0e9-1ace-4095-9de8-6e517ddb1ceb');
INSERT INTO link (begin_date_day, attribute_count, begin_date_year, created, link_type, end_date_day, begin_date_month, end_date_month, id, end_date_year) VALUES (NULL, 0, NULL, '2011-01-18 15:31:00.495651+00', 94, NULL, NULL, NULL, 6067, NULL);
diff --cc upgrade.sh
index 5554dd9,d056333..24965c8
--- a/upgrade.sh
+++ b/upgrade.sh
<at> <at> <at> -19,18 -19,9 +19,21 <at> <at> <at> the
./admin/psql READWRITE < ./admin/sql/DropReplicationTriggers.sql
fi
+echo `date` : Applying 20120420-editor-improvements.sql
+./admin/psql < admin/sql/updates/20120420-editor-improvements.sql
+
+echo `date` : Appyling 20120417-improved-aliases.sql
+./admin/psql < admin/sql/updates/20120417-improved-aliases.sql
+
+echo `date` : Applying 20120423-release-group-types.sql
+./admin/psql < admin/sql/updates/20120423-release-group-types.sql
+
+echo `date` : Applying 20120320-remove-url-refcount.sql
+./admin/psql < admin/sql/updates/20120320-remove-url-refcount.sql
+
+ echo `date` : 20120410-multiple-iswcs-per-work.sql
+ ./admin/psql < admin/sql/updates/20120410-multiple-iswcs-per-work.sql
+
if [ "$REPLICATION_TYPE" = "$RT_MASTER" ]
then
echo `date` : Create replication triggers
commit c7995cde1c21a43c44ab52e42bfb55a1ddea6aa1
Merge: a81c80a d630c4d
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri May 4 12:29:50 2012 +0100
Merge branch 'mbs-3189' into schema-change-2012-05-04
* mbs-3189:
Add 20120320-remove-url-refcount.sql to upgrade.sh
Add a upgrade script
Remove ref_count from the tests
Remove the url.reference_count attribute for the object model
MBS-3189: Drop the url.ref_count column
Conflicts:
upgrade.sh
diff --cc upgrade.sh
index 3c56a94,0b366d3..5554dd9
--- a/upgrade.sh
+++ b/upgrade.sh
<at> <at> <at> -19,15 -19,9 +19,18 <at> <at> <at> the
./admin/psql READWRITE < ./admin/sql/DropReplicationTriggers.sql
fi
+echo `date` : Applying 20120420-editor-improvements.sql
+./admin/psql < admin/sql/updates/20120420-editor-improvements.sql
+
+echo `date` : Appyling 20120417-improved-aliases.sql
+./admin/psql < admin/sql/updates/20120417-improved-aliases.sql
+
+echo `date` : Applying 20120423-release-group-types.sql
+./admin/psql < admin/sql/updates/20120423-release-group-types.sql
+
+ echo `date` : Applying 20120320-remove-url-refcount.sql
+ ./admin/psql < admin/sql/updates/20120320-remove-url-refcount.sql
+
if [ "$REPLICATION_TYPE" = "$RT_MASTER" ]
then
echo `date` : Create replication triggers
commit a81c80a06aed95c29e0aa61b898276bf1b4771cb
Merge: 1b5a6b0 e7082fd
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri May 4 12:29:24 2012 +0100
Merge branch 'mbs-3646' into schema-change-2012-05-04
* mbs-3646:
Add 20120423-release-group-types.sql to upgrade.sh
Group by primary type, and show secondary types as labels
Fix failing controller test now that a field has been renamed
Add <secondary-types> to the XML
Fix outstanding failing test cases
Add import/export/replication triggers for release group primary and secondary types
Allow specifying release group types from the add release wizard
Fix release editor to work with primary_types
Allow editing release groups and adding extra types
Add a form interface for selecting secondary types for release groups
Use type_name instead of type.name to display release group types
Rename type to primary_type in the object model
Migrate existing release group types to a combination of primary/secondary types
Pass existing tests to now use release_group_primary_type
Use the term 'secondary_type' instead of 'release_group_type'
Rename release_group_type to release_group_primary_type
Add a schema migration for secondary release group types
Add schema changes for secondary release group types
Conflicts:
upgrade.sh
diff --cc upgrade.sh
index ac6f6a5,006c9a9..3c56a94
--- a/upgrade.sh
+++ b/upgrade.sh
<at> <at> <at> -19,12 -19,9 +19,15 <at> <at> <at> the
./admin/psql READWRITE < ./admin/sql/DropReplicationTriggers.sql
fi
+echo `date` : Applying 20120420-editor-improvements.sql
+./admin/psql < admin/sql/updates/20120420-editor-improvements.sql
+
+echo `date` : Appyling 20120417-improved-aliases.sql
+./admin/psql < admin/sql/updates/20120417-improved-aliases.sql
+
+ echo `date` : Applying 20120423-release-group-types.sql
+ ./admin/psql < admin/sql/updates/20120423-release-group-types.sql
+
if [ "$REPLICATION_TYPE" = "$RT_MASTER" ]
then
echo `date` : Create replication triggers
commit 1b5a6b0b9b3321766871495931e403d49e68bebf
Merge: 8cd8843 0f448f3
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri May 4 12:29:09 2012 +0100
Merge branch 'mbs-3788' into schema-change-2012-05-04
* mbs-3788: (39 commits)
Add 20120417-improved-aliases.sql to upgrade.sh
Serialize the begin and end date of the alias to the XML
Add the new _type tables to import/export and replication
Add the new constraints to CreateTables
Add constraints on how a 'search hint' alias should appear
Allow inserts with a type_id
Do not allow users to edit the properties of search hint aliasesDo not allow users to edit the properties of search hint aliases
Clear out properties of search hints, as they are never meant to have any data
Fix outstanding failing tests
Fix controller tests to work with new alias data
/ws/2/ support for new alias properties
Add a trigger/function to only allow one primary locale per alias group
Sort aliases by sort name before sorting by name
Remove checks to ensure there is only one alias per locale
Revert "Group aliases by type in the alias page, sort by sort name before sorting by name"
Add validation to not allow primary_for_locale when locale is unde
Toggle the display of the 'primary_for_locale' checkbox, depending on locale selected
Only prefill the add alias name field, but not the sort name/begin/end dates
Group aliases by type in the alias page, sort by sort name before sorting by name
Show contents of primary_for_locale in all edit templates
...
Conflicts:
upgrade.sh
diff --cc upgrade.sh
index c17e436,c136aa4..ac6f6a5
--- a/upgrade.sh
+++ b/upgrade.sh
<at> <at> <at> -19,9 -19,9 +19,12 <at> <at> <at> the
./admin/psql READWRITE < ./admin/sql/DropReplicationTriggers.sql
fi
+echo `date` : Applying 20120420-editor-improvements.sql
+./admin/psql < admin/sql/updates/20120420-editor-improvements.sql
+
+ echo `date` : Appyling 20120417-improved-aliases.sql
+ ./admin/psql < admin/sql/updates/20120417-improved-aliases.sql
+
if [ "$REPLICATION_TYPE" = "$RT_MASTER" ]
then
echo `date` : Create replication triggers
commit 8cd8843825821d7273127810a195a71f95fa2ca1
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri May 4 12:13:24 2012 +0100
Add the 20120420-editor-improvements.sql to upgrade.sh
diff --git a/upgrade.sh b/upgrade.sh
index 542e574..c17e436 100755
--- a/upgrade.sh
+++ b/upgrade.sh
<at> <at> -19,6 +19,9 <at> <at> then
./admin/psql READWRITE < ./admin/sql/DropReplicationTriggers.sql
fi
+echo `date` : Applying 20120420-editor-improvements.sql
+./admin/psql < admin/sql/updates/20120420-editor-improvements.sql
+
if [ "$REPLICATION_TYPE" = "$RT_MASTER" ]
then
echo `date` : Create replication triggers
commit cd10a146ba9a95baf80766b4b35fdc64e234fe18
Merge: 68f7f2c 8babd7e
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri May 4 12:11:34 2012 +0100
Merge branch 'master' into mbs-4337
* master: (214 commits)
Add a skeleton database upgrade script
Fix test failure in t/script/SubscriptionEmails.t
MBS-4647: Do not display the add cover art form if JavaScript is disabled
MBS-4640: Remove ThickBox logic for displaying web pages, we only need it for images
MBS-4642: Remove ThickBox global reset
MBS-4625: Explain why there may be artwork in the sidebar, even if there is no CAA artwork
Unbreak the graphs when stuff isn't defined in view.js
MBS-4629: Fix displaying links to collections cover-art pages
Fix bad imports in cleanup jobs
Fix reference to in cover art edits
alter_edit_pending for releases on remove artwork
Remove update scripts, these are now in admin/sql/caa/*
Fix invalid HTML/JavaScript in the image macro
Get tests passing again
Initialize create_test_db with CAA stuff
Run unit tests against the TEST database
MBS-4619, display appropriate fallback message when a cover art image is not available yet.
Add the '--schema' option to psql, remove the '--profile' option
Add Create and Drop SQL for CAA
Add CAA support to GenerateSQLScripts.pl
...
Conflicts:
root/static/styles/widgets.css
diff --cc lib/MusicBrainz/Server/Entity/Editor.pm
index d15cb2b,a2a942c..db619a5
--- a/lib/MusicBrainz/Server/Entity/Editor.pm
+++ b/lib/MusicBrainz/Server/Entity/Editor.pm
<at> <at> <at> -1,9 -1,10 +1,11 <at> <at> <at>
package MusicBrainz::Server::Entity::Editor;
use Moose;
+ use namespace::autoclean;
+use DateTime;
use MusicBrainz::Server::Entity::Preferences;
- use MusicBrainz::Server::Types qw( :privileges );
+ use MusicBrainz::Server::Constants qw( :privileges );
+ use MusicBrainz::Server::Types DateTime => { -as => 'DateTimeType' };
extends 'MusicBrainz::Server::Entity';
commit 68f7f2cba2b234eae5224aa7d89e7c1581295df1
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Tue Apr 24 17:45:04 2012 +0100
Add editor_language to the import/export process
diff --git a/admin/ExportAllTables b/admin/ExportAllTables
index 661bc47..8d5c21c 100755
--- a/admin/ExportAllTables
+++ b/admin/ExportAllTables
<at> <at> -81,6 +81,7 <at> <at> my <at> tables = qw(
country
editor
editor_preference
+ editor_language
editor_sanitised
editor_subscribe_artist
editor_subscribe_editor
<at> <at> -302,6 +303,7 <at> <at> my <at> group_stats = qw(
my <at> group_editor = qw(
editor_sanitised
+ editor_language
);
my <at> group_edit = qw(
diff --git a/admin/MBImport.pl b/admin/MBImport.pl
index e9bea85..3ac3ab8 100755
--- a/admin/MBImport.pl
+++ b/admin/MBImport.pl
<at> <at> -358,6 +358,7 <at> <at> sub ImportAllTables
clientversion
country
editor
+ editor_language
editor_preference
editor_sanitised
editor_subscribe_artist
commit efcf8c005f274b4fa9f7aa9d7ade1d934d94dd99
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Mon Apr 23 16:07:04 2012 +0100
Fix submitting edit profile form with return
diff --git a/root/account/edit.tt b/root/account/edit.tt
index 3653f96..a74e26c 100644
--- a/root/account/edit.tt
+++ b/root/account/edit.tt
<at> <at> -9,7 +9,7 <at> <at>
[%- USE r = FormRenderer(form) -%]
- <form action="[% c.req.uri %]" method="post">
+ <form action="[% c.req.uri %]" method="post" id="edit-profile-form">
[%- IF server_details.testing_features -%]
[%- warning(l('This is a development server. Your email address is not private or secure. Proceed with caution!')) -%]
[%- END -%]
<at> <at> -72,10 +72,11 <at> <at>
$(this).parent('li').before(newLanguage);
});
+ MB.utility.setDefaultAction('#edit-profile-form', '#edit-profile-submit button');
});
</script>
- <div class="row no-label">
+ <div class="row no-label" id="edit-profile-submit">
[% form_submit(l('Save')) %]
</div>
<p class="row no-label">[% l('If you would like to delete your account, you may {uri|do so here}.', { uri => c.uri_for_action("/admin/delete_user", user.name) })%]</p>
commit 7c932a9bcfdc3f4807536a31fa621bab48b6045d
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Mon Apr 23 16:06:42 2012 +0100
Fix submitting edit profile with an empty birth date
diff --git a/lib/MusicBrainz/Server/Data/Editor.pm b/lib/MusicBrainz/Server/Data/Editor.pm
index b9a2eb1..596b76b 100644
--- a/lib/MusicBrainz/Server/Data/Editor.pm
+++ b/lib/MusicBrainz/Server/Data/Editor.pm
<at> <at> -301,7 +301,12 <at> <at> sub update_profile
);
if (my $date = delete $row->{birth_date}) {
- $row->{birth_date} = sprintf '%d-%d-%d', map { $date->{$_} } qw( year month day );
+ if (%$date) { # if date is given but all NULL, it will be an empty hash.
+ $row->{birth_date} = sprintf '%d-%d-%d', map { $date->{$_} } qw( year month day )
+ }
+ else {
+ $row->{birth_date} = undef;
+ }
}
Sql::run_in_transaction(sub {
commit dc262b5b3802120096cf118272d5d869ad80a320
Merge: 858943d f955d6f
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Mon Apr 23 15:54:26 2012 +0100
Merge branch 'master' into mbs-4337
* master:
Fix Artist::Show test now that annotations are shown in their entirity
MBS-4590: Update wikidoc links
Change warning from Controller to template
Add message in DBDefs about editable user permissions.
MBS-4038: Allow users to set permissions on development servers.
Change warning from Controller to template
Add message in DBDefs about editable user permissions.
MBS-4038: Allow users to set permissions on development servers.
diff --cc root/account/edit.tt
index e3d3226,40c593c..3653f96
--- a/root/account/edit.tt
+++ b/root/account/edit.tt
<at> <at> <at> -10,11 -10,11 +10,14 <at> <at> <at>
[%- USE r = FormRenderer(form) -%]
<form action="[% c.req.uri %]" method="post">
+ [%- IF server_details.testing_features -%]
+ [%- warning(l('This is a development server. Your email address is not private or secure. Proceed with caution!')) -%]
+ [%- END -%]
[% form_row_text_long(r, 'email', l('Email:')) %]
[% form_row_text_long(r, 'website', l('Website:')) %]
+ [% form_row_select(r, 'gender_id', l('Gender:')) %]
+ [% form_row_select(r, 'country_id', l('Country:')) %]
+ [% form_row_date(r, 'birth_date', l('Birth date:')) %]
[% WRAPPER form_row %]
[% r.label('biography', l('Bio:')) %]
[% r.textarea('biography', { cols => 80, rows => 5 }) %]
commit 858943dd3b54e85e07ad2ca4cfe496a6a8b3e5f1
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Mon Apr 23 15:51:25 2012 +0100
Default all current editors to *not* show Gravatar
diff --git a/admin/sql/updates/20120420-editor-improvements.sql b/admin/sql/updates/20120420-editor-improvements.sql
index 29b6e8b..4724604 100644
--- a/admin/sql/updates/20120420-editor-improvements.sql
+++ b/admin/sql/updates/20120420-editor-improvements.sql
<at> <at> -18,4 +18,6 <at> <at> CREATE TABLE editor_language (
CREATE INDEX editor_language_idx_language ON editor_language (language);
+INSERT INTO editor_preference (editor, name, value) SELECT id, 'show_gravatar', 0 FROM editor;
+
COMMIT;
commit ae52893bf0b20612106142798228e5bddcd5fd85
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Mon Apr 23 15:51:17 2012 +0100
Fix a typo in CreateTables
diff --git a/admin/sql/CreateTables.sql b/admin/sql/CreateTables.sql
index 1e7ff35..20a616b 100644
--- a/admin/sql/CreateTables.sql
+++ b/admin/sql/CreateTables.sql
<at> <at> -263,7 +263,7 <at> <at> CREATE TABLE editor
last_updated TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
birth_date DATE,
gender INTEGER, -- references gender.id
- country INTEGER, -- references country.id
+ country INTEGER -- references country.id
);
CREATE TYPE FLUENCY AS ENUM ('basic', 'intermediate', 'advanced', 'native');
commit 39440233b5f778dda3c91f6a97a48ca7397600a8
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Mon Apr 23 15:46:22 2012 +0100
Allow editors to edit their list of languages spoken
diff --git a/lib/MusicBrainz/Server/Controller/Account.pm b/lib/MusicBrainz/Server/Controller/Account.pm
index 4b8aaed..90215a6 100644
--- a/lib/MusicBrainz/Server/Controller/Account.pm
+++ b/lib/MusicBrainz/Server/Controller/Account.pm
<at> <at> -289,8 +289,9 <at> <at> sub edit : Local RequireAuth
}
my $editor = $c->model('Editor')->get_by_id($c->user->id);
+ $c->model('EditorLanguage')->load_for_editor($editor);
- my $form = $c->form( form => 'User::EditProfile', item => $editor );
+ my $form = $c->form( form => 'User::EditProfile', init_object => $editor );
if ($c->form_posted && $form->process( params => $c->req->params )) {
<at> <at> -312,6 +313,11 <at> <at> sub edit : Local RequireAuth
}
}
+ $c->model('EditorLanguage')->set_languages(
+ $c->user->id,
+ $form->field('languages')->value
+ );
+
$c->response->redirect($c->uri_for_action('/account/edit', \%args));
$c->detach;
}
diff --git a/lib/MusicBrainz/Server/Data/EditorLanguage.pm b/lib/MusicBrainz/Server/Data/EditorLanguage.pm
index 05a9d85..dc2b478 100644
--- a/lib/MusicBrainz/Server/Data/EditorLanguage.pm
+++ b/lib/MusicBrainz/Server/Data/EditorLanguage.pm
<at> <at> -2,6 +2,7 <at> <at> package MusicBrainz::Server::Data::EditorLanguage;
use Moose;
use namespace::autoclean;
+use List::UtilsBy qw( rev_nsort_by uniq_by );
use MusicBrainz::Server::Entity::EditorLanguage;
use MusicBrainz::Server::Data::Utils qw(
load_subobjects
<at> <at> -49,6 +50,48 <at> <at> sub load_for_editor {
$editor->add_language($_) for <at> languages;
}
+sub set_languages {
+ my ($self, $editor_id, $languages) = <at> _;
+
+ my %fluency_order = (
+ 'basic' => 1,
+ 'intermediate' => 2,
+ 'advanced' => 3,
+ 'native' => 4,
+ );
+
+ # The $languages map might have a language multiple times (ie, English-basic
+ # and English-advanced), which does make sense and violates the unique
+ # constraint in the database.
+ #
+ # For each language, we find all possible fluencys a user has specified, and
+ # take the highest fluency, where the ordering of fluencys is given by the
+ # %fluency_order mapping.
+
+ my %language_fluencys;
+ for my $language ( <at> $languages) {
+ $language_fluencys{$language->{language_id}} ||= [];
+ push <at> { $language_fluencys{$language->{language_id}} }, $language->{fluency}
+ }
+
+ for my $language_id (keys %language_fluencys) {
+ my <at> fluencys = <at> { $language_fluencys{$language_id} };
+ ($language_fluencys{ $language_id }) = rev_nsort_by { $fluency_order{$_} } <at> fluencys;
+ }
+
+ $self->c->sql->begin;
+ $self->c->sql->do('DELETE FROM editor_language WHERE editor = ?', $editor_id);
+ $self->c->sql->do(
+ 'DELETE FROM editor_language WHERE editor = ?', $editor_id
+ );
+ $self->c->sql->do(
+ 'INSERT INTO editor_language (editor, language, fluency)
+ VALUES ' . join(', ', ('(?, ?, ?)') x scalar(keys %language_fluencys)),
+ map { $editor_id, $_, $language_fluencys{$_} } keys %language_fluencys
+ );
+ $self->c->sql->commit;
+}
+
__PACKAGE__->meta->make_immutable;
no Moose;
1;
diff --git a/lib/MusicBrainz/Server/Form/User/EditProfile.pm b/lib/MusicBrainz/Server/Form/User/EditProfile.pm
index 939ca9b..9c307a3 100644
--- a/lib/MusicBrainz/Server/Form/User/EditProfile.pm
+++ b/lib/MusicBrainz/Server/Form/User/EditProfile.pm
<at> <at> -38,8 +38,31 <at> <at> has_field 'birth_date' => (
type => '+MusicBrainz::Server::Form::Field::PartialDate'
);
+has_field 'languages' => (
+ type => 'Repeatable'
+);
+
+has_field 'languages.language_id' => (
+ type => 'Select',
+ required => 1
+);
+
+has_field 'languages.fluency' => (
+ type => 'Select',
+ required => 1
+);
+
sub options_gender_id { shift->_select_all('Gender') }
sub options_country_id { shift->_select_all('Country') }
+sub options_languages_language_id { shift->_select_all('Language') }
+sub options_languages_fluency {
+ return [
+ 'basic', l('Basic'),
+ 'intermediate', l('Intermediate'),
+ 'advanced', l('Advanced'),
+ 'native', l('Native')
+ ]
+}
sub validate_birth_date {
my ($self, $field) = <at> _;
diff --git a/root/account/edit.tt b/root/account/edit.tt
index b903d74..e3d3226 100644
--- a/root/account/edit.tt
+++ b/root/account/edit.tt
<at> <at> -20,6 +20,58 <at> <at>
[% r.textarea('biography', { cols => 80, rows => 5 }) %]
[% field_errors(form, 'biography') %]
[% END %]
+
+ [% WRAPPER form_row %]
+ [% r.label('languages', l('Languages Known:'), fake => 1) %]
+ <div style="display: block; overflow: auto">
+ <ul>
+ [% FOR language=form.field('languages').fields %]
+ <li class="language">
+ [% r.select(language.field('language_id')) %]
+ [% r.select(language.field('fluency')) %]
+ <button class="remove">[% l('Remove') %]</button>
+ </li>
+ [% END %]
+ <li>
+ <button class="another">[% l('Add a language') %]</button>
+ [% extra_field = form.field('languages').field(form.field('languages').add_extra(1) - 1) %]
+ <span id="add-language-template" style="display: none">
+ [% r.select(extra_field.field('language_id'), name => '', id => '', class => 'language_id',) %]
+[% r.select(extra_field.field('fluency'), name => '', id => '', class => 'fluency') %]
+ <button class="remove">[% l('Remove') %]</button>
+ </span>
+ </li>
+ </ul>
+ </div>
+
+ [% FOR error=form.errors %]
+ [% error %]
+ [% END %]
+ [% END %]
+
+ <script>
+ $(function() {
+ var languageCount = $('li.language').size();
+ $('button.remove').live('click', function(event) {
+ event.preventDefault();
+ $(this).parent('li').remove();
+ });
+ $('button.another').click(function(event) {
+ event.preventDefault();
+
+ languageCount++;
+
+ var newLanguage = $('<li>').append($('#add-language-template').clone().contents());
+ newLanguage.find('select.language_id').attr('name',
+ 'profile.languages.' + languageCount + '.language_id');
+ newLanguage.find('select.fluency').attr('name',
+ 'profile.languages.' + languageCount + '.fluency');
+
+ $(this).parent('li').before(newLanguage);
+ });
+ });
+ </script>
+
<div class="row no-label">
[% form_submit(l('Save')) %]
</div>
diff --git a/root/static/styles/widgets.css b/root/static/styles/widgets.css
index 3f35edb..da55770 100644
--- a/root/static/styles/widgets.css
+++ b/root/static/styles/widgets.css
<at> <at> -55,8 +55,8 <at> <at>
}
/* Standard */
-.buttons a:focus, input[type=submit]:focus, button:focus,
-.buttons a:hover, input[type=submit]:hover, button:hover {
+.buttons a:focus, .buttons input[type=submit]:focus, buttons. button:focus,
+.buttons a:hover, .buttons input[type=submit]:hover, buttons. button:hover {
background-color:#dff4ff;
border:1px solid #c2e1ef;
color:#336699;
commit eb6154823c379dacaef9a04f8ed72df7a5f1f7dd
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Mon Apr 23 14:17:16 2012 +0100
Allow editing the Gravatar preference
diff --git a/lib/MusicBrainz/Server/Form/User/Preferences.pm b/lib/MusicBrainz/Server/Form/User/Preferences.pm
index 933379c..17db27b 100644
--- a/lib/MusicBrainz/Server/Form/User/Preferences.pm
+++ b/lib/MusicBrainz/Server/Form/User/Preferences.pm
<at> <at> -21,6 +21,8 <at> <at> has_field 'email_on_vote' => ( type => 'Boolean' );
has_field 'subscribe_to_created_artists' => ( type => 'Boolean' );
has_field 'subscribe_to_created_labels' => ( type => 'Boolean' );
+has_field 'show_gravatar' => ( type => 'Boolean' );
+
has_field 'subscriptions_email_period' => (
type => 'Select',
required => 1,
diff --git a/root/account/preferences.tt b/root/account/preferences.tt
index d00310d..d8b80da 100644
--- a/root/account/preferences.tt
+++ b/root/account/preferences.tt
<at> <at> -30,6 +30,7 <at> <at>
[% form_row_checkbox(r, 'public_subscriptions', l('Allow other users to see my subscriptions')) %]
[% form_row_checkbox(r, 'public_tags', l('Allow other users to see my tags')) %]
[% form_row_checkbox(r, 'public_ratings', l('Allow other users to see my ratings')) %]
+ [% form_row_checkbox(r, 'show_gravatar', l('Show my Gravatar')) %]
</fieldset>
<fieldset>
commit 5b44ced306baef51c6ea1b7442e437e237033774
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Mon Apr 23 14:05:57 2012 +0100
Display Gravatar's throughout the site
diff --git a/lib/MusicBrainz/Server.pm b/lib/MusicBrainz/Server.pm
index 73414cb..d2a6711 100644
--- a/lib/MusicBrainz/Server.pm
+++ b/lib/MusicBrainz/Server.pm
<at> <at> -56,7 +56,8 <at> <at> __PACKAGE__->config(
'format_editnote' => \&MusicBrainz::Server::Filters::format_editnote,
'uri_decode' => \&MusicBrainz::Server::Filters::uri_decode,
'language' => \&MusicBrainz::Server::Filters::language,
- 'locale' => \&MusicBrainz::Server::Filters::locale
+ 'locale' => \&MusicBrainz::Server::Filters::locale,
+ 'gravatar' => \&MusicBrainz::Server::Filters::gravatar
},
RECURSION => 1,
TEMPLATE_EXTENSION => '.tt',
diff --git a/lib/MusicBrainz/Server/Data/Editor.pm b/lib/MusicBrainz/Server/Data/Editor.pm
index dfeb73e..b9a2eb1 100644
--- a/lib/MusicBrainz/Server/Data/Editor.pm
+++ b/lib/MusicBrainz/Server/Data/Editor.pm
<at> <at> -340,6 +340,7 <at> <at> sub load
{
my ($self, <at> objs) = <at> _;
load_subobjects($self, 'editor', <at> objs);
+ $self->load_preferences(map { $_->editor } grep defined, <at> objs);
}
sub load_preferences
diff --git a/lib/MusicBrainz/Server/Entity/Preferences.pm b/lib/MusicBrainz/Server/Entity/Preferences.pm
index 4d1569c..26f14cf 100644
--- a/lib/MusicBrainz/Server/Entity/Preferences.pm
+++ b/lib/MusicBrainz/Server/Entity/Preferences.pm
<at> <at> -57,6 +57,13 <at> <at> has 'subscriptions_email_period' => (
lazy => 1,
);
+has 'show_gravatar' => (
+ isa => 'Bool',
+ default => 1,
+ is => 'rw',
+ lazy => 1
+);
+
no Moose;
__PACKAGE__->meta->make_immutable;
1;
diff --git a/lib/MusicBrainz/Server/Filters.pm b/lib/MusicBrainz/Server/Filters.pm
index 5b2755b..de6c991 100644
--- a/lib/MusicBrainz/Server/Filters.pm
+++ b/lib/MusicBrainz/Server/Filters.pm
<at> <at> -3,6 +3,7 <at> <at> package MusicBrainz::Server::Filters;
use strict;
use warnings;
+use Digest::MD5 qw( md5_hex );
use Encode;
use Locale::Language;
use MusicBrainz::Server::Track;
<at> <at> -202,4 +203,9 <at> <at> sub locale
}
}
+sub gravatar {
+ my $email = shift;
+ return sprintf 'http://gravatar.com/avatar/%s?d=mm', md5_hex($email);
+}
+
1;
diff --git a/root/components/common-macros.tt b/root/components/common-macros.tt
index 95ac1b9..d72b213 100644
--- a/root/components/common-macros.tt
+++ b/root/components/common-macros.tt
<at> <at> -312,11 +312,20 <at> <at> END -%]
'<a href="' _ link _ '">' _ text _ '</a>';
END -%]
+[%- MACRO gravatar(email) FILTER gravatar; email; END %]
+
[%- MACRO link_editor(editor, action, text) BLOCK;
action = action || 'profile';
link = c.uri_for_action("/user/$action", [ editor.name ]);
text = text == '' ? html_escape(editor.name) : text;
- '<a href="' _ link _ '">' _ text _ '</a>';
+ '<a href="' _ link _ '">';
+ IF editor.preferences.show_gravatar;
+ '<img src="' _ gravatar(editor.email) _ '" class="gravatar"> ';
+ ELSE;
+ '<img src="http://gravatar.com/avatar/placeholder?d=mm" class="gravatar"> ';
+ END;
+ text;
+ '</a>';
END -%]
[%- MACRO link_edit(edit, action, text) BLOCK;
diff --git a/root/static/styles/edit.css b/root/static/styles/edit.css
index bcb2b4a..2cb07dc 100644
--- a/root/static/styles/edit.css
+++ b/root/static/styles/edit.css
<at> <at> -103,21 +103,10 <at> <at> table.vote-tally .date {
.edit-notes .edit-note h3 {
font-weight: normal;
- background-image: url('../images/icons/user.png');
- background-repeat: no-repeat;
- background-position: 5px 50%;
background-color: #EAEAEA;
height: 16px;
margin: 0 0 10px;
- padding: 5px 10px 5px 26px;
-}
-
-.edit-notes .edit-note h3.Yes {
- background-image: url('../images/icons/user_add.png');
-}
-
-.edit-notes .edit-note h3.No {
- background-image: url('../images/icons/user_delete.png');
+ padding: 5px 10px 5px 10px;
}
.edit-notes .edit-note h3.owner {
diff --git a/root/static/styles/layout.css b/root/static/styles/layout.css
index c36fd74..4009cf6 100644
--- a/root/static/styles/layout.css
+++ b/root/static/styles/layout.css
<at> <at> -103,6 +103,21 <at> <at> pre code {
width: 100%;
}
+#header img.gravatar { display: none; }
+
+img.gravatar {
+ display: inline;
+ max-height: 1em;
+ vertical-align: middle;
+ border: 1px solid #ddd;
+ padding: 1px;
+ background: #fff
+}
+
+h1 img.gravatar {
+ max-height: 3em;
+}
+
#header-logo {
background: #736DAB url('../images/layout/sprites.png') no-repeat top left;
height: 58px;
diff --git a/root/user/profile/layout.tt b/root/user/profile/layout.tt
index 44e1e8b..b30dae1 100644
--- a/root/user/profile/layout.tt
+++ b/root/user/profile/layout.tt
<at> <at> -5,7 +5,7 <at> <at>
: l("Editor “{user}”", { user => html_escape(user.name) })
-%]
- <h1>[% l("Editor “{user}”", { user => link_entity(user) }) %]</h1>
+ <h1>[% l("{user}", { user => link_entity(user) }) %]</h1>
[% MACRO generic_link(url, text) BLOCK %]<a href="[% url %]">[% text %]</a>[% END %]
commit 73725807c790276981093987577c42e6b320167c
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri Apr 20 17:37:03 2012 +0100
Show languages a user speaks on their profile page
diff --git a/lib/MusicBrainz/Server/Controller/User.pm b/lib/MusicBrainz/Server/Controller/User.pm
index 4b920ba..a284f4a 100644
--- a/lib/MusicBrainz/Server/Controller/User.pm
+++ b/lib/MusicBrainz/Server/Controller/User.pm
<at> <at> -308,6 +308,7 <at> <at> sub profile : Chained('load') PathPart('') HiddenOnSlaves
$c->model('Gender')->load($user);
$c->model('Country')->load($user);
+ $c->model('EditorLanguage')->load_for_editor($user);
$c->stash(
user => $user,
diff --git a/lib/MusicBrainz/Server/Data/EditorLanguage.pm b/lib/MusicBrainz/Server/Data/EditorLanguage.pm
new file mode 100644
index 0000000..05a9d85
--- /dev/null
+++ b/lib/MusicBrainz/Server/Data/EditorLanguage.pm
<at> <at> -0,0 +1,74 <at> <at>
+package MusicBrainz::Server::Data::EditorLanguage;
+
+use Moose;
+use namespace::autoclean;
+use MusicBrainz::Server::Entity::EditorLanguage;
+use MusicBrainz::Server::Data::Utils qw(
+ load_subobjects
+ query_to_list
+);
+
+extends 'MusicBrainz::Server::Data::Entity';
+
+sub _table
+{
+ return 'editor_language JOIN language ON language.id = editor_language.language';
+}
+
+sub _columns
+{
+ return 'language.*, editor, fluency, language AS language_id';
+}
+
+sub _new_from_row {
+ my ($self, $row) = <at> _;
+
+ return MusicBrainz::Server::Entity::EditorLanguage->new(
+ editor_id => $row->{editor},
+ fluency => $row->{fluency},
+ language => $self->c->model('Language')->_new_from_row($row),
+ language_id => $row->{language_id}
+ );
+}
+
+sub _entity_class
+{
+ return 'MusicBrainz::Server::Entity::EditorLanguage';
+}
+
+sub load_for_editor {
+ my ($self, $editor) = <at> _;
+
+ my <at> languages = query_to_list(
+ $self->sql, sub { $self->_new_from_row( <at> _) },
+ 'SELECT ' . $self->_columns . ' FROM ' . $self->_table .
+ ' WHERE editor = ?' .
+ ' ORDER BY musicbrainz_collate(language.name)', $editor->id
+ );
+
+ $editor->add_language($_) for <at> languages;
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+1;
+
+=head1 COPYRIGHT
+
+Copyright (C) 2012 MetaBrainz Foundation
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+=cut
diff --git a/lib/MusicBrainz/Server/Entity/Editor.pm b/lib/MusicBrainz/Server/Entity/Editor.pm
index 2cd4dda..d15cb2b 100644
--- a/lib/MusicBrainz/Server/Entity/Editor.pm
+++ b/lib/MusicBrainz/Server/Entity/Editor.pm
<at> <at> -177,6 +177,16 <at> <at> sub age {
return (DateTime->now - $self->birth_date)->in_units('years');
}
+has languages => (
+ isa => 'ArrayRef',
+ is => 'rw',
+ default => sub { [] },
+ traits => [ 'Array' ],
+ handles => {
+ add_language => 'push',
+ }
+);
+
no Moose;
__PACKAGE__->meta->make_immutable;
1;
diff --git a/lib/MusicBrainz/Server/Entity/EditorLanguage.pm b/lib/MusicBrainz/Server/Entity/EditorLanguage.pm
new file mode 100644
index 0000000..d877492
--- /dev/null
+++ b/lib/MusicBrainz/Server/Entity/EditorLanguage.pm
<at> <at> -0,0 +1,43 <at> <at>
+package MusicBrainz::Server::Entity::EditorLanguage;
+use Moose;
+use namespace::autoclean;
+
+has 'editor_id' => (
+ is => 'rw',
+);
+
+has 'language_id' => (
+ is => 'rw',
+);
+
+has 'language' => (
+ is => 'rw',
+);
+
+has 'fluency' => (
+ is => 'rw',
+);
+
+
+__PACKAGE__->meta->make_immutable;
+1;
+
+=head1 COPYRIGHT
+
+Copyright (C) 2012 MetaBrainz Foundation
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+=cut
diff --git a/root/user/profile.tt b/root/user/profile.tt
index 1629133..e966e2b 100644
--- a/root/user/profile.tt
+++ b/root/user/profile.tt
<at> <at> -112,6 +112,16 <at> <at>
[% html_escape(user.biography or l("(none)")).split("\n").join("<br />") %]
[% END %]
+ [% IF user.languages.size %]
+ [% WRAPPER property name=l('Languages:') %]
+ <ul>
+ [% FOR language=user.languages %]
+ <li>[% language.language.name %] ([% language.fluency %])</li>
+ [% END %]
+ </ul>
+ [% END %]
+ [% END %]
+
[% END %]
</dl>
commit 4a54dac1a0fd1d53f029fa29be9a6b912a949529
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri Apr 20 16:36:38 2012 +0100
Display a users age, country and gender on profile pages
diff --git a/lib/MusicBrainz/Server/Controller/User.pm b/lib/MusicBrainz/Server/Controller/User.pm
index e1af59e..4b920ba 100644
--- a/lib/MusicBrainz/Server/Controller/User.pm
+++ b/lib/MusicBrainz/Server/Controller/User.pm
<at> <at> -306,6 +306,9 <at> <at> sub profile : Chained('load') PathPart('') HiddenOnSlaves
$c->stash->{subscriber_count} = $subscr_model->get_subscribed_editor_count($user->id);
$c->stash->{votes} = $c->model('Vote')->editor_statistics($user->id);
+ $c->model('Gender')->load($user);
+ $c->model('Country')->load($user);
+
$c->stash(
user => $user,
template => 'user/profile.tt',
diff --git a/lib/MusicBrainz/Server/Entity/Editor.pm b/lib/MusicBrainz/Server/Entity/Editor.pm
index 023dccb..2cd4dda 100644
--- a/lib/MusicBrainz/Server/Entity/Editor.pm
+++ b/lib/MusicBrainz/Server/Entity/Editor.pm
<at> <at> -1,6 +1,7 <at> <at>
package MusicBrainz::Server::Entity::Editor;
use Moose;
+use DateTime;
use MusicBrainz::Server::Entity::Preferences;
use MusicBrainz::Server::Types qw( :privileges );
<at> <at> -170,6 +171,12 <at> <at> has country => (
is => 'rw',
);
+sub age {
+ my $self = shift;
+ return unless $self->birth_date;
+ return (DateTime->now - $self->birth_date)->in_units('years');
+}
+
no Moose;
__PACKAGE__->meta->make_immutable;
1;
diff --git a/root/user/profile.tt b/root/user/profile.tt
index 54accca..1629133 100644
--- a/root/user/profile.tt
+++ b/root/user/profile.tt
<at> <at> -54,6 +54,24 <at> <at>
[% END %]
+ [% IF user.age;
+ WRAPPER property name=l('Age:');
+ user.age;
+ END;
+ END; %]
+
+ [% IF user.gender;
+ WRAPPER property name=l('Gender:');
+ user.gender.name;
+ END;
+ END; %]
+
+ [% IF user.country;
+ WRAPPER property name=l('Country:');
+ user.country.name;
+ END;
+ END; %]
+
[% WRAPPER property name=l("Member since:") %]
[% IF user.name == "rob" %]
[% l('The Dawn of the Project') %]
commit 44be54089b1fc97648c8a62a1645072848a6505d
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri Apr 20 16:08:28 2012 +0100
Allow editor's to set their gender, country and birth date
diff --git a/lib/MusicBrainz/Server/Controller/Account.pm b/lib/MusicBrainz/Server/Controller/Account.pm
index c8974bc..4b8aaed 100644
--- a/lib/MusicBrainz/Server/Controller/Account.pm
+++ b/lib/MusicBrainz/Server/Controller/Account.pm
<at> <at> -294,9 +294,10 <at> <at> sub edit : Local RequireAuth
if ($c->form_posted && $form->process( params => $c->req->params )) {
- $c->model('Editor')->update_profile($editor,
- $form->field('website')->value,
- $form->field('biography')->value);
+ $c->model('Editor')->update_profile(
+ $editor,
+ $form->value
+ );
my %args = ( ok => 1 );
my $old_email = $editor->email || '';
diff --git a/lib/MusicBrainz/Server/Controller/Admin.pm b/lib/MusicBrainz/Server/Controller/Admin.pm
index 875d3db..5d30ac8 100644
--- a/lib/MusicBrainz/Server/Controller/Admin.pm
+++ b/lib/MusicBrainz/Server/Controller/Admin.pm
<at> <at> -50,8 +50,7 <at> <at> sub edit_user : Path('/admin/user/edit') Args(1) RequireAuth(account_admin) Hidd
if ($form2->submitted_and_valid ($c->req->params )) {
$c->model('Editor')->update_profile(
$user,
- $form2->field('website')->value,
- $form2->field('biography')->value
+ $form2->value
);
my %args = ( ok => 1 );
diff --git a/lib/MusicBrainz/Server/Data/Editor.pm b/lib/MusicBrainz/Server/Data/Editor.pm
index b1084b2..dfeb73e 100644
--- a/lib/MusicBrainz/Server/Data/Editor.pm
+++ b/lib/MusicBrainz/Server/Data/Editor.pm
<at> <at> -8,6 +8,7 <at> <at> use DateTime;
use MusicBrainz::Server::Entity::Preferences;
use MusicBrainz::Server::Entity::Editor;
use MusicBrainz::Server::Data::Utils qw(
+ hash_to_row
load_subobjects
placeholders
query_to_list
<at> <at> -33,7 +34,8 <at> <at> sub _columns
{
return 'editor.id, editor.name, password, privs, email, website, bio,
member_since, email_confirm_date, last_login_date, edits_accepted,
- edits_rejected, auto_edits_accepted, edits_failed';
+ edits_rejected, auto_edits_accepted, edits_failed, gender, country,
+ birth_date';
}
sub _column_mapping
<at> <at> -53,6 +55,9 <at> <at> sub _column_mapping
email_confirmation_date => 'email_confirm_date',
registration_date => 'member_since',
last_login_date => 'last_login_date',
+ gender_id => 'gender',
+ country_id => 'country',
+ birth_date => 'birth_date'
};
}
<at> <at> -282,11 +287,25 <at> <at> sub update_password
sub update_profile
{
- my ($self, $editor, $website, $bio) = <at> _;
+ my ($self, $editor, $update) = <at> _;
+
+ my $row = hash_to_row(
+ $update,
+ {
+ bio => 'biography',
+ country => 'country_id',
+ gender => 'gender_id',
+ website => 'website',
+ birth_date => 'birth_date',
+ }
+ );
+
+ if (my $date = delete $row->{birth_date}) {
+ $row->{birth_date} = sprintf '%d-%d-%d', map { $date->{$_} } qw( year month day );
+ }
Sql::run_in_transaction(sub {
- $self->sql->do('UPDATE editor SET website=?, bio=? WHERE id=?',
- $website || undef, $bio || undef, $editor->id);
+ $self->sql->update_row('editor', $row, { id => $editor->id });
}, $self->sql);
}
diff --git a/lib/MusicBrainz/Server/Entity/Editor.pm b/lib/MusicBrainz/Server/Entity/Editor.pm
index 9a10c7a..023dccb 100644
--- a/lib/MusicBrainz/Server/Entity/Editor.pm
+++ b/lib/MusicBrainz/Server/Entity/Editor.pm
<at> <at> -146,6 +146,30 <at> <at> sub is_limited
$self->accepted_edits < 10;
}
+has birth_date => (
+ is => 'rw',
+ isa => 'DateTime',
+ coerce => 1
+);
+
+has gender_id => (
+ is => 'rw',
+ isa => 'Int',
+);
+
+has gender => (
+ is => 'rw',
+);
+
+has country_id => (
+ is => 'rw',
+ isa => 'Int',
+);
+
+has country => (
+ is => 'rw',
+);
+
no Moose;
__PACKAGE__->meta->make_immutable;
1;
diff --git a/lib/MusicBrainz/Server/Form/User/EditProfile.pm b/lib/MusicBrainz/Server/Form/User/EditProfile.pm
index ec4b8d8..939ca9b 100644
--- a/lib/MusicBrainz/Server/Form/User/EditProfile.pm
+++ b/lib/MusicBrainz/Server/Form/User/EditProfile.pm
<at> <at> -1,6 +1,7 <at> <at>
package MusicBrainz::Server::Form::User::EditProfile;
use HTML::FormHandler::Moose;
+use List::MoreUtils qw( any all );
use MusicBrainz::Server::Translation qw( l ln );
use MusicBrainz::Server::Validation;
<at> <at> -25,6 +26,30 <at> <at> has_field 'email' => (
type => 'Email',
);
+has_field 'gender_id' => (
+ type => 'Select',
+);
+
+has_field 'country_id' => (
+ type => 'Select',
+);
+
+has_field 'birth_date' => (
+ type => '+MusicBrainz::Server::Form::Field::PartialDate'
+);
+
+sub options_gender_id { shift->_select_all('Gender') }
+sub options_country_id { shift->_select_all('Country') }
+
+sub validate_birth_date {
+ my ($self, $field) = <at> _;
+ my <at> date_components = values %{ $field->value };
+ if ((any { defined } <at> date_components) &&
+ !(all { defined } <at> date_components)) {
+ return $field->add_error(l('You must supply a complete birth date'));
+ }
+}
+
1;
=head1 COPYRIGHT
diff --git a/root/account/edit.tt b/root/account/edit.tt
index e9999ec..b903d74 100644
--- a/root/account/edit.tt
+++ b/root/account/edit.tt
<at> <at> -12,6 +12,9 <at> <at>
<form action="[% c.req.uri %]" method="post">
[% form_row_text_long(r, 'email', l('Email:')) %]
[% form_row_text_long(r, 'website', l('Website:')) %]
+ [% form_row_select(r, 'gender_id', l('Gender:')) %]
+ [% form_row_select(r, 'country_id', l('Country:')) %]
+ [% form_row_date(r, 'birth_date', l('Birth date:')) %]
[% WRAPPER form_row %]
[% r.label('biography', l('Bio:')) %]
[% r.textarea('biography', { cols => 80, rows => 5 }) %]
commit 44bb022a93fabae6eab9e36318f79cc5dfcaea08
Author: Oliver Charles <oliver.g.charles <at> googlemail.com>
Date: Fri Apr 20 15:14:44 2012 +0100
Add the new schema for editors
diff --git a/admin/sql/CreateFKConstraints.sql b/admin/sql/CreateFKConstraints.sql
index a846628..e5a34a4 100644
--- a/admin/sql/CreateFKConstraints.sql
+++ b/admin/sql/CreateFKConstraints.sql
<at> <at> -246,6 +246,16 <at> <at> ALTER TABLE edit_work
REFERENCES work(id)
ON DELETE CASCADE;
+ALTER TABLE editor
+ ADD CONSTRAINT editor_fk_gender
+ FOREIGN KEY (gender)
+ REFERENCES gender(id);
+
+ALTER TABLE editor
+ ADD CONSTRAINT editor_fk_country
+ FOREIGN KEY (country)
+ REFERENCES country(id);
+
ALTER TABLE editor_collection
ADD CONSTRAINT editor_collection_fk_editor
FOREIGN KEY (editor)
<at> <at> -261,6 +271,16 <at> <at> ALTER TABLE editor_collection_release
FOREIGN KEY (release)
REFERENCES release(id);
+ALTER TABLE editor_language
+ ADD CONSTRAINT editor_language_fk_editor
+ FOREIGN KEY (editor)
+ REFERENCES editor(id);
+
+ALTER TABLE editor_language
+ ADD CONSTRAINT editor_language_fk_language
+ FOREIGN KEY (language)
+ REFERENCES language(id);
+
ALTER TABLE editor_preference
ADD CONSTRAINT editor_preference_fk_editor
FOREIGN KEY (editor)
diff --git a/admin/sql/CreateIndexes.sql b/admin/sql/CreateIndexes.sql
index 276a9f7..6f680db 100644
--- a/admin/sql/CreateIndexes.sql
+++ b/admin/sql/CreateIndexes.sql
<at> <at> -31,6 +31,7 <at> <at> CREATE UNIQUE INDEX cdtoc_raw_toc ON cdtoc_raw (track_count, leadout_offset, tra
CREATE UNIQUE INDEX country_idx_iso_code ON country (iso_code);
CREATE UNIQUE INDEX editor_idx_name ON editor (LOWER(name));
+CREATE INDEX editor_language_idx_language ON editor_language (language);
CREATE UNIQUE INDEX editor_preference_idx_editor_name ON editor_preference (editor, name);
diff --git a/admin/sql/CreatePrimaryKeys.sql b/admin/sql/CreatePrimaryKeys.sql
index 7f19b6b..653d76d 100644
--- a/admin/sql/CreatePrimaryKeys.sql
+++ b/admin/sql/CreatePrimaryKeys.sql
<at> <at> -32,6 +32,7 <at> <at> ALTER TABLE edit_work ADD CONSTRAINT edit_work_pkey PRIMARY KEY (edit, work);
ALTER TABLE editor ADD CONSTRAINT editor_pkey PRIMARY KEY (id);
ALTER TABLE editor_collection ADD CONSTRAINT editor_collection_pkey PRIMARY KEY (id);
ALTER TABLE editor_collection_release ADD CONSTRAINT editor_collection_release_pkey PRIMARY KEY (collection, release);
+ALTER TABLE editor_language ADD CONSTRAINT editor_language_pkey PRIMARY KEY (editor, language);
ALTER TABLE editor_preference ADD CONSTRAINT editor_preference_pkey PRIMARY KEY (id);
ALTER TABLE editor_subscribe_artist ADD CONSTRAINT editor_subscribe_artist_pkey PRIMARY KEY (id);
ALTER TABLE editor_subscribe_editor ADD CONSTRAINT editor_subscribe_editor_pkey PRIMARY KEY (id);
diff --git a/admin/sql/CreateTables.sql b/admin/sql/CreateTables.sql
index 91daa60..1e7ff35 100644
--- a/admin/sql/CreateTables.sql
+++ b/admin/sql/CreateTables.sql
<at> <at> -258,9 +258,20 <at> <at> CREATE TABLE editor
last_login_date TIMESTAMP WITH TIME ZONE,
edits_accepted INTEGER DEFAULT 0,
edits_rejected INTEGER DEFAULT 0,
- auto_edits_accepted INTEGER DEFAULT 0,
+ auto_edits_accepted INTEGER DEFAULT 0,
edits_failed INTEGER DEFAULT 0,
- last_updated TIMESTAMP WITH TIME ZONE DEFAULT NOW()
+ last_updated TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
+ birth_date DATE,
+ gender INTEGER, -- references gender.id
+ country INTEGER, -- references country.id
+);
+
+CREATE TYPE FLUENCY AS ENUM ('basic', 'intermediate', 'advanced', 'native');
+
+CREATE TABLE editor_language (
+ editor INTEGER NOT NULL, -- PK, references editor.id
+ language INTEGER NOT NULL, -- PK, references language.id
+ fluency FLUENCY NOT NULL
);
CREATE TABLE editor_preference
diff --git a/admin/sql/DropFKConstraints.sql b/admin/sql/DropFKConstraints.sql
index 75b3e21..c33ae57 100644
--- a/admin/sql/DropFKConstraints.sql
+++ b/admin/sql/DropFKConstraints.sql
<at> <at> -48,9 +48,13 <at> <at> ALTER TABLE edit_url DROP CONSTRAINT edit_url_fk_edit;
ALTER TABLE edit_url DROP CONSTRAINT edit_url_fk_url;
ALTER TABLE edit_work DROP CONSTRAINT edit_work_fk_edit;
ALTER TABLE edit_work DROP CONSTRAINT edit_work_fk_work;
+ALTER TABLE editor DROP CONSTRAINT editor_fk_gender;
+ALTER TABLE editor DROP CONSTRAINT editor_fk_country;
ALTER TABLE editor_collection DROP CONSTRAINT editor_collection_fk_editor;
ALTER TABLE editor_collection_release DROP CONSTRAINT editor_collection_release_fk_collection;
ALTER TABLE editor_collection_release DROP CONSTRAINT editor_collection_release_fk_release;
+ALTER TABLE editor_language DROP CONSTRAINT editor_language_fk_editor;
+ALTER TABLE editor_language DROP CONSTRAINT editor_language_fk_language;
ALTER TABLE editor_preference DROP CONSTRAINT editor_preference_fk_editor;
ALTER TABLE editor_subscribe_artist DROP CONSTRAINT editor_subscribe_artist_fk_editor;
ALTER TABLE editor_subscribe_editor DROP CONSTRAINT editor_subscribe_editor_fk_editor;
diff --git a/admin/sql/DropIndexes.sql b/admin/sql/DropIndexes.sql
index ccc5bf4..c4e7abb 100644
--- a/admin/sql/DropIndexes.sql
+++ b/admin/sql/DropIndexes.sql
<at> <at> -42,6 +42,7 <at> <at> DROP INDEX editor_collection_idx_editor;
DROP INDEX editor_collection_idx_gid;
DROP INDEX editor_collection_idx_name;
DROP INDEX editor_idx_name;
+DROP INDEX editor_language_idx_language;
DROP INDEX editor_preference_idx_editor_name;
DROP INDEX editor_subscribe_artist_idx_artist;
DROP INDEX editor_subscribe_artist_idx_uniq;
diff --git a/admin/sql/DropPrimaryKeys.sql b/admin/sql/DropPrimaryKeys.sql
index 69a5cf8..ab893f6 100644
--- a/admin/sql/DropPrimaryKeys.sql
+++ b/admin/sql/DropPrimaryKeys.sql
<at> <at> -32,6 +32,7 <at> <at> ALTER TABLE edit_work DROP CONSTRAINT edit_work_pkey;
ALTER TABLE editor DROP CONSTRAINT editor_pkey;
ALTER TABLE editor_collection DROP CONSTRAINT editor_collection_pkey;
ALTER TABLE editor_collection_release DROP CONSTRAINT editor_collection_release_pkey;
+ALTER TABLE editor_language DROP CONSTRAINT editor_language_pkey;
ALTER TABLE editor_preference DROP CONSTRAINT editor_preference_pkey;
ALTER TABLE editor_subscribe_artist DROP CONSTRAINT editor_subscribe_artist_pkey;
ALTER TABLE editor_subscribe_editor DROP CONSTRAINT editor_subscribe_editor_pkey;
diff --git a/admin/sql/DropTables.sql b/admin/sql/DropTables.sql
index 74e5475..dfebd09 100644
--- a/admin/sql/DropTables.sql
+++ b/admin/sql/DropTables.sql
<at> <at> -32,6 +32,7 <at> <at> DROP TABLE edit_work;
DROP TABLE editor;
DROP TABLE editor_collection;
DROP TABLE editor_collection_release;
+DROP TABLE editor_language;
DROP TABLE editor_preference;
DROP TABLE editor_subscribe_artist;
DROP TABLE editor_subscribe_editor;
diff --git a/admin/sql/updates/20120420-editor-improvements.sql b/admin/sql/updates/20120420-editor-improvements.sql
new file mode 100644
index 0000000..29b6e8b
--- /dev/null
+++ b/admin/sql/updates/20120420-editor-improvements.sql
<at> <at> -0,0 +1,21 <at> <at>
+BEGIN;
+
+ALTER TABLE editor ADD COLUMN birth_date DATE;
+ALTER TABLE editor ADD COLUMN gender INTEGER;
+ALTER TABLE editor ADD COLUMN country INTEGER;
+
+ALTER TABLE editor ADD CONSTRAINT editor_fk_gender FOREIGN KEY (gender) REFERENCES gender (id);
+ALTER TABLE editor ADD CONSTRAINT editor_fk_country FOREIGN KEY (country) REFERENCES country (id);
+
+CREATE TYPE FLUENCY AS ENUM ('basic', 'intermediate', 'advanced', 'native');
+
+CREATE TABLE editor_language (
+ editor INTEGER NOT NULL REFERENCES editor (id),
+ language INTEGER NOT NULL REFERENCES language (id),
+ fluency FLUENCY NOT NULL,
+ PRIMARY KEY (editor, language)
+);
+
+CREATE INDEX editor_language_idx_language ON editor_language (language);
+
+COMMIT;
-----------------------------------------------------------------------
hooks/post-receive
--
--
mb_server
_______________________________________________
MusicBrainz-commits mailing list
MusicBrainz-commits <at> lists.musicbrainz.org
http://lists.musicbrainz.org/mailman/listinfo/musicbrainz-commits
RSS Feed