diff --git a/Gemfile b/Gemfile index 45e7d36360bfc32f84ff8971572c47bd252495ad..7f1efd8f523e88b896969aef8f3be81f500c783e 100644 --- a/Gemfile +++ b/Gemfile @@ -58,7 +58,7 @@ end # gem 'devise' # enable login via rest -gem 'devise_token_auth' +#gem 'devise_token_auth' gem 'rack-cors', require: 'rack/cors' #bootstrap @@ -81,5 +81,4 @@ gem 'chart-js-rails' gem 'mina' gem 'rubycritic', require: false - gem 'locastyle' diff --git a/Gemfile.lock b/Gemfile.lock index ac3cca0c4c3c9c2a6b672bf493015e85f8c99853..ae09f4cba2038b13cbdfd21a123fdc7f4e081017 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -79,16 +79,13 @@ GEM debug_inspector (0.0.2) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - devise (3.5.1) + devise (3.5.2) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 3.2.6, < 5) responders thread_safe (~> 0.1) warden (~> 1.2.3) - devise_token_auth (0.1.34) - devise (= 3.5.1) - rails (~> 4.2) diff-lcs (1.2.5) domain_name (0.5.24) unf (>= 0.0.5, < 1.0.0) @@ -270,7 +267,6 @@ DEPENDENCIES coffee-rails (~> 4.1.0) dspace_rest_client (~> 1.1.0) devise - devise_token_auth gruff jbuilder (~> 2.0) jquery-rails @@ -296,4 +292,4 @@ DEPENDENCIES web-console (~> 2.0) BUNDLED WITH - 1.10.5 + 1.10.6 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index b153830616b10674f5493778630e09103034cb64..15e1d0135f85fd59816d2fdd12772bf6195c1baf 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,10 +2,16 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :null_session - include DeviseTokenAuth::Concerns::SetUserByToken + before_action :configure_permitted_parameters, if: :devise_controller? def repository Portalmec::Application.repository end + protected + + def configure_permitted_parameters + devise_parameter_sanitizer.for(:sign_up) << :name + end + end diff --git a/app/controllers/management/users_controller.rb b/app/controllers/management/users_controller.rb index cc53f3b3b15b4a4e118f4d3a83288e82d2d9a7c0..95e72c32739f9e894038c403bdf8734b13036798 100644 --- a/app/controllers/management/users_controller.rb +++ b/app/controllers/management/users_controller.rb @@ -1,5 +1,6 @@ class Management::UsersController < ManagementController before_action :set_user, only: [:show, :edit, :update, :destroy] + before_action :set_roles, only: [:new, :edit] def index @users = user_repository.all @@ -68,11 +69,15 @@ class Management::UsersController < ManagementController # Never trust parameters from the scary internet, only allow the white list through. def user_params - params.require(:user).permit(:name, :email, :password, :password_confirmation) + params.require(:user).permit(:name, :email, :password, :password_confirmation, roles: []) end def user_repository repository.for(:user) end + def set_roles + @roles = Role.all + end + end diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb deleted file mode 100644 index e692f7f87efe5a8c2050d61dfaac9cfae200bc38..0000000000000000000000000000000000000000 --- a/app/controllers/registrations_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -class RegistrationsController < Devise::RegistrationsController - after_action :create_user_dependencies, only: :create - - private - - def create_user_dependencies - if resource.persisted? - user_repository.save resource - end - end - - def user_repository - repository.for :user - end - -end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb deleted file mode 100644 index 3a2a164d6ac3004f500308844243a79fa17af6c9..0000000000000000000000000000000000000000 --- a/app/controllers/users_controller.rb +++ /dev/null @@ -1,33 +0,0 @@ -class UsersController < ApplicationController - def index - #db = repository.for(:user) #OrientDb::UserRepository.new - #@user = db.find_by_id "#17:1" - end - - def show - end - - # GET /users/new - def new - end - - # GET /users/1/edit - def edit - end - - # POST /users - # POST /users.json - def create - end - - # PATCH/PUT /users/1 - # PATCH/PUT /users/1.json - def update - end - - # DELETE /users/1 - # DELETE /users/1.json - def destroy - end - -end diff --git a/app/helpers/management/users_helper.rb b/app/helpers/management/users_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..688b6e1e8520ddde4f16a269af9b08523533fc7d --- /dev/null +++ b/app/helpers/management/users_helper.rb @@ -0,0 +1,2 @@ +module Management::UsersHelper +end \ No newline at end of file diff --git a/app/helpers/registrations_helper.rb b/app/helpers/registrations_helper.rb deleted file mode 100644 index b10037684b2bfcfd874c22a8354d581326b77f28..0000000000000000000000000000000000000000 --- a/app/helpers/registrations_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module RegistrationsHelper -end diff --git a/app/models/role.rb b/app/models/role.rb new file mode 100644 index 0000000000000000000000000000000000000000..33cd819aca6c2fef5200134c096b45a0249961bb --- /dev/null +++ b/app/models/role.rb @@ -0,0 +1,3 @@ +class Role < ActiveRecord::Base + has_and_belongs_to_many :users +end diff --git a/app/models/user.rb b/app/models/user.rb index 4487ee2cc55d54de11fcb3be727db1bdd8826c1f..655002b4a16e0db6faa79368658ed3c1927e3fe2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,7 +1,7 @@ class User < ActiveRecord::Base + # Include default devise modules. Others available are: + # :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable - :confirmable - include DeviseTokenAuth::Concerns::User - + has_and_belongs_to_many :roles end diff --git a/app/repositories/active_record/user_repository.rb b/app/repositories/active_record/user_repository.rb index e87064ee1c1159a5ef4df920396522c75ded8aa1..d102a7e8d67914eda5c084def0544f7bb6e24a10 100644 --- a/app/repositories/active_record/user_repository.rb +++ b/app/repositories/active_record/user_repository.rb @@ -1,5 +1,6 @@ module ActiveRecord class UserRepository + class MethodNotImplementedError < NoMethodError; end def find(*ids) User.find ids @@ -21,5 +22,9 @@ module ActiveRecord user.destroy end + def ensure_is_graph_node(user) + raise MethodNotImplementedError, 'This method is implement only for graph repositories' + end + end end \ No newline at end of file diff --git a/app/repositories/orient_db/highlight_repository.rb b/app/repositories/orient_db/highlight_repository.rb index 8d678645222f98338e0ef13903debf4cf10df23e..668cfd502d93c713e399b2852b8b2b094a1c5d60 100644 --- a/app/repositories/orient_db/highlight_repository.rb +++ b/app/repositories/orient_db/highlight_repository.rb @@ -2,18 +2,16 @@ module OrientDb class HighlightRepository < Base def find_all - connection.query "SELECT FROM Highlight" + connection.query "SELECT * FROM Highlight" end - def insert_data (name,url) - connection.command "INSERT INTO Highlight (name,URL) VALUES ('#{name}','#{url}')" + def insert_data (name, url) + connection.command "INSERT INTO Highlight (name,URL) VALUES ('#{name}','#{url}')" end def destroy_data(id) - return @connection.command "DELETE VERTEX Highlight where @rid = '#{id}'" - rescue - return nil + @connection.command "DELETE VERTEX Highlight where @rid = '#{id}'" end end diff --git a/app/repositories/orient_db/user_repository.rb b/app/repositories/orient_db/user_repository.rb index 5e77c2c2ce71df99b49aaf3a28eba1dc5c3af3f4..2c912f36825b4ba4b22bdeb3f950c9c22529ec32 100644 --- a/app/repositories/orient_db/user_repository.rb +++ b/app/repositories/orient_db/user_repository.rb @@ -17,7 +17,15 @@ module OrientDb def destroy(user) end - private + def find_by_email(email) + connection.query sprintf("SELECT FROM User WHERE @email = '%s'", email) + end + + def ensure_is_graph_node(user) + if find_by_email(user.email).nil? + return save(user) + end + end def find_by_id(rid) connection.query "SELECT FROM User WHERE @rid=#{rid}" diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 3ea40f0148a37063c43e7c00ffcbb8fc1e66b91f..51ee35d468d244240877322f4c038e7af2f87448 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,39 +1,44 @@ <h2>Edit <%= resource_name.to_s.humanize %></h2> -<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> - <%= devise_error_messages! %> - - <div class="field"> - <%= f.label :email %><br /> - <%= f.email_field :email, autofocus: true %> - </div> - - <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> - <div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div> - <% end %> - - <div class="field"> - <%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br /> - <%= f.password_field :password, autocomplete: "off" %> - </div> - - <div class="field"> - <%= f.label :password_confirmation %><br /> - <%= f.password_field :password_confirmation, autocomplete: "off" %> - </div> - - <div class="field"> - <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br /> - <%= f.password_field :current_password, autocomplete: "off" %> - </div> - - <div class="actions"> - <%= f.submit "Update" %> - </div> +<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {method: :put}) do |f| %> + <%= devise_error_messages! %> + + <div class="field"> + <%= f.label :name %><br/> + <%= f.text_field :name, autofocus: true, required: true %> + </div> + + <div class="field"> + <%= f.label :email %><br/> + <%= f.email_field :email, autofocus: true %> + </div> + + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> + <div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div> + <% end %> + + <div class="field"> + <%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br/> + <%= f.password_field :password, autocomplete: "off" %> + </div> + + <div class="field"> + <%= f.label :password_confirmation %><br/> + <%= f.password_field :password_confirmation, autocomplete: "off" %> + </div> + + <div class="field"> + <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br/> + <%= f.password_field :current_password, autocomplete: "off" %> + </div> + + <div class="actions"> + <%= f.submit "Update" %> + </div> <% end %> <h3>Cancel my account</h3> -<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p> +<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: {confirm: "Are you sure?"}, method: :delete %></p> <%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index 5a238ce6eba330c494ecc77443fd4625e97df81e..f67db65b8b4ba004f64cfe6faaff987c4cf0060d 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -1,29 +1,34 @@ <h2>Sign up</h2> <%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> - <%= devise_error_messages! %> + <%= devise_error_messages! %> - <div class="field"> - <%= f.label :email %><br /> - <%= f.email_field :email, autofocus: true %> - </div> + <div class="field"> + <%= f.label :name %><br/> + <%= f.text_field :name, autofocus: true, required: true %> + </div> - <div class="field"> - <%= f.label :password %> - <% if @minimum_password_length %> - <em>(<%= @minimum_password_length %> characters minimum)</em> - <% end %><br /> - <%= f.password_field :password, autocomplete: "off" %> - </div> + <div class="field"> + <%= f.label :email %><br/> + <%= f.email_field :email, required: true %> + </div> - <div class="field"> - <%= f.label :password_confirmation %><br /> - <%= f.password_field :password_confirmation, autocomplete: "off" %> - </div> + <div class="field"> + <%= f.label :password %> + <% if @minimum_password_length %> + <em>(<%= @minimum_password_length %> characters minimum)</em> + <% end %><br/> + <%= f.password_field :password, autocomplete: "off" %> + </div> - <div class="actions"> - <%= f.submit "Sign up" %> - </div> + <div class="field"> + <%= f.label :password_confirmation %><br/> + <%= f.password_field :password_confirmation, autocomplete: "off" %> + </div> + + <div class="actions"> + <%= f.submit "Sign up" %> + </div> <% end %> <%= render "devise/shared/links" %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index de6f18b5eb2f595325f1fc47ee26f54b61e6f40c..75255c10fb0f2a9e9c349b29c986ae8ae89353c7 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -20,10 +20,6 @@ <div id="wrapper"> <%= render 'shared/application/header' %> - <% flash.each do |key, value| %> - <%= content_tag :div, value, class: "flash #{key}" %> - <% end %> - <% if notice %> <%= notice %> <% end %> diff --git a/app/views/layouts/management.html.erb b/app/views/layouts/management.html.erb index f238180e33e0b7f45a4ea46d5f5763c696333078..5a31b893032b6d869c23a4737ff5e0e68f53a4b0 100644 --- a/app/views/layouts/management.html.erb +++ b/app/views/layouts/management.html.erb @@ -19,38 +19,12 @@ <div class="ls-topbar"> <!-- Notification bar --> - <div class="ls-notification-topbar"> - <!-- Link of support/help --> - <div class="ls-alerts-list"> - <a href="#" class="ls-ico-bell-o" data-counter="5" data-ls-module="topbarCurtain" data-target="#ls-notification-curtain"><span>Notificações</span></a> - <a href="#" class="ls-ico-bullhorn" data-ls-module="topbarCurtain" data-target="#ls-help-curtain"><span>Ajuda</span></a> - <a href="#" class="ls-ico-question" data-ls-module="topbarCurtain" data-target="#ls-feedback-curtain"><span>Sugestões</span></a> - </div> - - <!-- User details --> - <div data-ls-module="dropdown" class="ls-dropdown ls-user-account"> - <a href="#" class="ls-ico-user"> - Carlos Marques - <small>(lstyle)</small> - </a> - <nav class="ls-dropdown-nav ls-user-menu"> - <ul> - <li><a href="#">Conta</a></li> - <li><a href="#">Logout</a></li> - </ul> - </nav> - </div> - </div> + <%= render 'shared/management/notification_bar' %> <span class="ls-show-sidebar ls-ico-menu"></span> - <!-- Nome do produto/marca --> - <h1 class="ls-brand-name"> - <a class="ls-ico-earth" href="/"> - <small>Management System</small> - Portal MEC - </a> - </h1> + <!-- product name --> + <%= render 'shared/management/product_name' %> </div> <main class="ls-main "> @@ -62,67 +36,14 @@ </main> <aside class="ls-sidebar"> - <!-- Defails of user account --> - <div data-ls-module="dropdown" class="ls-dropdown ls-user-account"> - <a href="#" class="ls-ico-user"> - Calum Hoyle - <small>(lstyle)</small> - </a> - <nav class="ls-dropdown-nav ls-user-menu"> - <ul> - <li><a href="#">submenu</a></li> - </ul> - </nav> - </div> + <%= render 'shared/management/user_account' %> <!--Menu à esquerda--> - <nav class="ls-menu"> - <ul> - <li><%= link_to "InÃcio", management_root_path, class: 'ls-ico-home' %></li> - <li><%= link_to "Objetos em destaque", management_highlights_path, class: 'ls-ico-star' %><li> - - <li class="ls-submenu"> - <a href="#" class="ls-ico-stats">EstatÃsticas</a> - <ul role="menu"> - <li><%= link_to "Geral", management_index_statistics_path, class: 'ls-submenu-item' %></li> - <li><%= link_to "Usuários", management_users_statistics_path, class: 'ls-submenu-item' %></li> - <li><%= link_to "Coleções", management_collections_statistics_path, class: 'ls-submenu-item' %></li> - <li><%= link_to "Downloads", management_downloads_statistics_path, class: 'ls-submenu-item' %></li> - <li><%= link_to "Acessos", management_accesses_statistics_path, class: 'ls-submenu-item' %></li> - </ul> - </li> - <li><%= link_to "Usuários", management_users_path, class: 'ls-ico-users' %></li> - <li><%= link_to "Denúncias", '#', class: 'ls-ico-bullhorn' %><li> - </ul> - </nav> + <%= render 'shared/management/nav_menu' %> </aside> <aside class="ls-notification"> - <nav class="ls-notification-list" id="ls-notification-curtain" style="left: 1716px;"> - <h3 class="ls-title-2">Notificações</h3> - <ul> - <li class="ls-dismissable"> - <a href="#">Blanditiis est est dolorem iure voluptatem eos deleniti repellat et laborum consequatur</a> - <a href="#" data-ls-module="dismiss" class="ls-ico-close ls-close-notification"></a> - </li> - <li class="ls-dismissable"> - <a href="#">Similique eos rerum perferendis voluptatibus</a> - <a href="#" data-ls-module="dismiss" class="ls-ico-close ls-close-notification"></a> - </li> - <li class="ls-dismissable"> - <a href="#">Qui numquam iusto suscipit nisi qui unde</a> - <a href="#" data-ls-module="dismiss" class="ls-ico-close ls-close-notification"></a> - </li> - <li class="ls-dismissable"> - <a href="#">Nisi aut assumenda dignissimos qui ea in deserunt quo deleniti dolorum quo et consequatur</a> - <a href="#" data-ls-module="dismiss" class="ls-ico-close ls-close-notification"></a> - </li> - <li class="ls-dismissable"> - <a href="#">Sunt consequuntur aut aut a molestiae veritatis assumenda voluptas nam placeat eius ad</a> - <a href="#" data-ls-module="dismiss" class="ls-ico-close ls-close-notification"></a> - </li> - </ul> - </nav> + <%= render 'shared/management/notification_list' %> <nav class="ls-notification-list" id="ls-help-curtain" style="left: 1756px;"> <h3 class="ls-title-2">Feedback</h3> @@ -144,4 +65,4 @@ </nav> </aside> </body> -</html> +</html> \ No newline at end of file diff --git a/app/views/management/users/_form.html.erb b/app/views/management/users/_form.html.erb index 8000a9d512eca00b8d0732a4ae54ba30cf997d5b..3efc7e93dbac97d66288f5b0a533fb07ee91939c 100644 --- a/app/views/management/users/_form.html.erb +++ b/app/views/management/users/_form.html.erb @@ -1,36 +1,60 @@ -<body> - <div> +<%= form_for([:management, @user], html: {class: 'ls-form row'}) do |f| %> - <%= form_tag( :action => "create", method: "post") do %> - <div> - <%= label_tag :name, "Nome" %><br><br> - <%= text_field_tag :name,'', placeholder: "nome completo" %> - </div> + <% if @user.errors.any? %> + <div class="ls-alert-danger"> + <h2><%= pluralize(@user.errors.count, "erro") %> <%= "happened".pluralize(@user.errors.count) %>:</h2> + <ul> + <% @user.errors.full_messages.each do |message| %> + <li><%= message %></li> + <% end %> + </ul> + </div> + <% end %> - <div> - <%= label_tag :email, "E-mail " %><br><br> - <%= email_field_tag :email, '', placeholder: "e-mail" %> - <%= submit_tag "Salvar", class: "ls-btn" %> - </div> + <fieldset> + <label class="ls-label col-md-3"> + <b class="ls-label-text">Nome</b> - <div> - <%= label_tag :state, "Estado " %><br><br> - <%= text_field_tag :state, '', placeholder: "" %> - <%= submit_tag "Salvar", class: "ls-btn" %> - </div> + <p>Digite o nome completo</p> + <%= f.text_field :name, {required: true} %> + </label> + <label class="ls-label col-md-5"> + <b class="ls-label-text">E-mail</b> - <div> - <%= label_tag :password, "Senha " %><br><br> - <%= password_field_tag :password, '', placeholder: "senha" %> - <%= submit_tag "Salvar", class: "ls-btn" %> - </div> + <p>Um e-email válido, pois será utilizado para validar a conta</p> + <%= f.email_field :email, {required: true} %> + </label> + </fieldset> + + <hr> + + <fieldset> + + <label class="ls-label col-md-4"> + <b class="ls-label-text">Senha</b> + + <div class="ls-prefix-group"> + <%= f.password_field :password, {required: true, minlenght: 6, id: 'pass'} %> + <a class="ls-label-text-prefix ls-toggle-pass ls-ico-eye" data-toggle-class="ls-ico-eye, ls-ico-eye-blocked" data-target="#pass" href="#"></a> + </div> + </label> + + </fieldset> + + <hr> + + <fieldset> + + <div class="ls-label col-md-5"> + <p>Selecione as responsabilidades do usuário:</p> + + <%= f.collection_check_boxes :role_ids, @roles, :id, :name %> + </div> + </fieldset> - <div> - <%= label_tag :confirm_password, "Confirmação da Senha " %><br><br> - <%= password_field_tag :confirm_password, '', placeholder: "confirme sua senha" %> - <%= submit_tag "Salvar", class: "ls-btn" %> + <div class="ls-actions-btn"> + <button class="ls-btn">Salvar</button> + <button class="ls-btn-danger">Cancelar</button> </div> - <% end %> - </div> -</body> +<% end %> \ No newline at end of file diff --git a/app/views/management/users/new.html.erb b/app/views/management/users/new.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..5cac49569c1a8729509a601370ed1d1bc9bfc4f7 --- /dev/null +++ b/app/views/management/users/new.html.erb @@ -0,0 +1,8 @@ +<h1 class="ls-title-intro ls-ico-users">Usuários</h1> + +<ol class="ls-breadcrumb"> + <li><a href="#">Usuários</a></li> + <li>Novo usuário</li> +</ol> + +<%= render 'form' %> \ No newline at end of file diff --git a/app/views/shared/application/_header.html.erb b/app/views/shared/application/_header.html.erb index a02088ab3527f9045d7927e044152d8aca6b7284..b58d17a67b7dcd2d73026e4f35e1e94a3a0601a0 100644 --- a/app/views/shared/application/_header.html.erb +++ b/app/views/shared/application/_header.html.erb @@ -25,11 +25,14 @@ <%= image_tag 'contraste.png', onclick: 'changeContrast()', height: '30px' %> <% if user_signed_in? %> - <%= link_to current_user.email, edit_user_registration_path %> + <%= link_to current_user.name, edit_user_registration_path %> + | + <%= link_to 'Sair', destroy_user_session_path, :method=>'delete' %> <% else %> - <%= link_to 'Entrar', new_user_session_path %> | <%= link_to 'Cadastro', new_user_registration_path %> + <%= link_to 'Entrar', new_user_session_path %> + | + <%= link_to 'Cadastro', new_user_registration_path %> <% end %> - </h2> </div> <div class="row"> diff --git a/app/views/shared/management/_nav_menu.html.erb b/app/views/shared/management/_nav_menu.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..3b8b8e725bf19176df73c3708fbb023960be7485 --- /dev/null +++ b/app/views/shared/management/_nav_menu.html.erb @@ -0,0 +1,28 @@ +<nav class="ls-menu"> + <ul> + <li><%= link_to "InÃcio", management_root_path, class: 'ls-ico-home' %></li> + <li><%= link_to "Objetos em destaque", management_highlights_path, class: 'ls-ico-star' %> + <li> + + <li class="ls-submenu"> + <a href="#" class="ls-ico-stats">EstatÃsticas</a> + <ul role="menu"> + <li><%= link_to "Geral", management_index_statistics_path, class: 'ls-submenu-item' %></li> + <li><%= link_to "Usuários", management_users_statistics_path, class: 'ls-submenu-item' %></li> + <li><%= link_to "Coleções", management_collections_statistics_path, class: 'ls-submenu-item' %></li> + <li><%= link_to "Downloads", management_downloads_statistics_path, class: 'ls-submenu-item' %></li> + <li><%= link_to "Acessos", management_accesses_statistics_path, class: 'ls-submenu-item' %></li> + </ul> + </li> + <li class="ls-submenu"> + <a href="#" class="ls-ico-stats">Usuários e permissões</a> + <ul role="menu"> + <li><%= link_to "Usuários", management_users_path, class: 'ls-submenu-item' %></li> + <li><%= link_to "Curadores", '#', class: 'ls-submenu-item' %></li> + <li><%= link_to "Administradores", '#', class: 'ls-submenu-item' %></li> + </ul> + </li> + <li><%= link_to "Denúncias", '#', class: 'ls-ico-bullhorn' %> + <li> + </ul> +</nav> \ No newline at end of file diff --git a/app/views/shared/management/_notification_bar.html.erb b/app/views/shared/management/_notification_bar.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..5cd1149ff4d6dcf02b303c0ed6a3f67584122c55 --- /dev/null +++ b/app/views/shared/management/_notification_bar.html.erb @@ -0,0 +1,11 @@ +<div class="ls-notification-topbar"> + <!-- Link of support/help --> + <div class="ls-alerts-list"> + <a href="#" class="ls-ico-bell-o" data-counter="5" data-ls-module="topbarCurtain" data-target="#ls-notification-curtain"><span>Notificações</span></a> + <a href="#" class="ls-ico-bullhorn" data-ls-module="topbarCurtain" data-target="#ls-help-curtain"><span>Ajuda</span></a> + <a href="#" class="ls-ico-question" data-ls-module="topbarCurtain" data-target="#ls-feedback-curtain"><span>Sugestões</span></a> + </div> + + <!-- User details --> + <%= render 'shared/management/user_account' %> +</div> \ No newline at end of file diff --git a/app/views/shared/management/_notification_list.html.erb b/app/views/shared/management/_notification_list.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..5cbe2f36591dcb7424f12d41a18f236e0b293681 --- /dev/null +++ b/app/views/shared/management/_notification_list.html.erb @@ -0,0 +1,25 @@ +<nav class="ls-notification-list" id="ls-notification-curtain" style="left: 1716px;"> + <h3 class="ls-title-2">Notificações</h3> + <ul> + <li class="ls-dismissable"> + <a href="#">Blanditiis est est dolorem iure voluptatem eos deleniti repellat et laborum consequatur</a> + <a href="#" data-ls-module="dismiss" class="ls-ico-close ls-close-notification"></a> + </li> + <li class="ls-dismissable"> + <a href="#">Similique eos rerum perferendis voluptatibus</a> + <a href="#" data-ls-module="dismiss" class="ls-ico-close ls-close-notification"></a> + </li> + <li class="ls-dismissable"> + <a href="#">Qui numquam iusto suscipit nisi qui unde</a> + <a href="#" data-ls-module="dismiss" class="ls-ico-close ls-close-notification"></a> + </li> + <li class="ls-dismissable"> + <a href="#">Nisi aut assumenda dignissimos qui ea in deserunt quo deleniti dolorum quo et consequatur</a> + <a href="#" data-ls-module="dismiss" class="ls-ico-close ls-close-notification"></a> + </li> + <li class="ls-dismissable"> + <a href="#">Sunt consequuntur aut aut a molestiae veritatis assumenda voluptas nam placeat eius ad</a> + <a href="#" data-ls-module="dismiss" class="ls-ico-close ls-close-notification"></a> + </li> + </ul> +</nav> \ No newline at end of file diff --git a/app/views/shared/management/_product_name.html.erb b/app/views/shared/management/_product_name.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..b8c69aa3f5b41236b7615592f9523f021cc4f434 --- /dev/null +++ b/app/views/shared/management/_product_name.html.erb @@ -0,0 +1,6 @@ +<h1 class="ls-brand-name"> + <a class="ls-ico-earth" href="/"> + <small>Management System</small> + Portal MEC + </a> +</h1> \ No newline at end of file diff --git a/app/views/shared/management/_user_account.html.erb b/app/views/shared/management/_user_account.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..6fc0661f8492d67f5b0d11b9e67ec1664982416e --- /dev/null +++ b/app/views/shared/management/_user_account.html.erb @@ -0,0 +1,12 @@ +<div data-ls-module="dropdown" class="ls-dropdown ls-user-account"> + <a href="#" class="ls-ico-user"> + Carlos Marques + <small>(lstyle)</small> + </a> + <nav class="ls-dropdown-nav ls-user-menu"> + <ul> + <li><a href="#">Conta</a></li> + <li><a href="#">Logout</a></li> + </ul> + </nav> +</div> \ No newline at end of file diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 2fe7a9a67f78a4f66356d9d84ed805b91fb409ca..f29fa86c004f7f24b8365a0c2ed71f97b3f5f364 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -6,13 +6,13 @@ Devise.setup do |config| # confirmation, reset password and unlock tokens in the database. # Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key` # by default. You can change it below and use your own secret key. - config.secret_key = 'f7c95d45a707ef0281bb68ca1632abee8fc4238287245e50eb3ac8132837a9a0561ef3cfa16b9d879595717c3ff804b0e3585cad7190edbfe6b051b7fa32d4b7' + config.secret_key = '8a5e454bf7120cdd81e6aa917bf63fab66cc10794f4732aab492bd89cda65b0320327e02718d4f13fc9ea3956d12fbe022b830e2ffc9adb0c6ff9119edabf713' # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use your own mailer class # with default "from" parameter. - config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com' + config.mailer_sender = 'suporte@c3sl.ufpr.br' # Configure the class responsible to send e-mails. # config.mailer = 'Devise::Mailer' @@ -99,7 +99,7 @@ Devise.setup do |config| config.stretches = Rails.env.test? ? 1 : 10 # Setup a pepper to generate the encrypted password. - # config.pepper = '381b4fd6d17ae053e8cdb90006658cfdbe52323f5e3c8bdfc1878754d14df7a0226df6d1c6f13c64dcd20e2877e8a837b4c7a1a7912e6466784f27d5155d19ad' + # config.pepper = '62f7713e8428f204e0ecc9d9687fbe060840404fd26fb6b8762cb1a51af7210fbe3ff884fd4de7934becbf4de4daa1539d7645a9ab0b3733237b91aa733d8783' # ==> Configuration for :confirmable # A period that the user is allowed to access the website even without @@ -154,9 +154,6 @@ Devise.setup do |config| # time the user will be asked for credentials again. Default is 30 minutes. # config.timeout_in = 30.minutes - # If true, expires auth token on session timeout. - # config.expire_auth_token_on_timeout = false - # ==> Configuration for :lockable # Defines which strategy will be used to lock an account. # :failed_attempts = Locks an account after a number of failed attempts to sign in. diff --git a/config/initializers/devise_token_auth.rb b/config/initializers/devise_token_auth.rb deleted file mode 100644 index e158e784f9b2e368489acf59a872f6a5a56718a1..0000000000000000000000000000000000000000 --- a/config/initializers/devise_token_auth.rb +++ /dev/null @@ -1,28 +0,0 @@ -DeviseTokenAuth.setup do |config| - # By default the authorization headers will change after each request. The - # client is responsible for keeping track of the changing tokens. Change - # this to false to prevent the Authorization header from changing after - # each request. - #config.change_headers_on_each_request = true - - # By default, users will need to re-authenticate after 2 weeks. This setting - # determines how long tokens will remain valid after they are issued. - #config.token_lifespan = 2.weeks - - # Sometimes it's necessary to make several requests to the API at the same - # time. In this case, each request in the batch will need to share the same - # auth token. This setting determines how far apart the requests can be while - # still using the same auth token. - #config.batch_request_buffer_throttle = 5.seconds - - # This route will be the prefix for all oauth2 redirect callbacks. For - # example, using the default '/omniauth', the github oauth2 provider will - # redirect successful authentications to '/omniauth/github/callback' - #config.omniauth_prefix = "/omniauth" - - # By defult sending current password is not needed for the password update. - # Uncomment to enforce current_password param to be checked before all - # attribute updates. Set it to :password if you want it to be checked only if - # password is updated. - # config.check_current_password_before_update = :attributes -end diff --git a/config/orientdb.yml b/config/orientdb.yml index 67492f22e327cffdb5eafc3e4dbd15a10adebe15..1169c03a50b1a83eaff953b7fc909adfeea45318 100644 --- a/config/orientdb.yml +++ b/config/orientdb.yml @@ -1,6 +1,6 @@ development: &development - host: mecdb2.c3sl.ufpr.br - database: dev-mauricio + host: localhost + database: portalmec username: admin password: admin port: 2480 @@ -10,11 +10,4 @@ test: database: PortalMEC username: admin password: admin - port: 2480 - -production: - host: <%= ENV['PORTALMEC_ORIENTDB_HOST'] %> - database: <%= ENV['PORTALMEC_ORIENTDB_DATABASE'] %> - username: <%= ENV['PORTALMEC_ORIENTDB_USERNAME'] %> - password: <%= ENV['PORTALMEC_ORIENTDB_PASSWD'] %> - port: <%= ENV['PORTALMEC_ORIENTDB_PORT'] %> \ No newline at end of file + port: 2480 \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 6dc4098969879fa693efc806f4a62d7fc85cc61d..e14132cc1806521462968e6fb2fb901b37660e38 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,11 +1,5 @@ Rails.application.routes.draw do - devise_for :users, controllers: {registrations: :registrations} - namespace :auth do - mount_devise_token_auth_for 'User', skip: [:omniauth_callbacks] - end - - # devise_for :users - + devise_for :users namespace :management do root 'welcome#index' diff --git a/db/migrate/20150904134929_create_roles.rb b/db/migrate/20150904134929_create_roles.rb new file mode 100644 index 0000000000000000000000000000000000000000..927ceff15307846b5fc62d75e01b36e28d474dee --- /dev/null +++ b/db/migrate/20150904134929_create_roles.rb @@ -0,0 +1,11 @@ +class CreateRoles < ActiveRecord::Migration + def change + create_table :roles do |t| + t.string :name + t.text :description + + t.timestamps null: false + end + add_index :roles, :name, unique: true + end +end diff --git a/db/migrate/20150904141558_create_join_table_users_roles.rb b/db/migrate/20150904141558_create_join_table_users_roles.rb new file mode 100644 index 0000000000000000000000000000000000000000..ea9807f83d809800cede481f31053bd92112af1a --- /dev/null +++ b/db/migrate/20150904141558_create_join_table_users_roles.rb @@ -0,0 +1,8 @@ +class CreateJoinTableUsersRoles < ActiveRecord::Migration + def change + create_join_table :users, :roles do |t| + t.index :user_id + t.index :role_id + end + end +end diff --git a/db/migrate/20150909135745_add_name_column_to_users.rb b/db/migrate/20150909135745_add_name_column_to_users.rb new file mode 100644 index 0000000000000000000000000000000000000000..82bb9cff6950de7213db0eb41bd4a8985caf5870 --- /dev/null +++ b/db/migrate/20150909135745_add_name_column_to_users.rb @@ -0,0 +1,5 @@ +class AddNameColumnToUsers < ActiveRecord::Migration + def change + add_column :users, :name, :string + end +end diff --git a/db/seeds.rb b/db/seeds.rb index 4edb1e857ee6c203463c7fa0387aae32496ec93d..1c2b4f8c534d8140d806c1f4baa7da19cd6a5152 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,6 @@ # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) +Role.create(name: 'teacher', description: 'This role represents a Teacher in Portal MEC.') +Role.create(name: 'admin', description: 'This role represents an MEC Admin, that can perform any action.') +Role.create(name: 'curator', description: 'This role represents a content Curator in Portal MEC.') \ No newline at end of file diff --git a/test/controllers/management/welcome_controller_test.rb b/test/controllers/management/welcome_controller_test.rb index f19d31e055d784b216b5c8254da11180c1e986f5..b080784bf71258fc8be6f9f555cdf06631224781 100644 --- a/test/controllers/management/welcome_controller_test.rb +++ b/test/controllers/management/welcome_controller_test.rb @@ -1,6 +1,8 @@ require 'test_helper' class Management::WelcomeControllerTest < ActionController::TestCase + tests Management::WelcomeController + test "should get index" do get :index assert_response :success diff --git a/test/controllers/registrations_controller_test.rb b/test/controllers/registrations_controller_test.rb deleted file mode 100644 index 3571cdd05aee054a2a20e976b4c5599106c5722a..0000000000000000000000000000000000000000 --- a/test/controllers/registrations_controller_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class RegistrationsControllerTest < ActionController::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/controllers/university_controller_test.rb b/test/controllers/university_controller_test.rb index d258c1ba7eaddb97328d90003fdcecdcd4e8a7a7..747c990f3abc2a6eb3c26f96a5f57eaf27e36395 100644 --- a/test/controllers/university_controller_test.rb +++ b/test/controllers/university_controller_test.rb @@ -4,9 +4,8 @@ class UniversityControllerTest < ActionController::TestCase tests UniversitiesController test "should get index" do - #get :index - #assert_response :success - assert true + get :index + assert_response :success end end diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb deleted file mode 100644 index a1fa5b34c2cfbcad6aa161426af14d8f06f5a17c..0000000000000000000000000000000000000000 --- a/test/controllers/users_controller_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require 'test_helper' - -class UsersControllerTest < ActionController::TestCase - test "should get index" do - # get :index - # assert_response :success - assert true - end - -end diff --git a/test/controllers/welcome_controller_test.rb b/test/controllers/welcome_controller_test.rb index 60c05b114a611e16770fb0e98624e743b9cf78eb..954ffa058949277ff746d817c868d5b1dccd6a06 100644 --- a/test/controllers/welcome_controller_test.rb +++ b/test/controllers/welcome_controller_test.rb @@ -1,10 +1,11 @@ require 'test_helper' class WelcomeControllerTest < ActionController::TestCase + tests WelcomeController + test "should get index" do - # get :index - # assert_response :success - assert true + get :index + assert_response :success end -end +end \ No newline at end of file diff --git a/test/fixtures/roles.yml b/test/fixtures/roles.yml new file mode 100644 index 0000000000000000000000000000000000000000..f35b3bf1f2e3b5edbb7a0521ca75bbdcfaddeb93 --- /dev/null +++ b/test/fixtures/roles.yml @@ -0,0 +1,13 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +admin: + name: admin + description: MyText + +teacher: + name: teacher + description: MyText + +curator: + name: curator + description: MyText \ No newline at end of file diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml index 989ce90a0575f7a8a289a40a7301ff6f6e65ff95..e7c2ceefe67d37c925d3243bfb4110b900ec03a8 100644 --- a/test/fixtures/users.yml +++ b/test/fixtures/users.yml @@ -1,5 +1,7 @@ one: email: 'mgg12@inf.ufpr.br' + provider: 'email' two: - email: 'test@c3sl.ufpr.br' \ No newline at end of file + email: 'test@c3sl.ufpr.br' + provider: 'email' \ No newline at end of file diff --git a/test/models/role_test.rb b/test/models/role_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..400bdfd312509486ade76489b3d4cb3b550234b0 --- /dev/null +++ b/test/models/role_test.rb @@ -0,0 +1,5 @@ +require 'test_helper' + +class RoleTest < ActiveSupport::TestCase + should have_and_belong_to_many(:users) +end diff --git a/test/models/user_test.rb b/test/models/user_test.rb index 636d460edad619b8548abaec67554f4a442598ba..3badf9c73309065222b240f94fcf03f2d6d8f660 100644 --- a/test/models/user_test.rb +++ b/test/models/user_test.rb @@ -1,7 +1,5 @@ require 'test_helper' class UserTest < ActiveSupport::TestCase - test 'true' do - assert true - end + should have_and_belong_to_many(:roles) end