Commit fca19b80 authored by surma Lodur's avatar surma Lodur

added admin backend

parent 0b2e64e7
......@@ -12,6 +12,18 @@ gem 'sass-rails', '~> 4.0.0'
gem 'bootstrap-sass'
gem 'devise'
# versioning ActiveRecords
gem 'vestal_versions'
# Admin Panel
gem 'activeadmin', github: 'gregbell/active_admin'
# Authorisation
gem 'cancan'
# Store Attachments
gem 'paperclip'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
......@@ -47,6 +59,7 @@ group :development do
gem 'guard', :git => 'https://github.com/guard/guard.git'
gem 'guard-rspec'
gem 'guard-bundler'
gem 'zeus'
end
# Use ActiveModel has_secure_password
......
GIT
remote: git://github.com/gregbell/active_admin.git
revision: 9ca081f47ab447793afbd0cb2ba1eded68c26f10
specs:
activeadmin (1.0.0.pre)
arbre (~> 1.0)
bourbon
coffee-rails
devise (~> 3.2)
formtastic (~> 2.3.0.rc2)
inherited_resources (~> 1.3)
jquery-rails
jquery-ui-rails
kaminari (~> 0.15)
rails (>= 3.2, < 4.1)
ransack (~> 1.0)
sass-rails
GIT
remote: https://github.com/guard/guard.git
revision: 055c8da9bf593163289bf84327735ec26a9a1f2e
......@@ -36,18 +54,28 @@ GEM
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
arbre (1.0.1)
activesupport (>= 3.0.0)
arel (4.0.2)
atomic (1.1.14)
bcrypt-ruby (3.1.2)
bootstrap-sass (3.1.0.2)
sass (~> 3.2)
bourbon (3.1.8)
sass (>= 3.2.0)
thor
builder (3.1.4)
cancan (1.6.10)
celluloid (0.15.2)
timers (~> 1.1.0)
celluloid-io (0.15.0)
celluloid (>= 0.15.0)
nio4r (>= 0.5.0)
choice (0.1.6)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.3)
climate_control (>= 0.0.3, < 1.0)
coderay (1.1.0)
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
......@@ -74,20 +102,30 @@ GEM
ffaker (1.23.0)
ffi (1.9.3)
formatador (0.2.4)
formtastic (2.3.0.rc2)
actionpack (>= 3.0)
guard-bundler (2.0.0)
bundler (~> 1.0)
guard (~> 2.2)
guard-rspec (4.2.6)
guard (~> 2.1)
rspec (>= 2.14, < 4.0)
has_scope (0.6.0.rc)
actionpack (>= 3.2, < 5)
activesupport (>= 3.2, < 5)
hike (1.2.3)
i18n (0.6.9)
inherited_resources (1.4.1)
has_scope (~> 0.6.0.rc)
responders (~> 1.0.0.rc)
jbuilder (1.5.3)
activesupport (>= 3.0.0)
multi_json (>= 1.2.0)
jquery-rails (3.1.0)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (4.2.0)
railties (>= 3.2.16)
json (1.8.1)
kaminari (0.15.1)
actionpack (>= 3.0.0)
......@@ -108,6 +146,13 @@ GEM
multi_json (1.8.4)
nio4r (1.0.0)
orm_adapter (0.5.0)
paperclip (4.1.1)
activemodel (>= 3.0.0)
activesupport (>= 3.0.0)
cocaine (~> 0.5.3)
mime-types
polyamorous (0.6.4)
activerecord (>= 3.0)
polyglot (0.3.3)
pry (0.9.12.6)
coderay (~> 1.0)
......@@ -138,12 +183,18 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.1.1)
ransack (1.1.0)
actionpack (>= 3.0)
activerecord (>= 3.0)
polyamorous (~> 0.6.0)
rb-fsevent (0.9.4)
rb-inotify (0.9.3)
ffi (>= 0.5.0)
rdoc (4.1.1)
json (~> 1.4)
ref (1.0.5)
responders (1.0.0)
railties (>= 3.2, < 5)
rspec (2.14.1)
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
......@@ -197,14 +248,21 @@ GEM
uglifier (2.4.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
vestal_versions (2.0.0)
activerecord (>= 3, < 5)
activesupport (>= 3, < 5)
warden (1.2.3)
rack (>= 1.0)
zeus (0.13.3)
method_source (>= 0.6.7)
PLATFORMS
ruby
DEPENDENCIES
activeadmin!
bootstrap-sass
cancan
coffee-rails (~> 4.0.0)
database_cleaner
devise
......@@ -216,6 +274,7 @@ DEPENDENCIES
jbuilder (~> 1.2)
jquery-rails
kaminari
paperclip
rails (= 4.0.2)
rails-erd
rails-i18n
......@@ -226,3 +285,5 @@ DEPENDENCIES
therubyracer
turbolinks
uglifier (>= 1.3.0)
vestal_versions
zeus
ActiveAdmin.register AdminUser do
permit_params :email, :password, :password_confirmation
index do
selectable_column
id_column
column :email
column :current_sign_in_at
column :sign_in_count
column :created_at
actions
end
filter :email
filter :current_sign_in_at
filter :sign_in_count
filter :created_at
form do |f|
f.inputs "Admin Details" do
f.input :email
f.input :password
f.input :password_confirmation
end
f.actions
end
end
ActiveAdmin.register_page "Dashboard" do
menu priority: 1, label: proc{ I18n.t("active_admin.dashboard") }
content title: proc{ I18n.t("active_admin.dashboard") } do
div class: "blank_slate_container", id: "dashboard_default_message" do
span class: "blank_slate" do
span I18n.t("active_admin.dashboard_welcome.welcome")
small I18n.t("active_admin.dashboard_welcome.call_to_action")
end
end
# Here is an example of a simple dashboard with columns and panels.
#
# columns do
# column do
# panel "Recent Posts" do
# ul do
# Post.recent(5).map do |post|
# li link_to(post.title, admin_post_path(post))
# end
# end
# end
# end
# column do
# panel "Info" do
# para "Welcome to ActiveAdmin."
# end
# end
# end
end # content
end
ActiveAdmin.register Quest do
# See permitted parameters documentation:
# https://github.com/gregbell/active_admin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
# permitted = [:permitted, :attributes]
# permitted << :other if resource.something?
# permitted
# end
end
ActiveAdmin.register Reward do
# See permitted parameters documentation:
# https://github.com/gregbell/active_admin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
#
# permit_params :list, :of, :attributes, :on, :model
#
# or
#
# permit_params do
# permitted = [:permitted, :attributes]
# permitted << :other if resource.something?
# permitted
# end
end
// SASS variable overrides must be declared before loading up Active Admin's styles.
//
// To view the variables that Active Admin provides, take a look at
// `app/assets/stylesheets/active_admin/mixins/_variables.css.scss` in the
// Active Admin source.
//
// For example, to change the sidebar width:
// $sidebar-width: 242px;
// Active Admin's got SASS!
@import "active_admin/mixins";
@import "active_admin/base";
// Overriding any non-variable SASS must be done after the fact.
// For example, to change the default status-tag color:
//
// .status_tag { background: #6090DB; }
......@@ -28,5 +28,14 @@ module ApplicationHelper
html << "Anonymous"
end
return escape_javascript(html)#.html_safe
end
end # #triggered_by
def cancel_button
html = '<button type="button" class="btn btn-danger btn-xs">'
html << '<span class="col-md-1">'
html << 'Storno'
html << '</span>'
html << '</button>'
return html.html_safe
end # #cancel_button
end
class AdminUser < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable
end
......@@ -14,9 +14,7 @@
<%= entry.chronicle_text %>
</span>
<% if entry.cancel.blank? %>
<span class="btn btn-danger btn-xs col-md-1">
<%= link_to 'Storno', cancel_earning_path(entry), :method => :post %>
</span>
<%= link_to(cancel_button, cancel_earning_path(entry), :method => :post )%>
<% end %>
</div>
<% if entry.cancel.present? %>
......
......@@ -14,9 +14,7 @@
<%= entry.chronicle_text %>
</span>
<% if entry.cancel.blank? %>
<span class="btn btn-danger btn-xs col-md-1">
<%= link_to 'Storno', cancel_redemption_path(entry), :method => :post %>
</span>
<%= link_to cancel_button, cancel_redemption_path(entry), :method => :post %>
<% end %>
</div>
<% if entry.cancel.present? %>
......
ActiveAdmin.setup do |config|
# == Site Title
#
# Set the title that is displayed on the main layout
# for each of the active admin pages.
#
config.site_title = "Space Punkte"
# Set the link url for the title. For example, to take
# users to your main site. Defaults to no link.
#
# config.site_title_link = "/"
# Set an optional image to be displayed for the header
# instead of a string (overrides :site_title)
#
# Note: Aim for an image that's 21px high so it fits in the header.
#
# config.site_title_image = "logo.png"
# == Default Namespace
#
# Set the default namespace each administration resource
# will be added to.
#
# eg:
# config.default_namespace = :hello_world
#
# This will create resources in the HelloWorld module and
# will namespace routes to /hello_world/*
#
# To set no namespace by default, use:
# config.default_namespace = false
#
# Default:
# config.default_namespace = :admin
#
# You can customize the settings for each namespace by using
# a namespace block. For example, to change the site title
# within a namespace:
#
# config.namespace :admin do |admin|
# admin.site_title = "Custom Admin Title"
# end
#
# This will ONLY change the title for the admin section. Other
# namespaces will continue to use the main "site_title" configuration.
# == User Authentication
#
# Active Admin will automatically call an authentication
# method in a before filter of all controller actions to
# ensure that there is a currently logged in admin user.
#
# This setting changes the method which Active Admin calls
# within the controller.
config.authentication_method = :authenticate_admin_user!
# == User Authorization
#
# Active Admin will automatically call an authorization
# method in a before filter of all controller actions to
# ensure that there is a user with proper rights. You can use
# CanCanAdapter or make your own. Please refer to documentation.
# config.authorization_adapter = ActiveAdmin::CanCanAdapter
# You can customize your CanCan Ability class name here.
# config.cancan_ability_class = "Ability"
# You can specify a method to be called on unauthorized access.
# This is necessary in order to prevent a redirect loop which happens
# because, by default, user gets redirected to Dashboard. If user
# doesn't have access to Dashboard, he'll end up in a redirect loop.
# Method provided here should be defined in application_controller.rb.
# config.on_unauthorized_access = :access_denied
# == Current User
#
# Active Admin will associate actions with the current
# user performing them.
#
# This setting changes the method which Active Admin calls
# to return the currently logged in user.
config.current_user_method = :current_admin_user
# == Logging Out
#
# Active Admin displays a logout link on each screen. These
# settings configure the location and method used for the link.
#
# This setting changes the path where the link points to. If it's
# a string, the strings is used as the path. If it's a Symbol, we
# will call the method to return the path.
#
# Default:
config.logout_link_path = :destroy_admin_user_session_path
# This setting changes the http method used when rendering the
# link. For example :get, :delete, :put, etc..
#
# Default:
# config.logout_link_method = :get
# == Root
#
# Set the action to call for the root path. You can set different
# roots for each namespace.
#
# Default:
# config.root_to = 'dashboard#index'
# == Admin Comments
#
# This allows your users to comment on any resource registered with Active Admin.
#
# You can completely disable comments:
# config.allow_comments = false
#
# You can disable the menu item for the comments index page:
# config.show_comments_in_menu = false
#
# You can change the name under which comments are registered:
# config.comments_registration_name = 'AdminComment'
# == Batch Actions
#
# Enable and disable Batch Actions
#
config.batch_actions = true
# == Controller Filters
#
# You can add before, after and around filters to all of your
# Active Admin resources and pages from here.
#
# config.before_filter :do_something_awesome
# == Setting a Favicon
#
# config.favicon = '/assets/favicon.ico'
# == Removing Breadcrumbs
#
# Breadcrumbs are enabled by default. You can customize them for individual
# resources or you can disable them globally from here.
#
# config.breadcrumb = false
# == Register Stylesheets & Javascripts
#
# We recommend using the built in Active Admin layout and loading
# up your own stylesheets / javascripts to customize the look
# and feel.
#
# To load a stylesheet:
# config.register_stylesheet 'my_stylesheet.css'
#
# You can provide an options hash for more control, which is passed along to stylesheet_link_tag():
# config.register_stylesheet 'my_print_stylesheet.css', :media => :print
#
# To load a javascript file:
# config.register_javascript 'my_javascript.js'
# == CSV options
#
# Set the CSV builder separator
# config.csv_options = { :col_sep => ';' }
#
# Force the use of quotes
# config.csv_options = { :force_quotes => true }
# == Menu System
#
# You can add a navigation menu to be used in your application, or configure a provided menu
#
# To change the default utility navigation to show a link to your website & a logout btn
#
# config.namespace :admin do |admin|
# admin.build_menu :utility_navigation do |menu|
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
# admin.add_logout_button_to_menu menu
# end
# end
#
# If you wanted to add a static menu item to the default menu provided:
#
# config.namespace :admin do |admin|
# admin.build_menu :default do |menu|
# menu.add label: "My Great Website", url: "http://www.mygreatwebsite.com", html_options: { target: :blank }
# end
# end
# == Download Links
#
# You can disable download links on resource listing pages,
# or customize the formats shown per namespace/globally
#
# To disable/customize for the :admin namespace:
#
# config.namespace :admin do |admin|
#
# # Disable the links entirely
# admin.download_links = false
#
# # Only show XML & PDF options
# admin.download_links = [:xml, :pdf]
#
# # Enable/disable the links based on block
# # (for example, with cancan)
# admin.download_links = proc { can?(:view_download_links) }
#
# end
# == Pagination
#
# Pagination is enabled by default for all resources.
# You can control the default per page count for all resources here.
#
# config.default_per_page = 30
# == Filters
#
# By default the index screen includes a “Filters” sidebar on the right
# hand side with a filter for each attribute of the registered model.
# You can enable or disable them for all resources here.
#
# config.filters = true
end
SpacePunkte::Application.routes.draw do
devise_for :admin_users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
devise_for :hackers
root :to => 'hackers#index'
......
class DeviseCreateAdminUsers < ActiveRecord::Migration
def migrate(direction)
super
# Create a default user
AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if direction == :up
end
def change
create_table(:admin_users) do |t|
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, :default => 0, :null => false
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps
end
add_index :admin_users, :email, :unique => true
add_index :admin_users, :reset_password_token, :unique => true
# add_index :admin_users, :confirmation_token, :unique => true
# add_index :admin_users, :unlock_token, :unique => true
end
end
class CreateActiveAdminComments < ActiveRecord::Migration
def self.up
create_table :active_admin_comments do |t|
t.string :namespace
t.text :body
t.string :resource_id, null: false
t.string :resource_type, null: false
t.references :author, polymorphic: true
t.timestamps
end
add_index :active_admin_comments, [:namespace]
add_index :active_admin_comments, [:author_type, :author_id]
add_index :active_admin_comments, [:resource_type, :resource_id]
end
def self.down
drop_table :active_admin_comments
end
end
......@@ -11,7 +11,40 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140209154606) do
ActiveRecord::Schema.define(version: 20140312192849) do
create_table "active_admin_comments", force: true do |t|
t.string "namespace"
t.text "body"
t.string "resource_id", null: false
t.string "resource_type", null: false
t.integer "author_id"
t.string "author_type"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "active_admin_comments", ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id"
add_index "active_admin_comments", ["namespace"], name: "index_active_admin_comments_on_namespace"
add_index "active_admin_comments", ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource_type_and_resource_id"
create_table "admin_users", force: true do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "admin_users", ["email"], name: "index_admin_users_on_email", unique: true
add_index "admin_users", ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
create_table "cancels", force: true do |t|
t.integer "hacker_id"
......