Skip to content

Commit

Permalink
try to fixed for spree 1-3-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
damdiginess committed Mar 3, 2013
2 parents 76aef10 + 5c7ae33 commit 2151bb7
Show file tree
Hide file tree
Showing 37 changed files with 367 additions and 270 deletions.
2 changes: 0 additions & 2 deletions app/assets/javascripts/admin/spree_simple_cms.js
@@ -1,2 +0,0 @@
//= require admin/spree_core
//= require ckeditor/init
3 changes: 0 additions & 3 deletions app/assets/javascripts/store/spree_simple_cms.js
@@ -1,6 +1,3 @@
//= require store/spree_core
//= require ckeditor/init

(function($){
$(document).ready(function(){

Expand Down
21 changes: 0 additions & 21 deletions app/assets/stylesheets/admin/spree_simple_cms.css
@@ -1,21 +0,0 @@
/*
*= require admin/spree_core
*= require formtastic
*/

.formtastic input, .formtastic textarea, .formtastic select {
font-size: 100%;
padding: 5px;
}

.formtastic button {
margin: 0;
padding: 0 20px 0 0;
}
.formtastic button:hover {
text-shadow: #FFFFFF -1px -1px 0px;
}

.tags {
margin-right: 5px;
}
3 changes: 0 additions & 3 deletions app/assets/stylesheets/store/spree_simple_cms.css
@@ -1,3 +0,0 @@
/*
*= require store/spree_core
*/
28 changes: 0 additions & 28 deletions app/controllers/spree/admin/blogs_controller.rb

This file was deleted.

39 changes: 27 additions & 12 deletions app/controllers/spree/admin/posts_controller.rb
Expand Up @@ -2,26 +2,41 @@ module Spree
module Admin
class PostsController < ResourceController
def index
params[:search] ||= {}
params[:search][:meta_sort] ||= "name.asc"
@posts = @search.result.published.page(params[:name]).per(Spree::Config[:admin_products_per_page])
respond_with(@collection)
end

def collection
@search = super.ransack(params[:search])
def show
redirect_to( :action => :edit )
end

def destroy
@static_page = StaticPage.where(:permalink => params[:id]).first!
@static_page.delete

def new
@post = @object
end
flash.notice = I18n.t('notice_messages.page_deleted')

def edit
@post = @object
respond_with(@static_page) do |format|
format.html { redirect_to collection_url }
format.js { render_js_for_destroy }
end
end

protected
def find_resource
Post.find_by_permalink!(params[:id])
end

def location_after_save
admin_static_pages_url
edit_admin_post_url(@post)
end

def collection
return @collection if @collection.present?
params[:q] ||= {}
params[:q][:s] ||= "title asc"

@search = super.ransack(params[:q])
@collection = @search.result.page(params[:page]).per(Spree::Config[:admin_post_per_page])
end
end
end
Expand Down
61 changes: 35 additions & 26 deletions app/controllers/spree/admin/static_pages_controller.rb
@@ -1,14 +1,29 @@
module Spree
module Admin
class StaticPagesController < ResourceController

def index
params[:search] ||= {}
params[:search][:meta_sort] ||= "name.asc"
@static_pages = @search.result.page(params[:name]).per(Spree::Config[:admin_products_per_page])
respond_with(@collection)
end

def show
redirect_to( :action => :edit )
end

def destroy
@static_page = StaticPage.where(:permalink => params[:id]).first!
@static_page.delete

flash.notice = I18n.t('notice_messages.page_deleted')

respond_with(@static_page) do |format|
format.html { redirect_to collection_url }
format.js { render_js_for_destroy }
end
end

def published
sp = Spree::StaticPage.find(params[:id])
sp = StaticPage.find(params[:id])

if sp.update_attribute(:published_at, Time.now)
flash[:notice] = t("info_published_static_page")
Expand All @@ -19,7 +34,7 @@ def published
end

def in_nav_menu
sp = Spree::StaticPage.find(params[:id])
sp = StaticPage.find(params[:id])

if sp.update_attribute(:in_nav_menu, true)
flash[:notice] = t("info_in_nav_menu_static_page")
Expand All @@ -29,31 +44,25 @@ def in_nav_menu
redirect_to spree.admin_static_pages_path
end

def update_positions
params[:positions].each do |id, index|
Spree::StaticPage.where(:id => id).update_all(:position => index)
end
respond_to do |format|
format.js { render :text => 'Ok' }
end
end

def collection
@search = super.ransack(params[:search])
end

def new
@static_page = @object
end

def edit
@static_page = @object
end

protected
def find_resource
StaticPage.find_by_permalink!(params[:id])
end

def location_after_save
admin_static_pages_url
edit_admin_static_page_url(@static_page)
end

def collection
return @collection if @collection.present?
params[:q] ||= {}
params[:q][:s] ||= "title asc"

@search = super.ransack(params[:q])
@collection = @search.result.page(params[:page]).per(Spree::Config[:admin_post_per_page])
end

end
end
end
14 changes: 5 additions & 9 deletions app/controllers/spree/admin/store_settings_controller.rb
@@ -1,25 +1,21 @@
module Spree
module Admin
class StoreSettingsController < BaseController
def show
@preferences = ['store_name', 'store_default_email', 'store_address',
'store_phone_number', 'store_fax_number', 'store_twitter_id',
'store_facebook_id', 'store_skype', 'store_location', 'store_description', 'store_welcome_title', 'store_welcome_description']
end


def edit
@preferences = [:store_name, :store_default_email, :store_address,
@preferences = [:store_default_email, :store_address,
:store_phone_number, :store_fax_number, :store_twitter_id,
:store_facebook_id, :store_skype, :store_location, :store_description, :store_welcome_title, :store_welcome_description]
end

def update
params.each do |name, value|
next unless Spree::Config.has_preference? name
Spree::Config[name] = value
end
flash[:success] = t(:successfully_updated, :resource => t(:general_settings))

redirect_to admin_store_settings_path
redirect_to edit_admin_store_settings_path
end

end
Expand Down
18 changes: 13 additions & 5 deletions app/controllers/spree/static_pages_controller.rb
@@ -1,27 +1,35 @@
module Spree
class StaticPagesController < BaseController
before_filter :load_obj
before_filter :load_page, :only => :show
rescue_from ActiveRecord::RecordNotFound, :with => :render_404
helper 'spree/taxons'

respond_to :html

def contacts
end

def show
@page = Spree::StaticPage.find(params[:id])
return unless @static_page
end

def create_mail
unless (params[:name].blank? && params[:email].blank? && params[:messaggio].blank?)
Spree::ContactMailer.contacts_form(params[:name], params[:email], params[:messaggio]).deliver
Spree::ContactMailer.contact_form(params[:name], params[:email], params[:messaggio]).deliver
flash[:notice] = t('create_mail_static_page')
else
flash[:notice] = t('not_create_mail_static_page')#'Si e` verificato un problema durante l\'invio della mail. Verifica di aver compilato tutti i campi'
end
redirect_to contacts_url
end

def load_obj
@static_pages = Spree::StaticPage.published
private
def accurate_title
@static_page ? @static_page.title : super
end

def load_page
@static_page = Spree::StaticPage.find_by_permalink!(params[:id])
end
end
end
7 changes: 2 additions & 5 deletions app/mailers/spree/contact_mailer.rb
@@ -1,15 +1,12 @@
module Spree
class ContactMailer < ActionMailer::Base
helper 'spree/base'

default :from => Spree::Config[:store_default_email]

def contacts_form(name, email, text)
def contact_form(name, email, text)
@name = name
@email = email
@messaggio = text
mail(:to => "#{email} - #{name}",
:subject => Spree::Config[:store_default_contact_subject])
mail(:to => Spree::Config[:store_default_email], :subject => "#{Spree::Config[:site_name]} - #{Spree::Config[:store_default_contact_subject]}")
end
end
end
52 changes: 0 additions & 52 deletions app/models/comment.rb

This file was deleted.

22 changes: 20 additions & 2 deletions app/models/spree/app_configuration_decorator.rb
@@ -1,8 +1,24 @@
# This is the primary location for defining spree preferences
#
# The expectation is that this is created once and stored in
# the spree environment
#
# setters:
# a.color = :blue
# a[:color] = :blue
# a.set :color = :blue
# a.preferred_color = :blue
#
# getters:
# a.color
# a[:color]
# a.get :color
# a.preferred_color
#
Spree::AppConfiguration.class_eval do

preference :store_name, :string, :default => 'Spree Demo'
preference :store_default_email, :string, :default => 'spree@example.com'
preference :store_default_contact_subject, :string, :default => "[Spree Demo] Contact form subject"
preference :store_default_contact_subject, :string, :default => "Contact form subject"
preference :store_address, :string, :default => 'Address, 123 - 123456 City (IT)'
preference :store_phone_number, :string, :default => '012 - 3456789'
preference :store_fax_number, :string, :default => '012 - 3456789'
Expand All @@ -13,5 +29,7 @@
preference :store_description, :text, :default => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt, sem id vulputate auctor, dui lectus lacinia ipsum, placerat euismod felis tellus a nulla. Nunc fermentum tincidunt dui, ac iaculis quam elementum et. Mauris sit amet vehicula tortor. Maecenas euismod fringilla venenatis. In accumsan ultricies odio at venenatis. Duis aliquam euismod libero, nec eleifend massa fermentum iaculis. Donec imperdiet egestas ligula pretium aliquam.'
preference :store_welcome_title, :string, :default => 'Welcome'
preference :store_welcome_description, :text, :default => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tincidunt, sem id vulputate auctor, dui lectus lacinia ipsum, placerat euismod felis tellus a nulla. Nunc fermentum tincidunt dui, ac iaculis quam elementum et. Mauris sit amet vehicula tortor. Maecenas euismod fringilla venenatis. In accumsan ultricies odio at venenatis. Duis aliquam euismod libero, nec eleifend massa fermentum iaculis. Donec imperdiet egestas ligula pretium aliquam.'
preference :admin_post_per_page, :integer, :default => 10
preference :post_per_page, :integer, :default => 5

end

0 comments on commit 2151bb7

Please sign in to comment.