Add a country column to users
[gruntmaster-data.git] / lib / Gruntmaster / Data / Result / User.pm
CommitLineData
4ed3f8e7
MG
1use utf8;
2package Gruntmaster::Data::Result::User;
3
4# Created by DBIx::Class::Schema::Loader
5# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7=head1 NAME
8
be2f7678 9Gruntmaster::Data::Result::User - List of users
4ed3f8e7
MG
10
11=cut
12
13use strict;
14use warnings;
15
16use base 'DBIx::Class::Core';
17
18=head1 TABLE: C<users>
19
20=cut
21
22__PACKAGE__->table("users");
23
24=head1 ACCESSORS
25
26=head2 id
27
28 data_type: 'text'
29 is_nullable: 0
30
2fec2d56
MG
31=head2 passphrase
32
33 data_type: 'text'
9bb39921 34 is_nullable: 1
2fec2d56 35
be2f7678
MG
36RFC2307-encoded passphrase
37
2fec2d56
MG
38=head2 admin
39
40 data_type: 'boolean'
41 default_value: false
42 is_nullable: 0
43
4ed3f8e7
MG
44=head2 name
45
46 data_type: 'text'
47 is_nullable: 1
48
be2f7678
MG
49Full name of user
50
4ed3f8e7
MG
51=head2 email
52
53 data_type: 'text'
54 is_nullable: 1
55
85d3f015
MG
56=head2 phone
57
58 data_type: 'text'
59 is_nullable: 1
60
4ed3f8e7
MG
61=head2 town
62
63 data_type: 'text'
64 is_nullable: 1
65
66=head2 university
67
68 data_type: 'text'
69 is_nullable: 1
70
71=head2 level
72
73 data_type: 'text'
74 is_nullable: 1
75
be2f7678
MG
76Highschool, Undergraduate, Master, Doctorate or Other
77
73243865
MG
78=head2 country
79
80 data_type: 'text'
81 is_nullable: 1
82
4ed3f8e7
MG
83=head2 lastjob
84
85 data_type: 'bigint'
86 is_nullable: 1
87
be2f7678
MG
88Unix time when this user last submitted a job
89
4ed3f8e7
MG
90=cut
91
92__PACKAGE__->add_columns(
93 "id",
94 { data_type => "text", is_nullable => 0 },
2fec2d56 95 "passphrase",
9bb39921 96 { data_type => "text", is_nullable => 1 },
2fec2d56
MG
97 "admin",
98 { data_type => "boolean", default_value => \"false", is_nullable => 0 },
4ed3f8e7
MG
99 "name",
100 { data_type => "text", is_nullable => 1 },
101 "email",
102 { data_type => "text", is_nullable => 1 },
85d3f015
MG
103 "phone",
104 { data_type => "text", is_nullable => 1 },
4ed3f8e7
MG
105 "town",
106 { data_type => "text", is_nullable => 1 },
107 "university",
108 { data_type => "text", is_nullable => 1 },
109 "level",
110 { data_type => "text", is_nullable => 1 },
73243865
MG
111 "country",
112 { data_type => "text", is_nullable => 1 },
4ed3f8e7
MG
113 "lastjob",
114 { data_type => "bigint", is_nullable => 1 },
115);
116
117=head1 PRIMARY KEY
118
119=over 4
120
121=item * L</id>
122
123=back
124
125=cut
126
127__PACKAGE__->set_primary_key("id");
128
129=head1 RELATIONS
130
adb42d4d
MG
131=head2 contest_statuses
132
133Type: has_many
134
135Related object: L<Gruntmaster::Data::Result::ContestStatus>
136
137=cut
138
139__PACKAGE__->has_many(
140 "contest_statuses",
141 "Gruntmaster::Data::Result::ContestStatus",
142 { "foreign.owner" => "self.id" },
143 { cascade_copy => 0, cascade_delete => 0 },
144);
145
4ed3f8e7
MG
146=head2 contests
147
148Type: has_many
149
150Related object: L<Gruntmaster::Data::Result::Contest>
151
152=cut
153
154__PACKAGE__->has_many(
155 "contests",
156 "Gruntmaster::Data::Result::Contest",
157 { "foreign.owner" => "self.id" },
158 { cascade_copy => 0, cascade_delete => 0 },
159);
160
161=head2 jobs
162
163Type: has_many
164
165Related object: L<Gruntmaster::Data::Result::Job>
166
167=cut
168
169__PACKAGE__->has_many(
170 "jobs",
171 "Gruntmaster::Data::Result::Job",
172 { "foreign.owner" => "self.id" },
173 { cascade_copy => 0, cascade_delete => 0 },
174);
175
176=head2 opens
177
178Type: has_many
179
180Related object: L<Gruntmaster::Data::Result::Open>
181
182=cut
183
184__PACKAGE__->has_many(
185 "opens",
186 "Gruntmaster::Data::Result::Open",
187 { "foreign.owner" => "self.id" },
188 { cascade_copy => 0, cascade_delete => 0 },
189);
190
adb42d4d
MG
191=head2 problem_statuses
192
193Type: has_many
194
195Related object: L<Gruntmaster::Data::Result::ProblemStatus>
196
197=cut
198
199__PACKAGE__->has_many(
200 "problem_statuses",
201 "Gruntmaster::Data::Result::ProblemStatus",
202 { "foreign.owner" => "self.id" },
203 { cascade_copy => 0, cascade_delete => 0 },
204);
205
4ed3f8e7
MG
206=head2 problems
207
208Type: has_many
209
210Related object: L<Gruntmaster::Data::Result::Problem>
211
212=cut
213
214__PACKAGE__->has_many(
215 "problems",
216 "Gruntmaster::Data::Result::Problem",
217 { "foreign.owner" => "self.id" },
218 { cascade_copy => 0, cascade_delete => 0 },
219);
220
221
73243865
MG
222# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-01-29 18:45:35
223# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rpx697B3St+ICCSbOn4cbQ
4ed3f8e7 224
de7226ca
MG
225use Class::Method::Modifiers qw/after/;
226
227after qw/insert update delete/ => sub {
228 my ($self) = @_;
229 Gruntmaster::Data::purge '/us/';
230 Gruntmaster::Data::purge '/us/' . $self->id;
231};
232
de625c9b
MG
233use Authen::Passphrase;
234use Authen::Passphrase::BlowfishCrypt;
235
236sub check_passphrase {
237 my ($self, $pw) = @_;
238 Authen::Passphrase->from_rfc2307($self->passphrase)->match($pw)
239}
240
241sub set_passphrase {
242 my ($self, $pw) = @_;
243 $self->update({passphrase => Authen::Passphrase::BlowfishCrypt->new(
244 cost => 10,
245 passphrase => $pw,
246 salt_random => 1,
526b9e80 247 )->as_rfc2307});
de625c9b 248}
4ed3f8e7 249
4ed3f8e7 2501;
4a8747ef
MG
251
252__END__
253
de625c9b
MG
254=head1 METHODS
255
256=head2 check_passphrase(I<$passphrase>)
257
258Returns true if I<$passphrase> is the correct passphrase, false otherwise.
259
260=head2 set_passphrase(I<$passphrase>)
261
262Changes the passphrase to I<$passphrase>.
263
4a8747ef
MG
264=head1 AUTHOR
265
266Marius Gavrilescu E<lt>marius@ieval.roE<gt>
267
268=head1 COPYRIGHT AND LICENSE
269
270Copyright (C) 2014 by Marius Gavrilescu
271
272This library is free software; you can redistribute it and/or modify
273it under the same terms as Perl itself, either Perl version 5.18.1 or,
274at your option, any later version of Perl 5 you may have available.
275
276
277=cut
This page took 0.028458 seconds and 4 git commands to generate.