From 3162853285607c6981d3ff61aa2fba7af4277291 Mon Sep 17 00:00:00 2001 From: Dan Barber Date: Mon, 31 Oct 2011 17:34:48 +0000 Subject: [PATCH] Finished up admin interface. Tweaks to site stylesheets. --- Gemfile | 2 + Gemfile.lock | 5 ++ app/assets/images/admin/logo.png | Bin 4070 -> 4020 bytes app/assets/javascripts/admin.js | 1 + app/assets/javascripts/admin/photos.js.coffee | 2 + app/assets/stylesheets/admin.css | 1 + app/assets/stylesheets/admin/admin.css.sass | 3 + .../stylesheets/admin/formtastic.css.sass | 12 ++++ app/assets/stylesheets/admin/photos.css.sass | 21 ++++++ app/assets/stylesheets/photos.css.sass | 32 ++++++---- app/controllers/admin/admin_controller.rb | 5 +- .../admin/categories_controller.rb | 53 +++++++++++++++- app/controllers/admin/pages_controller.rb | 53 +++++++++++++++- app/controllers/admin/photos_controller.rb | 60 +++++++++++++++++- .../admin/categories/_category.html.haml | 7 ++ app/views/admin/categories/_form.html.haml | 3 + app/views/admin/categories/edit.html.haml | 2 + app/views/admin/categories/index.html.haml | 15 +++++ app/views/admin/categories/new.html.haml | 2 + app/views/admin/pages/_form.html.haml | 3 + app/views/admin/pages/_page.html.haml | 7 ++ app/views/admin/pages/edit.html.haml | 2 + app/views/admin/pages/index.html.haml | 15 +++++ app/views/admin/pages/new.html.haml | 2 + app/views/admin/photos/_form.html.haml | 8 +++ app/views/admin/photos/_photo.html.haml | 6 ++ app/views/admin/photos/edit.html.haml | 2 + app/views/admin/photos/index.html.haml | 11 ++++ app/views/admin/photos/new.html.haml | 2 + app/views/layouts/photos.html.erb | 1 + app/views/shared/_typekit.html.haml | 3 + config/routes.rb | 3 + .../20111030163656_remove_admin_users.rb | 20 ++++++ ...0111030164012_create_devise_admin_users.rb | 27 ++++++++ db/schema.rb | 17 ++++- 35 files changed, 389 insertions(+), 19 deletions(-) create mode 100644 app/assets/javascripts/admin/photos.js.coffee create mode 100644 app/assets/stylesheets/admin/photos.css.sass create mode 100644 app/views/admin/categories/_category.html.haml create mode 100644 app/views/admin/categories/_form.html.haml create mode 100644 app/views/admin/categories/edit.html.haml create mode 100644 app/views/admin/categories/index.html.haml create mode 100644 app/views/admin/categories/new.html.haml create mode 100644 app/views/admin/pages/_form.html.haml create mode 100644 app/views/admin/pages/_page.html.haml create mode 100644 app/views/admin/pages/edit.html.haml create mode 100644 app/views/admin/pages/index.html.haml create mode 100644 app/views/admin/pages/new.html.haml create mode 100644 app/views/admin/photos/_form.html.haml create mode 100644 app/views/admin/photos/_photo.html.haml create mode 100644 app/views/admin/photos/edit.html.haml create mode 100644 app/views/admin/photos/index.html.haml create mode 100644 app/views/admin/photos/new.html.haml create mode 100644 app/views/shared/_typekit.html.haml create mode 100644 db/migrate/20111030163656_remove_admin_users.rb create mode 100644 db/migrate/20111030164012_create_devise_admin_users.rb diff --git a/Gemfile b/Gemfile index c4330a7..697d7d5 100644 --- a/Gemfile +++ b/Gemfile @@ -45,6 +45,7 @@ gem 'sass-rails', "~> 3.1.0" gem "exception_notification", :git => "git://github.com/rails/exception_notification", :require => 'exception_notifier' gem 'pg' gem 'devise' +gem 'formtastic' gem 'squeel' gem 'mini_exiftool' gem 'will_paginate' @@ -52,3 +53,4 @@ gem 'rdiscount' gem 'paperclip' gem 'acts_as_markup' gem 'yaml_db' +gem 'haml' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 991fbe6..aad6d95 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -64,6 +64,9 @@ GEM erubis (2.7.0) execjs (1.2.9) multi_json (~> 1.0) + formtastic (2.0.2) + rails (~> 3.0) + haml (3.1.3) hike (1.2.1) hpricot (0.8.4) i18n (0.6.0) @@ -164,6 +167,8 @@ DEPENDENCIES coffee-rails (~> 3.1.0) devise exception_notification! + formtastic + haml hpricot jquery-rails mini_exiftool diff --git a/app/assets/images/admin/logo.png b/app/assets/images/admin/logo.png index fec2fca88643d4ecb2def9e4d75324d133ee895e..ce9b20c4ff216dd4ab203e547655fc16729d9697 100644 GIT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K)qkLy?qu{AONCP7U&yFx~3 zi3~g2M^Yo4@5kG=g$E5@d}HQQ>E2=SWyy4-gsl}5x2_VXo^(G{2`?lzP>uWYL(xOd z)=R0X{kQveuuZ-D2s3lVBztmrDuRNC`S6 z>tAN9>0g;1nZzUX02@^n4#L?#8sSVuK+@8&)#@*w4~mwZ+vm>S=bHbgcx25;ttr}d zF5ZTfqm#Fl4SU+N9eDpDf(1MdoAxC>u=5})?N^bkNC|45M8CTwwpK58C#^>Kqun1NKMzQ%+?hE~40i!nC$fNedu6v{ zPyKDI*CvdaL6)@d_rd^uUV}z0bs&zd8h+6-4=>rLNRhZ`19+=65VJZJ0kgfBt)1*4 zOD!8uBc5>n^jKe9Dt=U?ct)>bT{zp_FNmrWbPW8J5`NaTqEN178PZWH_L99NcjV25 zyb)Rq<5tu5-r@unlYy;dbad$NGRB1?Dw^dTv7O(3T5uRBOitkk==`I#8=qsp`;QcJ7=0!@NoWbAx) z8u5Uk%mnB1r8eYwQ<9{2_NJGxJ^$9e)>hKn#fb%dz1T0F_G$MjAiIDAnx}Aw!Pb1C zGCvKOBCd5!S*5i&<1phN@(#&FwH(!elvuyh4^Yc&Owd1Bkw%nDw@-6y-L@>aYma3K z39a)GHpA48WYjIOn^8{Dp8&}#)%g!wa@`-T0uJkGj~$Q7hZ}Y3^Z#xCKvcRe46D z{fN>tQUFiY|9Z5^aVF#4RbQm+ro#|f9`XW*<)nX~zixTtAGESEbUrP;J2*>*R^_Id zSSl;0-~Y + $(".photos .photo a").not(".actions a").fancybox() \ No newline at end of file diff --git a/app/assets/stylesheets/admin.css b/app/assets/stylesheets/admin.css index ab7dfe9..af0241e 100644 --- a/app/assets/stylesheets/admin.css +++ b/app/assets/stylesheets/admin.css @@ -4,5 +4,6 @@ * the top of the compiled file, but it's generally better to create a new file per style scope. *= require_self *= require formtastic + *= require fancybox *= require_directory ./admin */ \ No newline at end of file diff --git a/app/assets/stylesheets/admin/admin.css.sass b/app/assets/stylesheets/admin/admin.css.sass index 9b3261a..1b6bca6 100644 --- a/app/assets/stylesheets/admin/admin.css.sass +++ b/app/assets/stylesheets/admin/admin.css.sass @@ -109,6 +109,9 @@ table background: #ddd !important border-bottom: 0 +.pagination + margin: 0.5em 0 + #error_explanation width: 450px border: 2px solid red diff --git a/app/assets/stylesheets/admin/formtastic.css.sass b/app/assets/stylesheets/admin/formtastic.css.sass index 97bc6b8..0007166 100644 --- a/app/assets/stylesheets/admin/formtastic.css.sass +++ b/app/assets/stylesheets/admin/formtastic.css.sass @@ -50,6 +50,13 @@ form.formtastic -webkit-appearance: none margin: 0 + .fragments + .label label + width: 13em + + .fragments-group + padding-left: 14em + input[type=submit], a.button @include button &[name=commit] @@ -60,6 +67,11 @@ form.formtastic @include box-shadow("0 1px 0 rgba(0, 0, 0, 0.25), inset -1px -1px 0 rgba(255, 255, 255, 0.2), inset 1px 1px 0 rgba(255, 255, 255, 0.3), inset 0 0 6px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.3)") &:hover, &:focus background-color: #8B6 + + .boolean + label + padding-left: 14em + text-align: left .error input border-width: 1px diff --git a/app/assets/stylesheets/admin/photos.css.sass b/app/assets/stylesheets/admin/photos.css.sass new file mode 100644 index 0000000..3a687be --- /dev/null +++ b/app/assets/stylesheets/admin/photos.css.sass @@ -0,0 +1,21 @@ +@import "../includes/round_corners" +@import "../includes/box_shadow" + +.photos + .photo + float: left + margin-right: 1em + margin-top: 1em + &:after + content: "" + display: block + clear: both + +ul.categories + border: 1px solid #ccc + @include round-corners(3px) + @include box-shadow("inset 2px 2px 4px rgba(0, 0, 0, 0.1)") + margin-top: 1em + padding: 1em + width: 25% + float: right diff --git a/app/assets/stylesheets/photos.css.sass b/app/assets/stylesheets/photos.css.sass index 9fc51ce..550c51f 100644 --- a/app/assets/stylesheets/photos.css.sass +++ b/app/assets/stylesheets/photos.css.sass @@ -1,10 +1,13 @@ @import "includes/box_shadow" +html + -webkit-text-size-adjust: 100% + body background: #101010 color: white - font-family: "Helvetica Neue", "Arial", "Helvatica", sans-serif - font-size: 14px + font-family: freight-sans-pro, "Helvetica Neue", "Arial", sans-serif + font-size: 100% overflow: hidden a @@ -151,7 +154,7 @@ p a text-align: right margin: 0 20px font-weight: normal - font-size: 1.1em + font-size: 1em line-height: 1em img @@ -183,9 +186,9 @@ img color: #ccc overflow: auto div - padding: 15px 20px + padding: 2px 12px p - margin-bottom: 0.6em + margin-top: 0.6em line-height: 1.35em /* FORM @@ -206,6 +209,7 @@ form display: block width: 75px float: left + margin-top: 6px &.error float: none display: inline @@ -214,9 +218,9 @@ form textarea height: 150px width: 335px - font-family: "Helvetica Neue","Arial","Helvatica",sans-serif - font-size: 14px - padding: 3px + font-family: freight-sans-pro, "Helvetica Neue", "Arial", sans-serif + font-size: 1em + padding: 5px color: #333 border: 2px solid #999 -moz-border-radius: 3px @@ -224,9 +228,9 @@ form border-radius: 3px input &[type='text'] - font-family: "Helvetica Neue","Arial","Helvatica",sans-serif - font-size: 14px - padding: 3px + font-family: freight-sans-pro, "Helvetica Neue", "Arial", sans-serif + font-size: 1em + padding: 5px color: #333 border: 2px solid #999 -moz-border-radius: 3px @@ -266,9 +270,9 @@ input.error, textarea.error form input[type='submit'] background: #666 - font-family: "Helvetica Neue","Arial","Helvatica",sans-serif - font-size: 14px - padding: 3px + font-family: freight-sans-pro, "Helvetica Neue", "Arial", sans-serif + font-size: 1em + padding: 3px 8px color: white border: 2px solid #333 -moz-border-radius: 3px diff --git a/app/controllers/admin/admin_controller.rb b/app/controllers/admin/admin_controller.rb index 57cf8cf..b66cd2f 100644 --- a/app/controllers/admin/admin_controller.rb +++ b/app/controllers/admin/admin_controller.rb @@ -5,6 +5,9 @@ class Admin::AdminController < ApplicationController def admin_menu @admin_menu = { :dashboard => '', - :admin_users => '' } + :admin_users => '', + :categories => '', + :photos => '', + :pages => '' } end end diff --git a/app/controllers/admin/categories_controller.rb b/app/controllers/admin/categories_controller.rb index 0d4438d..fa5a6d9 100644 --- a/app/controllers/admin/categories_controller.rb +++ b/app/controllers/admin/categories_controller.rb @@ -1,2 +1,53 @@ -class Admin::CategoriesController < Admin::ResourcesController +class Admin::CategoriesController < Admin::AdminController + + def index + @categories = Category.all + end + + def new + @category = Category.new + end + + def edit + @category = Category.find(params[:id]) + end + + def update + @category = Category.find(params[:id]) + + respond_to do |format| + if @category.update_attributes(params[:category]) + format.html { redirect_to(admin_categories_path, :notice => 'Category was successfully updated.') } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @category.errors, :status => :unprocessable_entity } + end + end + end + + def create + @category = Category.new(params[:category]) + + respond_to do |format| + if @category.save + format.html { redirect_to(admin_categories_path, :notice => 'Category was successfully added.') } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @category.errors, :status => :unprocessable_entity } + end + end + end + + def destroy + @category = Category.find(params[:id]) + @category.destroy + + respond_to do |format| + format.html { redirect_to(admin_categories_path, :notice => 'Category was deleted.') } + format.xml { head :ok } + end + end + end diff --git a/app/controllers/admin/pages_controller.rb b/app/controllers/admin/pages_controller.rb index df12653..ef63b69 100644 --- a/app/controllers/admin/pages_controller.rb +++ b/app/controllers/admin/pages_controller.rb @@ -1,2 +1,53 @@ -class Admin::PagesController < Admin::ResourcesController +class Admin::PagesController < Admin::AdminController + + def index + @pages = Page.all + end + + def new + @page = Page.new + end + + def edit + @page = Page.find(params[:id]) + end + + def update + @page = Page.find(params[:id]) + + respond_to do |format| + if @page.update_attributes(params[:page]) + format.html { redirect_to(admin_pages_path, :notice => 'Page was successfully updated.') } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @page.errors, :status => :unprocessable_entity } + end + end + end + + def create + @page = Page.new(params[:page]) + + respond_to do |format| + if @page.save + format.html { redirect_to(admin_pages_path, :notice => 'Page was successfully added.') } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @page.errors, :status => :unprocessable_entity } + end + end + end + + def destroy + @page = Page.find(params[:id]) + @page.destroy + + respond_to do |format| + format.html { redirect_to(admin_pages_path, :notice => 'Page was deleted.') } + format.xml { head :ok } + end + end + end diff --git a/app/controllers/admin/photos_controller.rb b/app/controllers/admin/photos_controller.rb index 75d2f9a..70ff80a 100644 --- a/app/controllers/admin/photos_controller.rb +++ b/app/controllers/admin/photos_controller.rb @@ -1,2 +1,60 @@ -class Admin::PhotosController < Admin::ResourcesController +class Admin::PhotosController < Admin::AdminController + before_filter :get_categories + + def index + @photos = Photo.paginate(:page => params[:page]) + end + + def new + @photo = Photo.new + end + + def edit + @photo = Photo.find(params[:id]) + end + + def update + @photo = Photo.find(params[:id]) + + respond_to do |format| + if @photo.update_attributes(params[:photo]) + format.html { redirect_to(admin_photos_path, :notice => 'Photo was successfully updated.') } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @photo.errors, :status => :unprocessable_entity } + end + end + end + + def create + @photo = Photo.new(params[:photo]) + + respond_to do |format| + if @photo.save + format.html { redirect_to(admin_photos_path, :notice => 'Photo was successfully added.') } + format.xml { head :ok } + else + format.html { render :action => "edit" } + format.xml { render :xml => @photo.errors, :status => :unprocessable_entity } + end + end + end + + def destroy + @photo = Photo.find(params[:id]) + @photo.destroy + + respond_to do |format| + format.html { redirect_to(admin_photos_path, :notice => 'Photo was deleted.') } + format.xml { head :ok } + end + end + + private + + def get_categories + @categories = Category.all + end + end diff --git a/app/views/admin/categories/_category.html.haml b/app/views/admin/categories/_category.html.haml new file mode 100644 index 0000000..8809248 --- /dev/null +++ b/app/views/admin/categories/_category.html.haml @@ -0,0 +1,7 @@ +%tr + %td= category.name + %td= category.base_colour + %td{ :class => :actions } + = link_to 'Show', [:admin, category] + = link_to 'Edit', edit_admin_category_path(category) + = link_to 'Destroy', [:admin, category], confirm: 'Are you sure?', method: :delete diff --git a/app/views/admin/categories/_form.html.haml b/app/views/admin/categories/_form.html.haml new file mode 100644 index 0000000..1cc8787 --- /dev/null +++ b/app/views/admin/categories/_form.html.haml @@ -0,0 +1,3 @@ += semantic_form_for [:admin, category] do |f| + = f.inputs :name, :description, :base_colour, :sort + = f.buttons \ No newline at end of file diff --git a/app/views/admin/categories/edit.html.haml b/app/views/admin/categories/edit.html.haml new file mode 100644 index 0000000..ad67433 --- /dev/null +++ b/app/views/admin/categories/edit.html.haml @@ -0,0 +1,2 @@ +%h2 Edit Category += render :partial => "form", :locals => { :category => @category } \ No newline at end of file diff --git a/app/views/admin/categories/index.html.haml b/app/views/admin/categories/index.html.haml new file mode 100644 index 0000000..423bf90 --- /dev/null +++ b/app/views/admin/categories/index.html.haml @@ -0,0 +1,15 @@ +%h2 Categories + +%table + %thead + %tr + %th Name + %th Base Colour + %th + %tbody + = render :partial => "category", :collection => @categories + %tfoot + %tr + %td{:colspan => 4} +%br/ += link_to 'New Category', new_admin_category_path, :class => [:button, :new] diff --git a/app/views/admin/categories/new.html.haml b/app/views/admin/categories/new.html.haml new file mode 100644 index 0000000..d765ae7 --- /dev/null +++ b/app/views/admin/categories/new.html.haml @@ -0,0 +1,2 @@ +%h2 New Category += render :partial => "form", :locals => { :category => @category } \ No newline at end of file diff --git a/app/views/admin/pages/_form.html.haml b/app/views/admin/pages/_form.html.haml new file mode 100644 index 0000000..ed135a0 --- /dev/null +++ b/app/views/admin/pages/_form.html.haml @@ -0,0 +1,3 @@ += semantic_form_for [:admin, page] do |f| + = f.inputs :name, :title, :content + = f.buttons \ No newline at end of file diff --git a/app/views/admin/pages/_page.html.haml b/app/views/admin/pages/_page.html.haml new file mode 100644 index 0000000..949c8d1 --- /dev/null +++ b/app/views/admin/pages/_page.html.haml @@ -0,0 +1,7 @@ +%tr + %td= page.name + %td= page.title + %td{ :class => :actions } + = link_to 'Show', [:admin, page] + = link_to 'Edit', edit_admin_page_path(page) + = link_to 'Destroy', [:admin, page], confirm: 'Are you sure?', method: :delete diff --git a/app/views/admin/pages/edit.html.haml b/app/views/admin/pages/edit.html.haml new file mode 100644 index 0000000..8584005 --- /dev/null +++ b/app/views/admin/pages/edit.html.haml @@ -0,0 +1,2 @@ +%h2 Edit Page += render :partial => "form", :locals => { :page => @page } \ No newline at end of file diff --git a/app/views/admin/pages/index.html.haml b/app/views/admin/pages/index.html.haml new file mode 100644 index 0000000..4d8ca59 --- /dev/null +++ b/app/views/admin/pages/index.html.haml @@ -0,0 +1,15 @@ +%h2 Pages + +%table + %thead + %tr + %th Name + %th Title + %th + %tbody + = render :partial => "page", :collection => @pages + %tfoot + %tr + %td{:colspan => 4} +%br/ += link_to 'New Category', new_admin_page_path, :class => [:button, :new] diff --git a/app/views/admin/pages/new.html.haml b/app/views/admin/pages/new.html.haml new file mode 100644 index 0000000..f3d37f3 --- /dev/null +++ b/app/views/admin/pages/new.html.haml @@ -0,0 +1,2 @@ +%h2 New Page += render :partial => "form", :locals => { :page => @page } \ No newline at end of file diff --git a/app/views/admin/photos/_form.html.haml b/app/views/admin/photos/_form.html.haml new file mode 100644 index 0000000..e3f348c --- /dev/null +++ b/app/views/admin/photos/_form.html.haml @@ -0,0 +1,8 @@ += semantic_form_for [:admin, photo] do |f| + %ul.categories + - @categories.each do |photo_category| + %li + = check_box_tag "photo[category_ids][]", photo_category.id, @photo.categories.include?(photo_category), :id => "photo_category_ids_#{photo_category.id}" + = label_tag "photo_category_ids_#{photo_category.id}", photo_category.name + = f.inputs :photo, :title, :description, :flickr_url, :featured, :enabled, :taken_at + = f.buttons \ No newline at end of file diff --git a/app/views/admin/photos/_photo.html.haml b/app/views/admin/photos/_photo.html.haml new file mode 100644 index 0000000..5e27625 --- /dev/null +++ b/app/views/admin/photos/_photo.html.haml @@ -0,0 +1,6 @@ +.photo + = link_to image_tag(photo.photo.url(:size5), :title => photo.title), photo.photo.url + .actions + = link_to 'Show', [:admin, photo] + = link_to 'Edit', edit_admin_photo_path(photo) + = link_to 'Destroy', [:admin, photo], confirm: 'Are you sure?', method: :delete diff --git a/app/views/admin/photos/edit.html.haml b/app/views/admin/photos/edit.html.haml new file mode 100644 index 0000000..6f956f4 --- /dev/null +++ b/app/views/admin/photos/edit.html.haml @@ -0,0 +1,2 @@ +%h2 Edit Photo += render :partial => "form", :locals => { :photo => @photo } \ No newline at end of file diff --git a/app/views/admin/photos/index.html.haml b/app/views/admin/photos/index.html.haml new file mode 100644 index 0000000..bab4e1f --- /dev/null +++ b/app/views/admin/photos/index.html.haml @@ -0,0 +1,11 @@ +%h2 Photos + += will_paginate @photos, :remote => true + +.photos + = render :partial => "photo", :collection => @photos + += will_paginate @products, :remote => true + +%br/ += link_to 'New Photo', new_admin_photo_path, :class => [:button, :new] diff --git a/app/views/admin/photos/new.html.haml b/app/views/admin/photos/new.html.haml new file mode 100644 index 0000000..3621575 --- /dev/null +++ b/app/views/admin/photos/new.html.haml @@ -0,0 +1,2 @@ +%h2 New Photo += render :partial => "form", :locals => { :photo => @photo } \ No newline at end of file diff --git a/app/views/layouts/photos.html.erb b/app/views/layouts/photos.html.erb index 5823f70..e218229 100644 --- a/app/views/layouts/photos.html.erb +++ b/app/views/layouts/photos.html.erb @@ -12,6 +12,7 @@ <%= stylesheet_link_tag "fancybox", :media => "all" %> <%= stylesheet_link_tag "scrollbars", :media => "screen" %> <%= javascript_include_tag 'application' %> + <%= render :partial => "shared/typekit" %> diff --git a/app/views/shared/_typekit.html.haml b/app/views/shared/_typekit.html.haml new file mode 100644 index 0000000..76914fe --- /dev/null +++ b/app/views/shared/_typekit.html.haml @@ -0,0 +1,3 @@ += javascript_include_tag "http://use.typekit.com/bvi1xdc.js" +:javascript + try{Typekit.load();}catch(e){} diff --git a/config/routes.rb b/config/routes.rb index 8d64a95..7678adf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -22,6 +22,9 @@ DanBarberPhoto::Application.routes.draw do put :update_password end end + resources :categories + resources :photos + resources :pages end # The priority is based upon order of creation: diff --git a/db/migrate/20111030163656_remove_admin_users.rb b/db/migrate/20111030163656_remove_admin_users.rb new file mode 100644 index 0000000..0b31c69 --- /dev/null +++ b/db/migrate/20111030163656_remove_admin_users.rb @@ -0,0 +1,20 @@ +class RemoveAdminUsers < ActiveRecord::Migration + def self.up + drop_table :admin_users + end + + def self.down + create_table :admin_users do |t| + t.string :first_name, :default => "", :null => false + t.string :last_name, :default => "", :null => false + t.string :role, :null => false + t.string :email, :null => false + t.boolean :status, :default => false + t.string :token, :null => false + t.string :salt, :null => false + t.string :crypted_password, :null => false + t.string :preferences + t.timestamps + end + end +end diff --git a/db/migrate/20111030164012_create_devise_admin_users.rb b/db/migrate/20111030164012_create_devise_admin_users.rb new file mode 100644 index 0000000..af89857 --- /dev/null +++ b/db/migrate/20111030164012_create_devise_admin_users.rb @@ -0,0 +1,27 @@ +class CreateDeviseAdminUsers < ActiveRecord::Migration + def up + create_table(:admin_users) do |t| + t.database_authenticatable :null => false + t.recoverable + t.rememberable + t.trackable + + # t.encryptable + t.confirmable + t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both + # t.token_authenticatable + + 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 + # add_index :admin_users, :authentication_token, :unique => true + end + + def down + drop_table :admin_users + end +end diff --git a/db/schema.rb b/db/schema.rb index 4c30654..5ee3352 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111013085444) do +ActiveRecord::Schema.define(:version => 20111030164012) do create_table "admin_users", :force => true do |t| t.string "email", :default => "", :null => false @@ -34,6 +34,11 @@ ActiveRecord::Schema.define(:version => 20111013085444) do t.datetime "updated_at" end + add_index "admin_users", ["confirmation_token"], :name => "index_admin_users_on_confirmation_token", :unique => true + 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 + add_index "admin_users", ["unlock_token"], :name => "index_admin_users_on_unlock_token", :unique => true + create_table "categories", :force => true do |t| t.string "name" t.text "description" @@ -74,4 +79,14 @@ ActiveRecord::Schema.define(:version => 20111013085444) do t.integer "views", :default => 0 end + create_table "sessions", :force => true do |t| + t.string "session_id", :null => false + t.text "data" + t.datetime "created_at" + t.datetime "updated_at" + end + + add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id" + add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at" + end