Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • develop
  • issue-68/streak-high_streak-last_action_at
  • issue-69/fix-statistics-route
  • issue/54-curator-queue
  • issue/58-testar-s3
  • issue/65-govbr
  • master
  • orientdb
  • pre-api
  • pre-languages
  • pre-submission
  • tag-clustering-task
  • video-cache
13 results

Target

Select target project
  • portalmec/portalmec
  • rfhferreira/cleanning-portalmec
2 results
Select Git revision
  • 208/fix_followers_avatar
  • agpl-headers
  • anonymous-auth
  • curator
  • curator-activity
  • default-attachment-location
  • develop
  • dspace-6
  • dspace-sync
  • email-confirmation
  • email-teste
  • file-headers
  • fix-follows
  • fix-paginator
  • fix-rspec-tests
  • fix_activities_curator
  • gamification
  • homologa
  • issue/225
  • issue/227
  • issue/238
  • issue/275
  • issue/280
  • issue/288
  • issue/289
  • issue/294
  • issue/296
  • issue/321
  • issue/357
  • issue/380
  • issue/388
  • issue/392
  • issue/397
  • learn-object-questions
  • learning_object-suspension-process
  • learning_object-update-permissions
  • licenses
  • list
  • master
  • multisearch
  • new-filters
  • ore-import
  • paginate-publisher
  • populator
  • predictionio-docker
  • publisher-search
  • recommendation-filters
  • recommendation-routes
  • revert-b13fcd9f
  • revert-dd480dc3
  • revert-ee12496c
  • rspec
  • show-public-collections
  • stable
  • submission
  • tags
  • teacher-code
  • teacher_info
  • test-ci
  • trackable-params
  • training-material
  • update-docs
  • update-gemfile
  • user-group
  • user-profiles
  • orientdb
  • pre-api
  • pre-languages
  • pre-submission
  • tag-clustering-task
  • video-cache
71 results
Show changes
Showing
with 695 additions and 52 deletions
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class V1::ProgressesController < ApplicationController
include ::Paginator
before_action :set_progress, only: :show
before_action :authenticate_user!, only: :index
def index
progresses = paginate current_user.progresses
render json: progresses, each_serializer: ProgressSerializer
end
def show
render json: @progress, serializer: ProgressSerializer
end
private
def set_progress
@progress ||= Progress.find_by_id(params[:id])
if @progress.blank?
render status: :not_found
end
end
end
......@@ -25,7 +25,7 @@ class V1::QuestionsController < ApplicationController
# GET /questions
def index
@questions = paginate Question.all
@questions = paginate Question.all.order(id: :asc)
render json: @questions
end
......
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class V1::RequirementsController < ApplicationController
include ::Paginator
before_action :set_requirement, only: [:show, :update, :destroy]
before_action :authenticate_user!, except: [:index, :show]
before_action :authorize!, only: [:update, :destroy]
def index
requirements = paginate Requirement
render json: requirements
end
def show
render json: @requirement
end
def create
@requirement = Requirement.new(requirement_params)
authorize @requirement
if @requirement.save
@requirement.add_achievements(extra_params[:achievements])
render json: @requirement, status: :created
else
render json: @requirement.errors, status: :unprocessable_entity
end
end
# PUT/PATCH /v1/requirements/1
def update
if @requirement.update(requirement_params)
@requirement.update_achievements(extra_params[:achievements])
render json: @requirement, status: :ok
else
render json: @requirement.errors, status: :unprocessable_entity
end
end
# DELETE /v1/requirements/1
def destroy
@requirement.destroy
response = { 'status': 'deleted' }
render status: :ok, json: response
end
private
def set_requirement
@requirement ||= Requirement.find_by_id(params[:id])
if @requirement.blank?
render status: :not_found
end
end
def requirement_params
params.require(:requirement).permit(:description, :goal, :repeatable, :action_id)
end
def extra_params
return {} if params[:requirement].nil?
params[:requirement].permit(achievements: [])
end
def authorize!
authorize @requirement
end
end
......@@ -19,22 +19,29 @@
require 'open-uri'
class V1::SessionsController < DeviseTokenAuth::SessionsController
#function to create a new session
def create
# Check
field = (resource_params.keys.map(&:to_sym) & resource_class.authentication_keys).first
#verify if the user exist and is active
if User.find_by_email(resource_params[:email]).present?
if User.find_by_email(resource_params[:email]).confirmed_at.present?
field = (resource_params.keys.map(&:to_sym) & resource_class.authentication_keys).first
@resource = nil
if field
q_value = get_case_insensitive_field_from_resource_params(field)
@resource = find_resource(field, q_value)
end
#verify the credentials
if @resource && valid_params?(field, q_value) && (!@resource.respond_to?(:active_for_authentication?) || @resource.active_for_authentication?)
valid_password = @resource.valid_password?(resource_params[:password])
if (@resource.respond_to?(:valid_for_authentication?) && !@resource.valid_for_authentication? { valid_password }) || !valid_password
return render_create_error_bad_credentials
end
@token = @resource.create_token
@resource.save
......@@ -43,6 +50,7 @@ require 'open-uri'
yield @resource if block_given?
render_create_success
elsif @resource && !(!@resource.respond_to?(:active_for_authentication?) || @resource.active_for_authentication?)
# verify if user is to be reactivated
reactivate_user?
......@@ -51,16 +59,35 @@ require 'open-uri'
elsif @resource.banished?
render_create_error_banished
end
else
render_create_error_bad_credentials
end
#in case of the user is not confirmed, find the user and send an email confirmation
else
return render_create_error_not_confirmed
end
else
return render_create_error_bad_credentials
end
end
def render_create_error_not_confirmed
render json: {
success: false,
errors: [ I18n.t("devise.failure.unconfirmed")],
}, status: 417
end
def render_create_error_banished
render json: {
success: false,
errors: [ I18n.t("devise.sessions.banished")]
}, status: 401
}, status: 406
end
def render_create_error_blocked
......@@ -68,7 +95,7 @@ require 'open-uri'
success: false,
errors: [ I18n.t("devise.sessions.blocked")],
avaliable_at: @resource.reactivated_at
}, status: 401
}, status: 406
end
def reactivate_user?
......
......@@ -23,10 +23,12 @@ class V1::SubmissionsController < ApplicationController
before_action :set_new_submission , only: :index
before_action :set_submission , only: [:show, :answer, :destroy]
before_action :authenticate_user!
before_action :authorize!, except: :create
before_action :authorize!, except: [:create, :user_submissions, :all_users_submissions]
def index
submissions = paginate Submission.all
submissions = paginate Submission.where(status: Submission.statuses[:submitted])
render json: submissions
end
......@@ -34,6 +36,19 @@ class V1::SubmissionsController < ApplicationController
render json: @submission
end
def user_submissions
submission_user = Submission.where(submitter_id: params[:user_id]).where(status: 0)
all_submission_user = paginate submission_user
render json: all_submission_user
end
def all_users_submissions
# show all submissions of all users without from the current user
submissions_users = Submission.where(status: 0).where.not(submitter_id: params[:user_id])
all_submissions_users = paginate submissions_users
render json: all_submissions_users
end
def create
learning_object = LearningObject.where(id: submission_params[:learning_object_id]).first
if learning_object.blank?
......@@ -118,4 +133,5 @@ class V1::SubmissionsController < ApplicationController
def authorize!
authorize @submission
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class V1::UnlockedAchievementsController < ApplicationController
include ::Paginator
before_action :set_achievement, only: :show
before_action :authenticate_user!, only: :index
def index
achievements = paginate current_user.unlocked_achievements
render json: achievements
end
def show
render json: @achievement
end
# GET /v1/unlocked_achievements/user/:id
def show_specific
# search for a all unlocked_achievements of a specific user
un_achievement = paginate User.find_by_id(params[:user_id]).unlocked_achievements
render json: un_achievement
end
private
def set_achievement
@achievement ||= UnlockedAchievement.find_by_id(params[:id])
if @achievement.blank?
render status: :not_found
end
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class V1::UserItemsController < ApplicationController
include ::Paginator
include ::ItemsFilter
before_action :set_user_item, only: :show
before_action :authenticate_user!, only: :index
def index
items = paginate filter_items(current_user.items.active)
render json: items
end
def show
render json: @user_item
end
private
def set_user_item
@user_item ||= UserItem.find_by_id(params[:id])
if @user_item.blank?
render status: :not_found
end
end
end
class V1::UserProgressesController < ApplicationController
include ::DeletedObjectsController
include ::Paginator
def index
progresses = Progress.joins("INNER JOIN requirements ON progresses.requirement_id = requirements.id")
.select("requirements.description, requirements.goal, progresses.user_id, progresses.requirement_id, progresses.counter, progresses.created_at, progresses.updated_at")
.where("counter < goal AND progresses.user_id = ?", params["user_id"])
if (progresses.length < 4)
all_progresses = Requirement.select("*").where("id IN (1,2,13)")
else
all_progresses = []
descriptions = []
last_string = "inicio"
progresses.all.each do |p|
if (!p.requirement.description.last(5).include? last_string.last(5))
all_progresses.append(p)
end
last_string = p.requirement.description
end
end
all_progresses_paginate = paginate all_progresses
render json: all_progresses_paginate
end
end
......@@ -23,14 +23,115 @@ class V1::UsersController < ApplicationController
include ::Paginator
include ::PublisherController
include ::SubjectableController
include ::ItemsFilter
before_action :set_user, only: [:show, :update, :destroy, :following, :own_reviews, :received_reviews, :followers, :add_teacher, :remove_teacher, :reactivate_user]
before_action :set_user, only: [:show, :update, :destroy, :following, :own_reviews, :received_reviews, :followers, :add_teacher, :remove_teacher, :reactivate_user, :items]
before_action :set_new_user, only: [:teacher_requests, :teacher_request]
before_action :authenticate_user!, only: [:create, :update, :destroy,
:following, :own_reviews, :received_reviews, :followers, :create_teacher_request, :update_teacher_request,
:teacher_requests, :add_teacher, :remove_teacher, :reactivate_user]
before_action :authorize_user, only: [:own_reviews, :received_reviews, :update, :destroy, :teacher_requests, :add_teacher, :remove_teacher]
# gamification
# POST /v1/users/complete_action
def complete_action
# current_user completes an action
# action counters and user progresses for achievements are updated,
# and if an achievement was conquered its rewards are given
quantity = params[:quantity].to_i > 1 ? params[:quantity].to_i : 1
success, response = current_user.complete_action(Action.where(id: params[:action_id]).first, quantity)
status = success ? :ok : :unprocessable_entity
render json: response, status: status
end
def confirm_email
link = "https://plataformaintegrada.mec.gov.br/confirmacao-de-email"
@user = User.find_by_confirm_token(params[:id])
if @user
@user.email_activate
redirect_to link
end
end
# POST /v1/users/purchase_item
def purchase_item
# purchases given item for current user
item = Item.find_by(id: params[:item_id])
user_item = UserItem.where(user: current_user, item: item).first
if !user_item.blank?
render json: { "error": "Você já possui este item." }, status: :unprocessable_entity
else
if current_user.points >= item.price - item.discount
current_user.points -= item.price - item.discount
if !current_user.save
render json: current_user.errors, status: :unprocessable_entity
else
current_user.add_user_item(item)
render json: current_user.user_items, status: :ok
end
else
render json: { "error": "Você não possui gemas suficientes para esta compra." }, status: :unprocessable_entity
end
end
end
# POST /v1/users/equip_item
def equip_item
if current_user.equip_item(Item.find_by(id: params[:item_id]))
render json: current_user.user_items, status: :ok
else
render json: current_user.errors, status: :unprocessable_entity
end
end
# POST /v1/users/unequip_item
def unequip_item
if current_user.unequip_item(Item.find_by(id: params[:item_id]))
render json: current_user.user_items, status: :ok
else
render json: current_user.errors, status: :unprocessable_entity
end
end
# POST /v1/users/remove_item
def remove_item
if current_user.remove_item(Item.find_by(id: params[:item_id]))
render json: current_user.user_items, status: :ok
else
render json: current_user.errors, status: :unprocessable_entity
end
end
# GET /v1/users/action_counters
def action_counters
# return action_counters and counters for given user
render json: paginate(current_user.action_counters), status: :ok
end
# GET /v1/users/completed_achievements
def completed_achievements
render json: paginate(current_user.unlocked_achievements), status: :ok
end
# GET /v1/users/:id/items
def items
query = {}
query[:items] = { item_type: params[:item_type] } if Item.item_types.keys.include? params[:item_type]
query[:being_used] = params[:being_used] if ["true", "false"].include? params[:being_used]
items = @user.user_items.includes(:item).where(query)
render json: paginate(items), status: :ok
end
#
# end gamification
# GET /v1/users
# GET /v1/users.json
def index
......@@ -51,6 +152,7 @@ class V1::UsersController < ApplicationController
authorize user
if user.save
UserMailer.welcome_email(user).deliver_now
render json: user, status: :created
else
render json: user.errors, status: :unprocessable_entity
......@@ -76,6 +178,26 @@ class V1::UsersController < ApplicationController
render status: :ok, json: response
end
# GET /v1/top_users
# GET /v1/top_users.json
def show_top_users
# select users who are not admin and order by level, limit to 5 users
ids = User.joins(:roles_users).where(roles_users: {role_id: 3}).pluck(:user_id)
users = User.where.not(id: ids).order("level DESC").limit(5)
render json: users
end
# GET /v1/most_active_users
# GET /v1/most_active_users.json
def most_active_users
# select users who are not admin and order by streak, limit to 5 users
ids = User.joins(:roles_users).where(roles_users: {role_id: 3}).pluck(:user_id)
users = User.where.not(id: ids).order("streak DESC").limit(5)
render json: users
end
# GET /v1/users/teacher_requests
# GET /v1/users/teacher_requests.json
def teacher_requests
......@@ -139,6 +261,7 @@ class V1::UsersController < ApplicationController
@user.submitter_request = :accepted
@user.roles << Role.where(name: "publisher")
if @user.save
@user.complete_action(Action.find_by_name("Autenticação de Professor"))
TeacherMailer.new_teacher_approved(@user).deliver_now
render status: :ok
else
......@@ -200,6 +323,10 @@ class V1::UsersController < ApplicationController
private
def xp_to_level(x)
(100 + Math.log([x, 900].min, 1.07)).floor
end
def deleted_resource
User
end
......
......@@ -18,7 +18,7 @@
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class ApplicationMailer < ActionMailer::Base
default to: 'plataformaintegrada@mec.gov.br'
#default to: 'plataformaintegrada@mec.gov.br'
default from: 'portalmec@inf.ufpr.br'
#layout 'mailer'
layout 'mailer'
end
......@@ -18,12 +18,12 @@
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class ContactsMailer < ApplicationMailer
default from: Proc.new { @contact.email }
default to: 'portalmec@inf.ufpr.br'
def new_contact_received(contact)
@contact = contact
@subject = "Contato de " + @contact.name
mail(subject: @subject)
mail(from: @contact.email, subject: @subject)
end
def contact_updated(contact)
......
class UserMailer < ActionMailer::Base
#set the default email sender
default from: 'portalmec_tec@inf.ufpr.br'
#function to send email to user when he/she is created through the admin panel
def welcome_email (user)
@user = user
mail(to: @user.email, subject: 'Bem vindo ao PortalMec!')
end
#function to send email confirmation to user, this view is located in app/views/user_mailer/email_confirmation.html.erb
def email_confirmation (user)
@user = user
mail(to: @user.email, subject: 'Confirmação de email')
end
def users_email_sender (email, subject, body)
@body = body
mail(to: email, subject: subject)
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
# == Schema Information
#
# Table name: achievements
# t.string :name
# t.string :description
# t.integer :reward_experience
# t.integer :reward_points
# t.integer :state
# t.integer :repeatable
# t.boolean :resettable
# t.datetime :created_at
# t.datetime :updated_at
class Achievement < ApplicationRecord
has_many :items
has_many :unlocked_achievements
has_many :users, through: :unlocked_achievements
has_and_belongs_to_many :requirements
enum state: [:inactive, :active, :deleted]
enum repeatable: [:never, :daily, :weekly, :monthly, :yearly]
validates_presence_of :name, :description, :reward_experience, :reward_points, :state, :repeatable
def add_requirements(ids=[])
errors = []
ids.each do |requirement_id|
if !requirement_ids.include?(requirement_id)
requirement = Requirement.where(id: requirement_id).first
if !requirement.blank?
requirements << requirement
else
errors << {error_type:"inexistent", id: requirement_id}
end
else
errors << {error_type:"repeated", id: requirement_id}
end
end
return errors
end
def remove_requirements(ids=[])
ids.each do |requirement_id|
requirement = requirements.where(id: requirement_id).first
if !requirement.blank?
self.requirements.delete(requirement)
end
end
end
def update_requirements(ids)
ids ||= []
add_requirements(ids - requirement_ids)
remove_requirements(requirement_ids - ids)
end
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
# == Schema Information
#
# Table name: actions
# t.integer "name"
# t.integer "description"
# t.datetime "created_at"
# t.datetime "updated_at"
# t.integer "reward_experience"
# this table has the following foreign keys: requirements | action_counters
class Action < ApplicationRecord
has_many :requirements
has_many :action_counters
has_many :users, through: :action_counters
validates_presence_of :name, :description
end
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
# == Schema Information
#
# Table name: action_counters
# t.belongs_to :action, index: true
# t.belongs_to :user, index:true
# t.integer :counter, default: 0
# t.datetime "created_at", null: false
# t.datetime "updated_at", null: false
class ActionCounter < ApplicationRecord
belongs_to :action
belongs_to :user
validates_presence_of :user, :action
end
......@@ -39,7 +39,8 @@
# thumbnail_content_type :string
# thumbnail_file_size :integer
# thumbnail_updated_at :datetime
#
# review_average: :float default("0.0")
# curator :string
class Collection < ApplicationRecord
include Reviewable
......@@ -67,16 +68,15 @@ class Collection < ApplicationRecord
validates :name, :owner, presence: true
validates_inclusion_of :privacy, in: %w(public private), message: 'Privacy must be public or private'
before_destroy :delete_index
after_create :create_action
#before_destroy :delete_index
scope :from_user, ->(user) { where(owner: user) }
searchkick language: 'brazilian', match: :word_start, searchable: [:name, :description, :author], callbacks: :async, index_prefix: Socket.gethostname.downcase, merge_mappings: true, mappings: {
collection: {
properties: {
created_at: {
type: "date"
}
"properties": {
"created_at": {
"type": "date"
}
}
}
......@@ -173,4 +173,8 @@ class Collection < ApplicationRecord
def ignore_changes
super + %w(score views_count downloads_count likes_count shares_count follows_count)
end
def create_action
owner.complete_action(Action.find_by_name("Criar Coleção"))
end
end
......@@ -25,7 +25,7 @@
# collectionable_id :integer
# collectionable_type :string
# collection_id :integer
# order :integer
# position :integer
# created_at :datetime not null
# updated_at :datetime not null
#
......@@ -34,6 +34,8 @@ class CollectionItem < ApplicationRecord
# *current_user* add item *collectionable* to *collection*
include Trackable
after_create :create_action
belongs_to :collection
belongs_to :collectionable, polymorphic: true
......@@ -58,4 +60,9 @@ class CollectionItem < ApplicationRecord
collectionable_type == 'LearningObject' ? LearningObject.find(collectionable_id).default_thumbnail : Collection.find(collectionable_id).thumbnail
end
private
def create_action
collection.owner.complete_action(Action.find_by_name("Adicionar Recurso a Coleção")) if collectionable_type == "LearningObject"
end
end
......@@ -29,7 +29,7 @@
# complaint_reason_id :integer
# created_at :datetime not null
# updated_at :datetime not null
#
# state :integer default("0")
class Complaint < ApplicationRecord
# *current_user* create complaint about *complaint_reason* for *complaintable*
......
......@@ -25,7 +25,7 @@
# reason :text
# created_at :datetime not null
# updated_at :datetime not null
#
# status :integer default("0")
class ComplaintReason < ApplicationRecord
# *current_user* create complaint reason
......
# Copyright (C) 2015 Centro de Computacao Cientifica e Software Livre
# Departamento de Informatica - Universidade Federal do Parana
#
# This file is part of portalmec.
#
# portalmec is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# portalmec is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with portalmec. If not, see <http://www.gnu.org/licenses/>.
class ComplaintVote < ApplicationRecord
include Trackable
belongs_to :complainable, polymorphic: true
belongs_to :user
validates_presence_of :user, :complainable_id
validates :user_id, uniqueness: { scope: [:complainable_id, :complainable_type]}
acts_as_paranoid
has_paper_trail
end