remove administrate

and add will paginate (whereas administrate used kaminari)
This commit is contained in:
Torsten Ruger 2017-06-06 22:37:26 +03:00
parent a22794d5a2
commit 6fa5d0e572
22 changed files with 13 additions and 728 deletions

View File

@ -7,7 +7,6 @@ gem 'coffee-rails'
gem 'jquery-rails'
gem "therubyracer"
gem 'administrate'
gem 'bootstrap' , "4.0.0.alpha5"
gem "susy"
gem 'tether-rails'
@ -21,7 +20,7 @@ gem 'animate-scss' , :github => "ejholmes/animate.scss"
gem "best_in_place"
gem 'rack-attack'
gem "ransack"
gem "will_paginate"
gem "bootstrap-will_paginate"
gem 'jquery-ui-rails'
#asynchronous sending

View File

@ -47,18 +47,6 @@ GEM
tzinfo (~> 1.1)
addressable (2.5.1)
public_suffix (~> 2.0, >= 2.0.2)
administrate (0.7.0)
actionpack (>= 4.2, < 5.1)
actionview (>= 4.2, < 5.1)
activerecord (>= 4.2, < 5.1)
autoprefixer-rails (~> 6.0)
datetime_picker_rails (~> 0.0.7)
jquery-rails (>= 4.0)
kaminari (>= 1.0)
momentjs-rails (~> 2.8)
normalize-rails (>= 3.0)
sass-rails (~> 5.0)
selectize-rails (~> 0.6)
airbrussh (1.2.0)
sshkit (>= 1.6.1, != 1.7.0)
arel (7.1.4)
@ -71,6 +59,8 @@ GEM
bootstrap (4.0.0.alpha5)
autoprefixer-rails (>= 6.0.3)
sass (>= 3.4.19)
bootstrap-will_paginate (1.0.0)
will_paginate
builder (3.2.3)
byebug (9.0.6)
capistrano (3.8.1)
@ -112,8 +102,6 @@ GEM
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
database_cleaner (1.6.1)
datetime_picker_rails (0.0.7)
momentjs-rails (>= 2.8.1)
devise (4.3.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
@ -181,18 +169,6 @@ GEM
thor (>= 0.14, < 2.0)
jquery-ui-rails (5.0.5)
railties (>= 3.2.16)
kaminari (1.0.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.0.1)
kaminari-activerecord (= 1.0.1)
kaminari-core (= 1.0.1)
kaminari-actionview (1.0.1)
actionview
kaminari-core (= 1.0.1)
kaminari-activerecord (1.0.1)
activerecord
kaminari-core (= 1.0.1)
kaminari-core (1.0.1)
launchy (2.4.3)
addressable (~> 2.3)
libv8 (3.16.14.19)
@ -211,8 +187,6 @@ GEM
mime-types-data (3.2016.0521)
mini_portile2 (2.2.0)
minitest (5.10.2)
momentjs-rails (2.17.1)
railties (>= 3.1)
multi_json (1.12.1)
mysql2 (0.4.6)
nenv (0.3.0)
@ -223,7 +197,6 @@ GEM
nio4r (2.0.0)
nokogiri (1.8.0)
mini_portile2 (~> 2.2.0)
normalize-rails (4.1.1)
notiffany (0.1.1)
nenv (~> 0.1)
shellany (~> 0.0)
@ -321,7 +294,6 @@ GEM
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
selectize-rails (0.12.4)
selenium-webdriver (3.4.0)
childprocess (~> 0.5)
rubyzip (~> 1.0)
@ -382,10 +354,10 @@ PLATFORMS
ruby
DEPENDENCIES
administrate
animate-scss!
best_in_place
bootstrap (= 4.0.0.alpha5)
bootstrap-will_paginate
byebug
capistrano (= 3.8.1)
capistrano-bundler
@ -436,7 +408,6 @@ DEPENDENCIES
tether-rails
therubyracer
uglifier
will_paginate
BUNDLED WITH
1.15.1

View File

@ -25,7 +25,6 @@ $susy: (
@import 'bootstrap';
@import "course";
@import "web_dev";
@import "index";
@import "layout";
@import "answers";
@import "fancy";

View File

@ -1,18 +0,0 @@
# All Administrate controllers inherit from this `Admin::ApplicationController`,
# making it the ideal place to put authentication logic or other
# before_filters.
#
# If you want to add pagination or other controller-level concerns,
# you're free to overwrite the RESTful controller actions.
module Admin
class ApplicationController < Administrate::ApplicationController
before_filter :authenticate_admin
def authenticate_admin
user = current_user
if(user)
redirect_to "/" unless user.admin?
end
end
end
end

View File

@ -1,77 +0,0 @@
require "administrate/base_dashboard"
class ApplyDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
user: Field::BelongsTo,
primary_choice_course: Field::BelongsTo.with_options(class_name: "Course"),
secondary_choice_course: Field::BelongsTo.with_options(class_name: "Course"),
id: Field::Number,
plan: Field::String,
discount_code: Field::String,
comment: Field::Text,
sent: Field::DateTime,
accepted: Field::DateTime,
funds_received: Field::Number,
created_at: Field::DateTime,
updated_at: Field::DateTime,
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = [
:user,
:primary_choice_course,
:secondary_choice_course,
:id,
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = [
:user,
:primary_choice_course,
:secondary_choice_course,
:id,
:plan,
:discount_code,
:comment,
:sent,
:accepted,
:funds_received,
:created_at,
:updated_at,
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [
:user,
:primary_choice_course,
:secondary_choice_course,
:primary_choice_course_id,
:secondary_choice_course_id,
:plan,
:discount_code,
:comment,
:sent,
:accepted,
:funds_received,
].freeze
# Overwrite this method to customize how applies are displayed
# across all pages of the admin dashboard.
#
# def display_resource(apply)
# "Apply ##{apply.id}"
# end
end

View File

@ -1,57 +0,0 @@
require "administrate/base_dashboard"
class CourseDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
id: Field::Number,
name: Field::String,
extra: Field::String,
start: Field::DateTime,
created_at: Field::DateTime,
updated_at: Field::DateTime,
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = [
:id,
:name,
:extra,
:start,
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = [
:id,
:name,
:extra,
:start,
:created_at,
:updated_at,
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [
:name,
:extra,
:start,
].freeze
# Overwrite this method to customize how courses are displayed
# across all pages of the admin dashboard.
#
def display_resource(course)
course.name
end
end

View File

@ -1,93 +0,0 @@
require "administrate/base_dashboard"
class ResumeDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
user: Field::BelongsTo,
id: Field::Number,
street: Field::String,
city: Field::String,
country: Field::String,
school: Field::Text,
uni: Field::Text,
internship: Field::Text,
work: Field::Text,
projects: Field::Text,
soft_skills: Field::Text,
tech_skills: Field::Text,
interests: Field::Text,
motivation: Field::Text,
finance: Field::Text,
other: Field::Text,
created_at: Field::DateTime,
updated_at: Field::DateTime,
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = [
:user,
:id,
:street,
:city,
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = [
:user,
:id,
:street,
:city,
:country,
:school,
:uni,
:internship,
:work,
:projects,
:soft_skills,
:tech_skills,
:interests,
:motivation,
:finance,
:other,
:created_at,
:updated_at,
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [
:user,
:street,
:city,
:country,
:school,
:uni,
:internship,
:work,
:projects,
:soft_skills,
:tech_skills,
:interests,
:motivation,
:finance,
:other,
].freeze
# Overwrite this method to customize how resumes are displayed
# across all pages of the admin dashboard.
#
# def display_resource(resume)
# "Resume ##{resume.id}"
# end
end

View File

@ -1,99 +0,0 @@
require "administrate/base_dashboard"
class UserDashboard < Administrate::BaseDashboard
# ATTRIBUTE_TYPES
# a hash that describes the type of each of the model's fields.
#
# Each different type represents an Administrate::Field object,
# which determines how the attribute is displayed
# on pages throughout the dashboard.
ATTRIBUTE_TYPES = {
id: Field::Number,
email: Field::String,
encrypted_password: Field::String,
reset_password_token: Field::String,
reset_password_sent_at: Field::DateTime,
remember_created_at: Field::DateTime,
sign_in_count: Field::Number,
current_sign_in_at: Field::DateTime,
last_sign_in_at: Field::DateTime,
current_sign_in_ip: Field::String,
last_sign_in_ip: Field::String,
created_at: Field::DateTime,
updated_at: Field::DateTime,
name: Field::String,
confirmation_token: Field::String,
confirmed_at: Field::DateTime,
confirmation_sent_at: Field::DateTime,
unconfirmed_email: Field::String,
role: Field::String.with_options(searchable: false),
course_id: Field::Number,
}.freeze
# COLLECTION_ATTRIBUTES
# an array of attributes that will be displayed on the model's index page.
#
# By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = [
:id,
:email,
:confirmed_at,
:sign_in_count,
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = [
:id,
:email,
:encrypted_password,
:reset_password_token,
:reset_password_sent_at,
:remember_created_at,
:sign_in_count,
:current_sign_in_at,
:last_sign_in_at,
:current_sign_in_ip,
:last_sign_in_ip,
:created_at,
:updated_at,
:name,
:confirmation_token,
:confirmed_at,
:confirmation_sent_at,
:unconfirmed_email,
:role,
:course_id,
].freeze
# FORM_ATTRIBUTES
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = [
:email,
:encrypted_password,
:reset_password_token,
:reset_password_sent_at,
:remember_created_at,
:sign_in_count,
:current_sign_in_at,
:last_sign_in_at,
:current_sign_in_ip,
:last_sign_in_ip,
:name,
:confirmation_token,
:confirmed_at,
:confirmation_sent_at,
:unconfirmed_email,
:role,
:course_id,
].freeze
# Overwrite this method to customize how users are displayed
# across all pages of the admin dashboard.
def display_resource(user)
user.name
end
end

View File

@ -1,92 +0,0 @@
<%#
# Collection
This partial is used on the `index` and `show` pages
to display a collection of resources in an HTML table.
## Local variables:
- `collection_presenter`:
An instance of [Administrate::Page::Collection][1].
The table presenter uses `ResourceDashboard::COLLECTION_ATTRIBUTES` to determine
the columns displayed in the table
- `resources`:
An ActiveModel::Relation collection of resources to be displayed in the table.
By default, the number of resources is limited by pagination
or by a hard limit to prevent excessive page load times
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
%>
<table aria-labelledby="page-title">
<thead>
<tr>
<% collection_presenter.attribute_types.each do |attr_name, attr_type| %>
<th class="cell-label
cell-label--<%= attr_type.html_class %>
cell-label--<%= collection_presenter.ordered_html_class(attr_name) %>
" scope="col">
<%= link_to(sanitized_order_params.merge(
collection_presenter.order_params_for(attr_name)
)) do %>
<%= t(
"helpers.label.#{resource_name}.#{attr_name}",
default: attr_name.to_s,
).titleize %>
<% if collection_presenter.ordered_by?(attr_name) %>
<span class="cell-label__sort-indicator cell-label__sort-indicator--<%= collection_presenter.ordered_html_class(attr_name) %>">
<%= svg_tag(
"administrate/sort_arrow.svg",
"sort_arrow",
width: "13",
height: "13"
) %>
</span>
<% end %>
<% end %>
</th>
<% end %>
<% [valid_action?(:edit), valid_action?(:destroy)].count(true).times do %>
<th scope="col"></th>
<% end %>
</tr>
</thead>
<tbody>
<% resources.each do |resource| %>
<tr class="js-table-row"
tabindex="0"
<%= %(role=link data-url=#{polymorphic_path([namespace, resource])}) if valid_action? :show -%>
>
<% collection_presenter.attributes_for(resource).each do |attribute| %>
<td class="cell-data cell-data--<%= attribute.html_class %>">
<a href="<%= polymorphic_path([namespace, resource]) -%>"
class="action-show"
>
<%= render_field attribute %>
</a>
</td>
<% end %>
<% if valid_action? :edit %>
<td><%= link_to(
t("administrate.actions.edit"),
[:edit, namespace, resource],
class: "action-edit",
) %></td>
<% end %>
<% if valid_action? :destroy %>
<td><%= link_to(
t("administrate.actions.destroy"),
[namespace, resource],
class: "text-color-red",
method: :delete,
data: { confirm: t("administrate.actions.confirm") }
) %></td>
<% end %>
</tr>
<% end %>
</tbody>
</table>

View File

@ -1,4 +0,0 @@
- if flash.any?
.flashes
- flash.each do |key, value|
%div{:class => "flash flash-#{key}"}= value

View File

@ -1,42 +0,0 @@
<%#
# Form Partial
This partial is rendered on a resource's `new` and `edit` pages,
and renders all form fields for a resource's editable attributes.
## Local variables:
- `page`:
An instance of [Administrate::Page::Form][1].
Contains helper methods to display a form,
and knows which attributes should be displayed in the resource's form.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
%>
<%= form_for([namespace, page.resource], html: { class: "form" }) do |f| %>
<% if page.resource.errors.any? %>
<div id="error_explanation">
<h2>
<%= pluralize(page.resource.errors.count, "error") %>
prohibited this <%= page.resource_name %> from being saved:
</h2>
<ul>
<% page.resource.errors.full_messages.each do |message| %>
<li class="flash-error"><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<% page.attributes.each do |attribute| -%>
<div class="field-unit field-unit--<%= attribute.html_class %>">
<%= render_field attribute, f: f %>
</div>
<% end -%>
<div class="form-actions">
<%= f.submit %>
</div>
<% end %>

View File

@ -1,7 +0,0 @@
- Administrate::Engine.javascripts.each do |js_path|
= javascript_include_tag js_path
= yield :javascript
- if Rails.env.test?
= javascript_tag do
$.fx.off = true;
$.ajaxSetup({ async: false });

View File

@ -1,7 +0,0 @@
%nav.navigation{:role => "navigation"}
- Administrate::Namespace.new(namespace).resources.each do |resource|
= link_to( |
display_resource_name(resource), |
[namespace, resource.path], |
class: "navigation__link navigation__link--#{nav_link_state(resource)}" |
) |

View File

@ -1,36 +0,0 @@
<%#
# Edit
This view is the template for the edit page.
It displays a header, and renders the `_form` partial to do the heavy lifting.
## Local variables:
- `page`:
An instance of [Administrate::Page::Form][1].
Contains helper methods to help display a form,
and knows which attributes should be displayed in the resource's form.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
%>
<% content_for(:title) { "#{t("administrate.actions.edit")} #{page.page_title}" } %>
<header class="main-content__header" role="banner">
<h1 class="main-content__page-title">
<%= content_for(:title) %>
</h1>
<div>
<%= link_to(
"#{t("administrate.actions.show")} #{page.page_title}",
[namespace, page.resource],
class: "button",
) if valid_action? :show %>
</div>
</header>
<section class="main-content__body">
<%= render "form", page: page %>
</section>

View File

@ -1,53 +0,0 @@
<%#
# Index
This view is the template for the index page.
It is responsible for rendering the search bar, header and pagination.
It renders the `_table` partial to display details about the resources.
## Local variables:
- `page`:
An instance of [Administrate::Page::Collection][1].
Contains helper methods to help display a table,
and knows which attributes should be displayed in the resource's table.
- `resources`:
An instance of `ActiveRecord::Relation` containing the resources
that match the user's search criteria.
By default, these resources are passed to the table partial to be displayed.
- `search_term`:
A string containing the term the user has searched for, if any.
- `show_search_bar`:
A boolean that determines if the search bar should be shown.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Collection
%>
<% content_for(:title) do %>
<%= display_resource_name(page.resource_name) %>
<% end %>
<% content_for(:search) do %>
<% if show_search_bar %>
<%= render "search", search_term: search_term %>
<% end %>
<% end %>
<header class="main-content__header" role="banner">
<h1 class="main-content__page-title" id="page-title">
<%= content_for(:title) %>
</h1>
<div>
<%= link_to(
"#{t("administrate.actions.new")} #{page.resource_name.titleize.downcase}",
[:new, namespace, page.resource_path],
class: "button",
) if valid_action? :new %>
</div>
</header>
<section class="main-content__body main-content__body--flush">
<%= render "collection", collection_presenter: page, resources: resources %>
<%= paginate resources %>
</section>

View File

@ -1,32 +0,0 @@
<%#
# New
This view is the template for the "new resource" page.
It displays a header, and then renders the `_form` partial
to do the heavy lifting.
## Local variables:
- `page`:
An instance of [Administrate::Page::Form][1].
Contains helper methods to help display a form,
and knows which attributes should be displayed in the resource's form.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Form
%>
<% content_for(:title) { "#{t("administrate.actions.new")} #{page.resource_name.titleize}" } %>
<header class="main-content__header" role="banner">
<h1 class="main-content__page-title">
<%= content_for(:title) %>
</h1>
<div>
<%= link_to t("administrate.actions.back"), :back, class: "button" %>
</div>
</header>
<section class="main-content__body">
<%= render "form", page: page %>
</section>

View File

@ -1,49 +0,0 @@
<%#
# Show
This view is the template for the show page.
It renders the attributes of a resource,
as well as a link to its edit page.
## Local variables:
- `page`:
An instance of [Administrate::Page::Show][1].
Contains methods for accessing the resource to be displayed on the page,
as well as helpers for describing how each attribute of the resource
should be displayed.
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Page/Show
%>
<% content_for(:title) { "#{t("administrate.actions.show")} #{page.page_title}" } %>
<header class="main-content__header" role="banner">
<h1 class="main-content__page-title">
<%= content_for(:title) %>
</h1>
<div>
<%= link_to(
"#{t("administrate.actions.edit")} #{page.page_title}",
[:edit, namespace, page.resource],
class: "button",
) if valid_action? :edit %>
</div>
</header>
<section class="main-content__body">
<dl>
<% page.attributes.each do |attribute| %>
<dt class="attribute-label">
<%= t(
"helpers.label.#{resource_name}.#{attribute.name}",
default: attribute.name.titleize,
) %>
</dt>
<dd class="attribute-data attribute-data--<%=attribute.html_class%>"
><%= render_field attribute %></dd>
<% end %>
</dl>
</section>

View File

@ -3,7 +3,7 @@
.row
.col-md-10
%h2 Applies
= paginate @applies
=will_paginate @applies
.col-md-3
= #image_tag "applies.jpg" , :class => "img-responsive"
.row
@ -21,7 +21,7 @@
%tr{:class => "line-#{cycle("1","2")}"}
%td=apply.id.to_s
%td= link_to "Show" , admin_apply_path(apply), :title => t(:show)
= paginate @applies
=will_paginate @applies
.col-md-3
= search_form_for [:admin , @q], :html => { :class => "form-horizontal" }, :method => :get do |f|
.form-group

View File

@ -3,7 +3,7 @@
.row
.col-md-10
%h2 Courses
= paginate @courses
=will_paginate @courses
.col-md-2
= link_to "New course" , new_admin_course_path , :class => "btn btn-primary"
.col-md-3
@ -26,9 +26,9 @@
%td.name=course.name
%td=course.extra
%td=course.start
%td= link_to "Show" , course_path(course), :title => "Show"
%td= link_to "Show" , admin_course_path(course), :title => "Show"
%td= link_to "Edit" , edit_admin_course_path(course), :title => "Edit"
= paginate @courses
=will_paginate @courses
.col-md-3
= search_form_for [:admin,@q], :html => { :class => "form-horizontal" }, :method => :get do |f|
.form-group

View File

@ -3,7 +3,7 @@
.row
.col-md-10
%h2 Resumes
= paginate @resumes
=will_paginate @resumes
.col-md-3
= #image_tag "resumes.jpg" , :class => "img-responsive"
.row
@ -21,7 +21,7 @@
%tr{:class => "line-#{cycle("1","2")}"}
%td=resume.id.to_s
%td= link_to "Show" , admin_resume_path(resume), :title => t(:show)
= paginate @resumes
=will_paginate @resumes
.col-md-3
= search_form_for [:admin , @q], :html => { :class => "form-horizontal" }, :method => :get do |f|
.form-group

View File

@ -3,7 +3,7 @@
.row
.col-md-10
%h2 Users
= paginate @users
=will_paginate @users
.col-md-3
= #image_tag "users.jpg" , :class => "img-responsive"
.row
@ -27,7 +27,7 @@
%td=user.city
%td=user.country
%td= link_to "Show" , admin_user_path(user), :title => t(:show)
= paginate @users
=will_paginate @users
.col-md-3
= search_form_for [:admin , @q], :html => { :class => "form-horizontal" }, :method => :get do |f|
.form-group

View File

@ -1,18 +0,0 @@
!!!
%html
%body
%meta{:charset => "utf-8"}/
%meta{:content => "NOODP", :name => "ROBOTS"}/
%meta{:content => "initial-scale=1", :name => "viewport"}/
%title
= content_for(:title)
\- #{Rails.application.class.parent_name.titlecase}
= render "stylesheet"
= csrf_meta_tags
.app-container
= render "navigation"
%main.main-content{:role => "main"}
= content_for(:search)
= render "flashes"
= yield
= render "javascript"