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

Only show own repositories on the index page for teachers #4380

Merged
merged 6 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 additions & 0 deletions app/assets/stylesheets/components/table.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ tr.gu-mirror {
text-align: center;
color: $on-surface-muted;
}

td.empty {
white-space: break-spaces;
text-align: center;
padding: 16px;
line-height: 22px;
width: 100%;
color: $on-surface-muted;
}
}

#scoresheet-table-wrapper td {
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/repositories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ class RepositoriesController < ApplicationController
# GET /repositories.json
def index
authorize Repository
@repositories = Repository.all
@title = I18n.t('repositories.index.title')
@repositories = policy_scope(Repository.all)
@repositories = @repositories.has_admin(current_user) unless current_user&.zeus?
@title = current_user&.zeus? ? I18n.t('repositories.index.title_zeus') : I18n.t('repositories.index.title')
end

# GET /repositories/1
Expand Down
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ def repository_admin?(repository)
@repository_admin.include?(repository.id)
end

def a_repository_admin?
zeus? || repositories.any?
end

def personal?
institution.nil?
end
Expand Down
5 changes: 5 additions & 0 deletions app/views/repositories/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@
</td>
</tr>
<% end %>
<% if @repositories.empty? %>
<tr>
<td colspan="6" class="empty"><%= t ".empty" %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
Expand Down
4 changes: 3 additions & 1 deletion config/locales/views/repositories/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ en:
toggle-label: "Feature this repository"
remote_cant_be_edited_html: The clone URL can't be edited after the repository was created. Contact <a href="mailto:dodona@ugent.be">dodona@ugent.be</a> if it needs to be changed.
index:
title: All exercise repositories
title_zeus: All exercise repositories
title: Your exercise repositories
admins: "Edit administrators"
courses: "Edit allowed courses"
edit: "Edit"
delete: "Delete"
admin: "You are an administrator of this repository"
empty: "You don't have any repositories yet.\nClick on the plus button to create you first repository or ask a repository admin you know to add you as an administrator."
new:
title: Add an exercise repository
help_html: "You can find a guide with more information on managing repositories in <a href='https://docs.dodona.be/nl/guides/teachers/new-exercise-repo/#_1-een-git-repository-aanmaken'>our documentation</a>."
jorg-vr marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
4 changes: 3 additions & 1 deletion config/locales/views/repositories/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ nl:
toggle-label: "Deze repository uitlichten"
remote_cant_be_edited_html: De clone URL kan niet aangepast worden nadat de repository werd aangemaakt. Contacteer <a href="mailto:dodona@ugent.be">dodona@ugent.be</a> als het toch aangepast moet worden.
index:
title: Alle oefeningen repository's
title_zeus: Alle oefeningen repository's
jorg-vr marked this conversation as resolved.
Show resolved Hide resolved
title: Jouw oefeningen repository's
jorg-vr marked this conversation as resolved.
Show resolved Hide resolved
admins: "Beheerders aanpassen"
courses: "Toegelaten cursussen aanpassen"
edit: "Aanpassen"
delete: "Verwijderen"
admin: "Je bent beheerder van deze repository"
empty: "Je hebt nog geen repository's.\nJe kan een repository aanmaken via de plus knop, of je kan aan een repository beheerder vragen om je toe te voegen aan een repository."
new:
title: Een repository met oefeningen toevoegen
help_html: "Een handleiding met meer informatie over het beheren van een repository kan je in <a href='https://docs.dodona.be/nl/guides/teachers/new-exercise-repo/#_1-een-git-repository-aanmaken'>onze documentatie</a> terugvinden."
Expand Down