Skip to content

Commit 02b673c

Browse files
author
Theresa
committed
Merge branch 'master' of github.com:openHPI/codeocean-classroom into refactor
2 parents 3066811 + 60eae20 commit 02b673c

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

app/controllers/exercises_controller.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,12 @@ def add_to_cart
8383
Cart.create(user: current_user)
8484
end
8585
cart = Cart.find_by(user: current_user)
86-
cart.exercises << @exercise
87-
redirect_to @exercise, notice: 'Exercise was successfully added to your cart.'
86+
unless cart.exercises.find_by(id: @exercise.id)
87+
cart.exercises << @exercise
88+
redirect_to @exercise, notice: 'Exercise was successfully added to your cart.'
89+
else
90+
redirect_to @exercise, alert: 'Exercise already in your cart.'
91+
end
8892
end
8993

9094
def exercises_all

app/models/ability.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def initialize(user)
1212
can :export, Exercise
1313
can :add_to_cart, Exercise
1414
can :read, Exercise
15-
can :edit, Exercise do |exercise|
15+
can :manage, Exercise do |exercise|
1616
exercise.user == user
1717
end
1818

app/views/exercises/show.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
<dl class="dl-horizontal">
2929

3030
<dt><em><%= 'Files' %>:</em> </dt>
31+
<br>
3132
<% @files.each do |file| %>
32-
<br>
3333
<dd>
3434
<dt><%= 'Content: '%></dt>
3535
<dd><div class="editor_readonly"><%= file.content %></div></dd>
@@ -47,8 +47,8 @@
4747
</dl>
4848
<dl class="dl-horizontal">
4949
<dt><em><%= 'Tests' %>:</em> </dt>
50+
<br>
5051
<% @tests.each do |test| %>
51-
<br>
5252
<dd>
5353
<dt><%= 'Content: '%></dt>
5454
<dd><div class="editor_readonly"><%= test.content %></div></dd>

0 commit comments

Comments
 (0)