Skip to content

Commit

Permalink
Update delete permissions and set button red
Browse files Browse the repository at this point in the history
  • Loading branch information
johnf committed May 4, 2024
1 parent 47470b2 commit 4f825bb
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@

require 'dotenv/tasks'

require_relative "config/application"
require_relative 'config/application'

Rails.application.load_tasks
5 changes: 5 additions & 0 deletions app/assets/stylesheets/_layout_style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ body.bp {
height: 30px;
}

.button-red {
background-color: #DC2626;
color: white;
}

.left {
float: left;
}
Expand Down
6 changes: 3 additions & 3 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def initialize(user)
# Only collection_admins can manage a collection
can :read, Collection, items: { item_users: { user_id: user.id } }
can :read, Collection, items: { item_admins: { user_id: user.id } }
can :manage, Collection, collection_admins: { user_id: user.id }
can :update, Collection, operator_id: user.id
can :update, Collection, collector_id: user.id
can %i[read update], Collection, collection_admins: { user_id: user.id }
can %i[read update], Collection, operator_id: user.id
can %i[read update], Collection, collector_id: user.id

# Only admins can create a collection
cannot :create, Collection
Expand Down
15 changes: 9 additions & 6 deletions app/views/collections/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
=link_to 'Return To Results', session[:search_from].merge(session[:search_params]), :class => 'button'

.right
- if can? :manage, @collection
- if can? :update, @collection
= link_to 'Edit collection', edit_collection_path(@collection), :class => 'button'

.clear
Expand Down Expand Up @@ -194,13 +194,16 @@
%td= number_to_human @num_essences


.right
-if @collection.items.any?
.right
- if can? :destroy, Collection
- if @collection.items.any?
%p.delete-warning
%strong This collection contains items! If you choose to delete it they will be deleted too, as well as any content files they contain. This action can not be undone!
= button_to 'Delete collection and contents', collection_path(@collection), :method => :delete, :data => { :confirm_delete_message => 'Do you really want to delete this collection and all of its items?' }
-else
= button_to 'Delete collection', collection_path(@collection), :method => :delete, :data => { :confirm_delete_message => 'Do you really want to delete this collection?' }
= button_to 'Delete collection and contents', collection_path(@collection), :method => :delete, :data => { :confirm_delete_message => 'Do you really want to delete this collection and all of its items?' }, :class => 'button-red'
- else
= button_to 'Delete collection', collection_path(@collection), :method => :delete, :data => { :confirm_delete_message => 'Do you really want to delete this collection?' }, :class => 'button-red'

- if can? :update, Collection
= link_to 'Edit collection', edit_collection_path(@collection), :class => 'button right'

= render partial: 'terms/licence_footer', locals: {all_work: false}
4 changes: 2 additions & 2 deletions app/views/essences/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
To request access, contact
=link_to 'admin@paradisec.org.au', 'mailto:admin@paradisec.org.au'

- if admin_user_signed_in?
- if can? :destroy, @essence
.right
= button_to 'Delete essence', collection_item_essence_path(@collection, @item, @essence), :method => :delete, :data => { :confirm_delete_message => 'Do you really want to delete this file and its metadata from the archive (no undo possible)?' }
= button_to 'Delete essence', collection_item_essence_path(@collection, @item, @essence), :method => :delete, :data => { :confirm_delete_message => 'Do you really want to delete this file and its metadata from the archive (no undo possible)?' }, :class => 'button-red'

= render partial: 'terms/licence_footer', locals: {all_work: false}
18 changes: 10 additions & 8 deletions app/views/items/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -292,14 +292,16 @@
= render :partial => 'comments/new', :locals => { :item => @item }
= render :partial => 'comments/comments', :locals => {:comments => @item.comments.approved}

- if can? :update, @item
.right
-if @item.essences.any?
%p.delete-warning
%strong This item contains content files. If you choose to delete it, they will be deleted too and this action can not be undone!
= button_to 'Delete item and contents', collection_item_path(@collection, @item), :method => :delete, :data => { :confirm_delete_message => 'Do you really want to delete this item and all of its content files?' }
-else
= button_to 'Delete item', collection_item_path(@collection, @item), :method => :delete, :data => { :confirm_delete_message => 'Do you really want to delete this item?' }
= link_to 'Edit item', edit_collection_item_path(@collection, @item), :class => 'button right', style: 'margin-left: 0.4rem;'
- if can? :destroy, @item
- if @item.essences.any?
%p.delete-warning
%strong This item contains content files. If you choose to delete it, they will be deleted too and this action can not be undone!
= button_to 'Delete item and contents', collection_item_path(@collection, @item), :method => :delete, :data => { :confirm_delete_message => 'Do you really want to delete this item and all of its content files?' }, :class => 'button-red'
- else
= button_to 'Delete item', collection_item_path(@collection, @item), :method => :delete, :data => { :confirm_delete_message => 'Do you really want to delete this item?' }, :class => 'button-red'

- if can? :update, @item
= link_to 'Edit item', edit_collection_item_path(@collection, @item), :class => 'button right', style: 'margin-left: 0.4rem;'

= render partial: 'terms/licence_footer', locals: {all_work: false}
5 changes: 5 additions & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,9 @@
# Show emails in the browser
config.action_mailer.delivery_method = :letter_opener
config.action_mailer.perform_deliveries = true

config.web_console.permissions = ['192.168.88.150', '172.18.0.3']

# NOTE: Not sure why we need this and the magic isn't happening by itself
config.assets.digest = false
end
34 changes: 0 additions & 34 deletions docker/app.dev.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,37 +34,3 @@ ENTRYPOINT ["/rails/bin/docker-entrypoint"]
# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD ["./bin/rails", "server"]


# RUN cd /tmp \
# && curl -s "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" \
# && unzip -q awscliv2.zip \
# && ./aws/install \
# && rm -rf /tmp/awscliv2.zip /tmp/aws \
# && curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/ubuntu_64bit/session-manager-plugin.deb" -o "session-manager-plugin.deb" \
# && dpkg -i session-manager-plugin.deb
# Stuff we might need
# net-tools \
# ruby-kgio \
# git-core \
# curl \
# zlib1g-dev \
# build-essential \
# libssl-dev \
# libreadline-dev \
# libsqlite3-dev \
# sqlite3 \
# libxml2-dev \
# libxslt1-dev \
# software-properties-common \
# libffi-dev \
# nodejs \
# openjdk-17-jre \
# wget \
# npm


# Chrome for headless testing
# RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
# RUN apt-get -y install ./google-chrome-stable_current_amd64.deb

0 comments on commit 4f825bb

Please sign in to comment.