Skip to content
Snippets Groups Projects
Commit cd356524 authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

Merge branch 'master' of gitlab.c3sl.ufpr.br:portalmec/portalmec

parents cc7e3673 f299df60
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,7 @@ class LearningObjectsController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
before_action :set_learning_object, only: [:show, :edit, :update,
:destroy, :destroy_attachment, :like, :bookmarks,
:destroy, :destroy_attachment, :remove_thumbnail, :like, :bookmarks,
:collections, :upload, :upload_link, :download,
:user_not_authorized]
after_action :increment_learning_object_views, only: [:show]
......@@ -88,6 +88,12 @@ class LearningObjectsController < ApplicationController
render :nothing => true, :status => 204
end
def remove_thumbnail
@learning_object.thumbnail = nil
@learning_object.save
render :nothing => true, :status => 204
end
def download
@learning_object.download current_user
......
......@@ -30,6 +30,10 @@ class LearningObjectPolicy < ApplicationPolicy
record if owns?
end
def remove_thumbnail?
record if owns?
end
def show?
if user.nil?
record.state == 'published'
......
......@@ -31,9 +31,24 @@
<%= form_for @learning_object, url: wizard_path, method: :put, html: { multipart: true } do |f| %>
<%= f.file_field :thumbnail, required: true %>
<% unless @learning_object.thumbnail.blank? %>
<div>Thumbnail: <%= @learning_object.thumbnail_file_name %>&nbsp;<i id="remove_thumbnail" class="fa fa-trash fa-1"></i></div>
<script>
$("#remove_thumbnail").click(function(){
if(confirm("Você tem certeza?")){
$(this).parent().remove()
$.ajax({
url: "<%= remove_thumbnail_path(@learning_object) %>",
method: 'POST'
})
}
});
</script>
<% end %>
<button type="submit" class="btn-submit btn btn-success btn-outline-rounded green">
Enviar <i style="margin-left:10px;" class="fa fa-paper-plane"></i>
</button>
<%= link_to next_wizard_path do %>
<button type="button" class="btn-submit btn btn-warning btn-outline-rounded yellow">Pular etapa</button>
<% end %>
......
......@@ -137,6 +137,7 @@ pt-BR:
object_type: "Tipo do objeto"
language: "Idioma"
author: "Autor"
topics: "Assunto"
create:
notice:
failure: "Não foi possível criar o objeto."
......
......@@ -72,6 +72,7 @@ Rails.application.routes.draw do
end
post 'learning_objects/:id/remove_file/:attachment_id' => 'learning_objects#destroy_attachment', as: 'remove_file'
post 'learning_objects/:id/remove_thumbnail', to: 'learning_objects#remove_thumbnail', as: 'remove_thumbnail'
resources :learning_objects do
resources :build, controller: 'learning_objects/build'
get :reviews, to: 'reviews#list', as: 'reviews'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment