Skip to content

Commit

Permalink
Bug 28762: Use Koha::Course in course-details controller
Browse files Browse the repository at this point in the history
This patch updates Koha::Course to include the 'instructors' relation
accessor and then update the course-details controller to use the
Koha::Course object and pass it to the template instead of building a
hash using GetCourse.

Signed-off-by: Martin Renvoize <[email protected]>
Signed-off-by: Nick Clemens <[email protected]>
Signed-off-by: Martin Renvoize <[email protected]>
  • Loading branch information
mrenvoize committed Jul 23, 2024
1 parent 316c14c commit 7f38c77
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions Koha/Course.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,32 @@ package Koha::Course;

use Modern::Perl;


use base qw(Koha::Object);

=head1 NAME
Koha::Course - Koha Course Object class
=head1 API
=head2 Relations
=head3 instructors
my $instructors = $course->instructors();
Returns the related Koha::Patrons object containing the instructors for this course
=cut

sub instructors {
my ($self) = @_;

my $instructors = Koha::Patrons->search(
{ 'course_instructors.course_id' => $self->course_id },
{ join => 'course_instructors' }
);

return $instructors;
}

=head2 Internal methods
Expand Down
2 changes: 1 addition & 1 deletion course_reserves/course-details.pl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
}
}

my $course = GetCourse($course_id);
my $course = Koha::Courses->find($course_id);
my $course_reserves = GetCourseReserves(
course_id => $course_id,
include_items => 1,
Expand Down

0 comments on commit 7f38c77

Please sign in to comment.