Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #116 from omu/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
msdundar authored Jul 14, 2018
2 parents c06405c + f524ef4 commit 7a538ba
Show file tree
Hide file tree
Showing 30 changed files with 285 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'

# view helpers: tools for forms, views, etc.
gem 'chartkick'
gem 'cocoon'
gem 'font-awesome-rails'
gem 'groupdate' # for chartkick
gem 'pagy'
gem 'simple_form'

Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ GEM
rack (>= 1.6.0)
rack-test (>= 0.6.3)
xpath (~> 3.1)
chartkick (2.3.5)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chromedriver-helper (1.2.0)
Expand Down Expand Up @@ -126,6 +127,8 @@ GEM
activerecord (>= 4.0.0)
globalid (0.4.1)
activesupport (>= 4.2.0)
groupdate (4.0.1)
activesupport (>= 4.2)
gyoku (1.3.1)
builder (>= 2.1.2)
httpi (2.4.3)
Expand Down Expand Up @@ -337,6 +340,7 @@ DEPENDENCIES
bundler-audit
byebug
capybara (>= 2.15, < 4.0)
chartkick
chromedriver-helper
cocoon
codacy-coverage
Expand All @@ -346,6 +350,7 @@ DEPENDENCIES
email_address
font-awesome-rails
friendly_id (~> 5.1.0)
groupdate
jbuilder (~> 2.5)
letter_opener
listen (>= 3.0.5, < 3.2)
Expand Down
2 changes: 2 additions & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
//= require perfect-scrollbar/dist/perfect-scrollbar.min
//= require select2/dist/js/select2.min
//= require jquery.maskedinput/src/jquery.maskedinput
//= require Chart.bundle
//= require chartkick
9 changes: 9 additions & 0 deletions app/controllers/studies/articles_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

module Studies
class ArticlesController < ApplicationController
include Pagy::Backend

def index; end
end
end
7 changes: 7 additions & 0 deletions app/controllers/studies/certifications_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module Studies
class CertificationsController < ApplicationController
def index; end
end
end
7 changes: 7 additions & 0 deletions app/controllers/studies/dashboard_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module Studies
class DashboardController < ApplicationController
def index; end
end
end
7 changes: 7 additions & 0 deletions app/controllers/studies/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module Studies
class ProjectsController < ApplicationController
def index; end
end
end
19 changes: 19 additions & 0 deletions app/helpers/apa_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module ApaHelper
def apa_citation(article)
title = article.title.capitalize_all

"#{authors_in_apa_format(article)}. (#{article.year}). #{title}. #{article.journal}, \
#{article.volume}(#{article.issue}), #{article.first_page}-#{article.last_page}"
end

def authors_in_apa_format(article)
article.authors.split(',').map do |author|
names = author.split
last_name = names.shift.capitalize_all
first_name = names.map(&:first).join('. ')
"#{last_name}, #{first_name}"
end.join(' & ')
end
end
1 change: 0 additions & 1 deletion app/jobs/yoksis/articles_create_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ def perform(user)
end

# callbacks

# rubocop:disable Metrics/BlockLength
after_perform do |job|
user = job.arguments.first
Expand Down
17 changes: 13 additions & 4 deletions app/models/academic_studies/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ class Article < ApplicationRecord
self.inheritance_column = nil

# relations
belongs_to :user
belongs_to :user, counter_cache: true

# validations
validates :yoksis_id, presence: true
validates :yoksis_id, presence: true, uniqueness: { scope: %i[user_id status] }
validates :title, presence: true

# enums
Expand Down Expand Up @@ -36,7 +36,8 @@ class Article < ApplicationRecord
eric: 55,
esci: 56,
index_chemicus: 59,
turkish_index: 45
turkish_index: 45,
art_index: 62
}

enum type: {
Expand All @@ -48,8 +49,16 @@ class Article < ApplicationRecord
abstract: 6,
book_review: 7,
research_note: 8,
export_report: 9,
expert_report: 9,
review_article: 10,
short_article: 11
}

def self.unique_count
active.group_by(&:yoksis_id).count
end

def self.most_recent
order(created_at: :desc).limit(10)
end
end
4 changes: 2 additions & 2 deletions app/models/academic_studies/certification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ class Certification < ApplicationRecord
belongs_to :user

# validations
validates :yoksis_id, presence: true
validates :type, presence: true
validates :yoksis_id, presence: true, uniqueness: { scope: %i[user_id status] }
validates :title, presence: true
validates :type, presence: true

# enums
enum type: {
Expand Down
4 changes: 2 additions & 2 deletions app/models/academic_studies/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ class Project < ApplicationRecord
self.inheritance_column = nil

# relations
belongs_to :user
belongs_to :user, counter_cache: true

# validations
validates :yoksis_id, presence: true
validates :yoksis_id, presence: true, uniqueness: { scope: %i[user_id status] }

# enums
enum status: {
Expand Down
1 change: 1 addition & 0 deletions app/models/unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Unit < ApplicationRecord
has_many :duties, dependent: :destroy
has_many :employees, through: :duties
has_many :students, dependent: :nullify
has_many :users, through: :employees
has_many :positions, through: :duties
has_many :administrative_functions, through: :duties

Expand Down
4 changes: 4 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ def build_identity_information
def accounts
(students + employees).flatten
end

def self.most_publishing
order('articles_count desc').limit(10)
end
end
6 changes: 6 additions & 0 deletions app/views/layouts/shared/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<%= link_to users_path, class: 'nav-link' do %>
<%= fa_icon('user', text: t('.users'), class: 'nav-icon') %>
<% end %>
</li>
<li class="nav-item nav-dropdown">
<a class="nav-link nav-dropdown-toggle" href="#">
<%= fa_icon('university', class: 'nav-icon') %><%= t('.references') %>
Expand Down Expand Up @@ -130,6 +131,11 @@
</li>
</ul>
</li>
<li class="nav-item">
<%= link_to studies_path, class: 'nav-link' do %>
<%= fa_icon('file-text-o', text: t('.studies'), class: 'nav-icon') %>
<% end %>
</li>
</ul>
</nav>
<button class="sidebar-minimizer brand-minimizer" type="button"></button>
Expand Down
100 changes: 100 additions & 0 deletions app/views/studies/articles/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<div class="row">
<div class="col-sm-6">
<div class="card">
<div class="card-body p-3 d-flex align-items-center">
<i class="fa fa-cogs bg-primary p-3 font-2xl mr-3"></i>
<div>
<div class="text-value-sm text-primary"><%= Article.unique_count %></div>
<div class="text-muted text-uppercase font-weight-bold small"><%= t('.article') %></div>
</div>
</div>
</div>
</div>
</div>

<div class="row">
<div class="col-sm-6">
<div class="card">
<div class="card-header">
<i class="fa fa-align-justify"></i> <%= t('.top_publishers') %>
</div>
<div class="card-body">
<ul class="list-group">
<% User.most_publishing.each do |user| %>
<li class="list-group-item"><%= user.identities.first.try(:first_name) %></li>
<% end %>
</ul>
</div>
</div>
</div>

<div class="col-sm-6">
<div class="card">
<div class="card-header">
<i class="fa fa-align-justify"></i> <%= t('.recently_added') %>
</div>
<div class="card-body">
<ul class="list-group">
<% Article.most_recent.each do |article| %>
<small><li class="list-group-item"><%= apa_citation(article) %></li></small>
<% end %>
</ul>
</div>
</div>
</div>

<div class="col-sm-12">
<div class="card">
<div class='card-header'>
<%= t('.number_of_articles_by_years') %>
</div>
<div class="card-body">
<%= line_chart Article.active.group(:year).count %>
</div>
</div>
</div>


<div class="col-sm-6">
<div class="card">
<div class='card-header'>
<%= t('.publications_by_index_types') %>
</div>
<div class="card-body">
<%= column_chart Article.active.group(:index).count %>
</div>
</div>
</div>
<div class="col-sm-6">
<div class="card">
<div class='card-header'>
<%= t('.publications_by_publication_types') %>
</div>
<div class="card-body">
<%= column_chart Article.active.group(:type).count %>
</div>
</div>
</div>

<div class="col-sm-6">
<div class="card">
<div class='card-header'>
<%= t('.publications_by_language') %>
</div>
<div class="card-body">
<%= pie_chart Article.active.group(:language_of_publication).count %>
</div>
</div>
</div>

<div class="col-sm-6">
<div class="card">
<div class='card-header'>
<%= t('.publications_by_number_of_authors') %>
</div>
<div class="card-body">
<%= bar_chart Article.active.group(:number_of_authors).count %>
</div>
</div>
</div>
</div>
Empty file.
19 changes: 19 additions & 0 deletions app/views/studies/dashboard/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<div class="row">
<div class="col-sm-12">
<div class="card">
<div class="card-body">
<nav class="nav">
<%= link_to studies_articles_path, class: 'nav-link' do %>
<%= t('.articles') %>
<% end %>
<%= link_to studies_projects_path, class: 'nav-link' do %>
<%= t('.projects') %>
<% end %>
<%= link_to studies_certifications_path, class: 'nav-link' do %>
<%= t('.certifications') %>
<% end %>
</nav>
</div>
</div>
</div>
</div>
Empty file.
1 change: 1 addition & 0 deletions config/locales/layouts/shared/sidebar_en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ en:
unit_statuses: Unit Statuses
unit_types: Unit Types
university_types: University Types
studies: Academic Studies
1 change: 1 addition & 0 deletions config/locales/layouts/shared/sidebar_tr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ tr:
unit_statuses: Aktiflik Durumları
unit_types: Birim Türleri
university_types: Üniversite Türleri
studies: Akademik Çalışmalar
17 changes: 17 additions & 0 deletions config/locales/models/studies/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
en:
studies:
dashboard:
index:
articles: Articles
projects: Projects
certifications: Certifications
articles:
index:
article: Article
top_publishers: Top Publishing Academics
recently_added: Recently Added Articles
number_of_articles_by_years: Number of Articles by Years
publications_by_index_types: Publications by Index Types
publications_by_publication_types: Publications by Publication Types
publications_by_language: Publications by Publication Language
publications_by_number_of_authors: Publications by Number of Authors
17 changes: 17 additions & 0 deletions config/locales/models/studies/tr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
tr:
studies:
dashboard:
index:
articles: Makaleler
projects: Projeler
certifications: Sertifikalar
articles:
index:
article: Makale
top_publishers: En Çok Makalesi Olanlar
recently_added: En Son Eklenen Makaleler
number_of_articles_by_years: Yıllara Göre Makale Sayısı
publications_by_index_types: Index Türüne Göre Makaleler
publications_by_publication_types: Yayın Türüne Göre Makaleler
publications_by_language: Yayın Dili Göre Makaleler
publications_by_number_of_authors: Yazar Sayısına Göre Makaleler
7 changes: 7 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,11 @@
resources :unit_types, except: :show
resources :university_types, except: :show
end

scope module: :studies do
get '/studies', to: 'dashboard#index'
get '/studies/articles', to: 'articles#index'
get '/studies/projects', to: 'projects#index'
get '/studies/certifications', to: 'certifications#index'
end
end
Loading

0 comments on commit 7a538ba

Please sign in to comment.