Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1413 vis feedback #1428

Merged
merged 21 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions dao/courses.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type CoursesDao interface {

RemoveAdminFromCourse(userID uint, courseID uint) error
DeleteCourse(course model.Course)

IsUserEnrolledInCourse(userID uint, courseID uint) (bool, error)
carlobortolan marked this conversation as resolved.
Show resolved Hide resolved
}

type coursesDao struct {
Expand Down Expand Up @@ -338,3 +340,12 @@ func (d coursesDao) DeleteCourse(course model.Course) {
logger.Error("Can't delete course", "err", err)
}
}

func (d coursesDao) IsUserEnrolledInCourse(user uint, course uint) (bool, error) {
var nRows int64
err := DB.Table("course_users").Where("user_id = ? AND course_id = ?", user, course).Count(&nRows).Error
if err != nil {
return false, err
}
return nRows == 1, nil
}
15 changes: 15 additions & 0 deletions mock_dao/courses.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions web/template/home.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

{{if and .VersionTag (eq .VersionTag "development")}}
<script defer src="/static/node_modules/alpinejs/dist/cdn.js"></script>
<script defer src="/static/node_modules/alpinejs/dist/cdn.js"></script>
carlobortolan marked this conversation as resolved.
Show resolved Hide resolved
{{else}}
<script defer src="/static/node_modules/alpinejs/dist/cdn.min.js"></script>
{{end}}
Expand Down
2 changes: 1 addition & 1 deletion web/template/index.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{{if .PinnedCourses}}
<h2 class="text-2xl text-1 mt-2">Pinned Courses</h2>
{{range $course := .PinnedCourses}}
{{if not $course.IsHidden}}
{{if $user.IsEligibleToWatchCourse $course}}
{{template "course-card" (dict "course" $course "user" $user)}}
{{end}}
{{end}}
Expand Down
1 change: 1 addition & 0 deletions web/ts/data-store/admin-lecture-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export class AdminLectureListProvider extends StreamableMapProvider<number, Lect
await AdminLectureList.delete(courseId, lectureIds);
this.data[courseId] = (await this.getData(courseId)).filter((s) => !lectureIds.includes(s.lectureId));
await this.triggerUpdate(courseId);
window.location.reload();
carlobortolan marked this conversation as resolved.
Show resolved Hide resolved
}

async deleteSeries(courseId: number, lectureId: number) {
Expand Down
Loading