Skip to content

Commit

Permalink
Added more feilds to student
Browse files Browse the repository at this point in the history
  • Loading branch information
kthakore committed Nov 10, 2010
1 parent 6326a32 commit 89047cb
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 12 deletions.
2 changes: 1 addition & 1 deletion implementation/SIMS/SIMS/INSTALL
Expand Up @@ -2,4 +2,4 @@ PERL_MM_USE_DEFAULT=1 cpan Catalyst::Devel
sqlite3 sims.db < sims.sql
cpan Catalyst::Helper::Model::DBIC::Schema
script/sims_create.pl model DB DBIC::Schema SIMS::Schema \
create=static 'dbi:SQLite;dbname=sims.db' '' ''
create=static 'dbi:SQLite:dbname=sims.db' '' ''
28 changes: 19 additions & 9 deletions implementation/SIMS/SIMS/lib/SIMS/Controller/Student.pm
Expand Up @@ -2,7 +2,7 @@ package SIMS::Controller::Student;
use Moose;
use namespace::autoclean;

BEGIN {extends 'Catalyst::Controller'; }
BEGIN { extends 'Catalyst::Controller'; }

=head1 NAME
Expand All @@ -16,24 +16,34 @@ Catalyst Controller.
=cut


=head2 Collection
Show all students in the current DB
=cut

sub collection :Chained('/base') PathPart('student') CaptureArgs(0) { my($self, $c) = @_; $c->stash->{collection} = $c->model('DB::Student') };
sub collection : Chained('/base') PathPart('student') CaptureArgs(0) {
my ( $self, $c ) = @_;
$c->stash->{collection} = $c->model('DB::Student');
}

sub view_collection : Chained('collection') Args(0) PathPart('') {
}

=head2 Object
Operations on a single student by id
sub view_collection :Chained('collection') Args(0) PathPart('') {}
=cut

sub object :Chained('collection') CaptureArgs(1) {
my($self, $c, $id) = @_;
$c->stash->{student} = $c->model('DB::Student')->find($id);
sub object : Chained('collection') PathPart('') CaptureArgs(1) {
my ( $self, $c, $id ) = @_;
$c->stash->{student} = $c->model('DB::Student')->find($id);

}
}

sub view :Chained('object') Args(0) { }
sub view : Chained('object') Args(0) {
}

=head1 AUTHOR
Expand Down
60 changes: 58 additions & 2 deletions implementation/SIMS/SIMS/lib/SIMS/Schema/Result/Student.pm
Expand Up @@ -33,6 +33,46 @@ __PACKAGE__->table("Student");
data_type: 'text'
is_nullable: 1
=head2 type
data_type: 'text'
is_nullable: 1
=head2 address
data_type: 'text'
is_nullable: 1
=head2 address2
data_type: 'text'
is_nullable: 1
=head2 city
data_type: 'text'
is_nullable: 1
=head2 province
data_type: 'text'
is_nullable: 1
=head2 postalcode
data_type: 'text'
is_nullable: 1
=head2 phone
data_type: 'text'
is_nullable: 1
=head2 email
data_type: 'text'
is_nullable: 1
=head2 location
data_type: 'text'
Expand All @@ -45,6 +85,22 @@ __PACKAGE__->add_columns(
{ data_type => "int", is_nullable => 0 },
"name",
{ data_type => "text", is_nullable => 1 },
"type",
{ data_type => "text", is_nullable => 1 },
"address",
{ data_type => "text", is_nullable => 1 },
"address2",
{ data_type => "text", is_nullable => 1 },
"city",
{ data_type => "text", is_nullable => 1 },
"province",
{ data_type => "text", is_nullable => 1 },
"postalcode",
{ data_type => "text", is_nullable => 1 },
"phone",
{ data_type => "text", is_nullable => 1 },
"email",
{ data_type => "text", is_nullable => 1 },
"location",
{ data_type => "text", is_nullable => 1 },
);
Expand Down Expand Up @@ -98,8 +154,8 @@ __PACKAGE__->has_many(
);


# Created by DBIx::Class::Schema::Loader v0.07002 @ 2010-11-09 08:02:37
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Xo5iJykdlqBJiB9qtAyp1g
# Created by DBIx::Class::Schema::Loader v0.07002 @ 2010-11-09 19:29:35
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Uq/8NyRcNYG2kKvIYPfiUQ


# You can replace this text with custom content, and it will be preserved on regeneration
Expand Down
16 changes: 16 additions & 0 deletions implementation/SIMS/SIMS/script/update_db.pl
@@ -0,0 +1,16 @@
use strict;
use warnings;
use DBI;

unlink 'sims.db';

`sqlite3 sims.db < ../sims.sql`;

`script/sims_create.pl model DB DBIC::Schema SIMS::Schema create=static 'dbi:SQLite:dbname=sims.db' '' ''`;

my $dbh = DBI->connect( "dbi:SQLite:dbname=sims.db", "", "" );
$dbh->do( '
INSERT INTO "Student" VALUES ("1","Kartik Thakore","New Student","123 Numbers blvd","--","London","ON","L2T2W1","123456789","123@email.com","MSC");
'
);

Binary file modified implementation/SIMS/SIMS/sims.db
Binary file not shown.
8 changes: 8 additions & 0 deletions implementation/SIMS/sims.sql
Expand Up @@ -3,6 +3,14 @@ CREATE TABLE Student (

ID INT NOT NULL UNIQUE PRIMARY KEY,
name TEXT,
type TEXT,
address TEXT,
address2 TEXT,
city TEXT,
province TEXT,
postalcode TEXT,
phone TEXT,
email TEXT,
location TEXT

);
Expand Down

0 comments on commit 89047cb

Please sign in to comment.