commit 0856528f5edabcbd262117095d6058a602b4f372 Author: Benjamin ter Kuile Date: Wed Aug 22 18:15:37 2012 +0200 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..06073069 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +# See http://help.github.com/ignore-files/ for more about ignoring files. +# +# If you find yourself ignoring temporary files generated by your text editor +# or operating system, you probably want to add a global ignore instead: +# git config --global core.excludesfile ~/.gitignore_global + +# Ignore bundler config +/.bundle + +# Ignore the default SQLite database. +/db/*.sqlite3 + +# Ignore all logfiles and tempfiles. +/log/*.log +/tmp +.sass-cache/ +*.swp +db/xapian_db +company_logo* +public/assets +public/javascripts +beanlog.log +routes.txt +public/system +vendor/cache +public/google* +replication_design.html diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000..65c8ac7c --- /dev/null +++ b/Gemfile @@ -0,0 +1,59 @@ +source 'https://rubygems.org' + +gem 'rails', '3.2.8' + +# Bundle edge Rails instead: +# gem 'rails', :git => 'git://github.com/rails/rails.git' + +# gem 'sqlite3' + + +# Gems used only for assets and not required +# in production environments by default. +group :assets do + gem 'sass-rails', '~> 3.2.3' + gem 'coffee-rails', '~> 3.2.1' + gem 'twitter-bootstrap-rails' + + # See https://github.com/sstephenson/execjs#readme for more supported runtimes + # gem 'therubyracer', :platforms => :ruby + + gem 'uglifier', '>= 1.0.3' +end + +gem 'jquery-rails' +gem 'haml-rails' +gem 'slim-rails' + +gem 'couch_potato' , :git => 'git://github.com/bterkuile/couch_potato.git' +gem 'simply_stored' , :git => 'git://github.com/bterkuile/simply_stored.git' +gem 'devise', '2.0.4' +gem 'devise_simply_stored' + +gem 'rqrcode-rails3' +gem 'mini_magick' + +# To use ActiveModel has_secure_password +# gem 'bcrypt-ruby', '~> 3.0.0' + +# To use Jbuilder templates for JSON +# gem 'jbuilder' +group :development do + gem 'pry' + gem 'rspec-rails' + gem 'thin' +end + +group :test do + gem 'rspec-rails' + gem 'capybara' +end + +# Use unicorn as the app server +# gem 'unicorn' + +# Deploy with Capistrano +# gem 'capistrano' + +# To use debugger +# gem 'debugger' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000..0c32942e --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,241 @@ +GIT + remote: git://github.com/bterkuile/couch_potato.git + revision: ff7505c432cabfccb55cfa732a548d9449d8250c + specs: + couch_potato (0.7.0.pre.1) + activemodel + couchrest (>= 1.0.1) + json (~> 1.6.0) + +GIT + remote: git://github.com/bterkuile/simply_stored.git + revision: ad8c6af0d845a8eb3d1caeb47ede1e607f94e854 + specs: + simply_stored (1.0.0) + activesupport + couch_potato (>= 0.2.15) + rest-client (>= 1.4.2) + +GEM + remote: https://rubygems.org/ + specs: + actionmailer (3.2.8) + actionpack (= 3.2.8) + mail (~> 2.4.4) + actionpack (3.2.8) + activemodel (= 3.2.8) + activesupport (= 3.2.8) + builder (~> 3.0.0) + erubis (~> 2.7.0) + journey (~> 1.0.4) + rack (~> 1.4.0) + rack-cache (~> 1.2) + rack-test (~> 0.6.1) + sprockets (~> 2.1.3) + activemodel (3.2.8) + activesupport (= 3.2.8) + builder (~> 3.0.0) + activerecord (3.2.8) + activemodel (= 3.2.8) + activesupport (= 3.2.8) + arel (~> 3.0.2) + tzinfo (~> 0.3.29) + activeresource (3.2.8) + activemodel (= 3.2.8) + activesupport (= 3.2.8) + activesupport (3.2.8) + i18n (~> 0.6) + multi_json (~> 1.0) + addressable (2.3.2) + arel (3.0.2) + bcrypt-ruby (3.0.1) + builder (3.0.0) + capybara (1.1.2) + mime-types (>= 1.16) + nokogiri (>= 1.3.3) + rack (>= 1.0.0) + rack-test (>= 0.5.4) + selenium-webdriver (~> 2.0) + xpath (~> 0.1.4) + childprocess (0.3.5) + ffi (~> 1.0, >= 1.0.6) + coderay (1.0.7) + coffee-rails (3.2.2) + coffee-script (>= 2.2.0) + railties (~> 3.2.0) + coffee-script (2.2.0) + coffee-script-source + execjs + coffee-script-source (1.3.3) + commonjs (0.2.6) + couchrest (1.1.3) + mime-types (~> 1.15) + multi_json (~> 1.0) + rest-client (~> 1.6.1) + daemons (1.1.9) + devise (2.0.4) + bcrypt-ruby (~> 3.0) + orm_adapter (~> 0.0.3) + railties (~> 3.1) + warden (~> 1.1.1) + devise_simply_stored (0.0.2) + devise + diff-lcs (1.1.3) + erubis (2.7.0) + eventmachine (0.12.10) + execjs (1.4.0) + multi_json (~> 1.0) + ffi (1.1.5) + haml (3.1.7) + haml-rails (0.3.4) + actionpack (~> 3.0) + activesupport (~> 3.0) + haml (~> 3.0) + railties (~> 3.0) + hike (1.2.1) + i18n (0.6.0) + journey (1.0.4) + jquery-rails (2.1.1) + railties (>= 3.1.0, < 5.0) + thor (~> 0.14) + json (1.6.7) + less (2.2.1) + commonjs (~> 0.2.6) + less-rails (2.2.3) + actionpack (>= 3.1) + less (~> 2.2.0) + libv8 (3.3.10.4) + libwebsocket (0.1.5) + addressable + mail (2.4.4) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + method_source (0.8) + mime-types (1.19) + mini_magick (3.4) + subexec (~> 0.2.1) + multi_json (1.3.6) + nokogiri (1.5.5) + orm_adapter (0.0.7) + polyglot (0.3.3) + pry (0.9.10) + coderay (~> 1.0.5) + method_source (~> 0.8) + slop (~> 3.3.1) + rack (1.4.1) + rack-cache (1.2) + rack (>= 0.4) + rack-ssl (1.3.2) + rack + rack-test (0.6.1) + rack (>= 1.0) + rails (3.2.8) + actionmailer (= 3.2.8) + actionpack (= 3.2.8) + activerecord (= 3.2.8) + activeresource (= 3.2.8) + activesupport (= 3.2.8) + bundler (~> 1.0) + railties (= 3.2.8) + railties (3.2.8) + actionpack (= 3.2.8) + activesupport (= 3.2.8) + rack-ssl (~> 1.3.2) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (>= 0.14.6, < 2.0) + rake (0.9.2.2) + rdoc (3.12) + json (~> 1.4) + rest-client (1.6.7) + mime-types (>= 1.16) + rqrcode (0.4.2) + rqrcode-rails3 (0.1.5) + rqrcode (>= 0.4.2) + rspec (2.11.0) + rspec-core (~> 2.11.0) + rspec-expectations (~> 2.11.0) + rspec-mocks (~> 2.11.0) + rspec-core (2.11.1) + rspec-expectations (2.11.2) + diff-lcs (~> 1.1.3) + rspec-mocks (2.11.2) + rspec-rails (2.11.0) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec (~> 2.11.0) + rubyzip (0.9.9) + sass (3.2.1) + sass-rails (3.2.5) + railties (~> 3.2.0) + sass (>= 3.1.10) + tilt (~> 1.3) + selenium-webdriver (2.25.0) + childprocess (>= 0.2.5) + libwebsocket (~> 0.1.3) + multi_json (~> 1.0) + rubyzip + slim (1.2.2) + temple (~> 0.4.0) + tilt (~> 1.3.3) + slim-rails (1.0.3) + actionpack (~> 3.0) + activesupport (~> 3.0) + railties (~> 3.0) + slim (~> 1.0) + slop (3.3.2) + sprockets (2.1.3) + hike (~> 1.2) + rack (~> 1.0) + tilt (~> 1.1, != 1.3.0) + subexec (0.2.2) + temple (0.4.0) + therubyracer (0.10.1) + libv8 (~> 3.3.10) + thin (1.4.1) + daemons (>= 1.0.9) + eventmachine (>= 0.12.6) + rack (>= 1.0.0) + thor (0.16.0) + tilt (1.3.3) + treetop (1.4.10) + polyglot + polyglot (>= 0.3.1) + twitter-bootstrap-rails (2.1.1) + actionpack (>= 3.1) + less-rails (~> 2.2.2) + railties (>= 3.1) + therubyracer (= 0.10.1) + tzinfo (0.3.33) + uglifier (1.2.7) + execjs (>= 0.3.0) + multi_json (~> 1.3) + warden (1.1.1) + rack (>= 1.0) + xpath (0.1.4) + nokogiri (~> 1.3) + +PLATFORMS + ruby + +DEPENDENCIES + capybara + coffee-rails (~> 3.2.1) + couch_potato! + devise (= 2.0.4) + devise_simply_stored + haml-rails + jquery-rails + mini_magick + pry + rails (= 3.2.8) + rqrcode-rails3 + rspec-rails + sass-rails (~> 3.2.3) + simply_stored! + slim-rails + thin + twitter-bootstrap-rails + uglifier (>= 1.0.3) diff --git a/Models.dia b/Models.dia new file mode 100644 index 00000000..42127149 Binary files /dev/null and b/Models.dia differ diff --git a/Models.dia~ b/Models.dia~ new file mode 100644 index 00000000..13ab58d5 Binary files /dev/null and b/Models.dia~ differ diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 00000000..7c36f235 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,261 @@ +== Welcome to Rails + +Rails is a web-application framework that includes everything needed to create +database-backed web applications according to the Model-View-Control pattern. + +This pattern splits the view (also called the presentation) into "dumb" +templates that are primarily responsible for inserting pre-built data in between +HTML tags. The model contains the "smart" domain objects (such as Account, +Product, Person, Post) that holds all the business logic and knows how to +persist themselves to a database. The controller handles the incoming requests +(such as Save New Account, Update Product, Show Post) by manipulating the model +and directing data to the view. + +In Rails, the model is handled by what's called an object-relational mapping +layer entitled Active Record. This layer allows you to present the data from +database rows as objects and embellish these data objects with business logic +methods. You can read more about Active Record in +link:files/vendor/rails/activerecord/README.html. + +The controller and view are handled by the Action Pack, which handles both +layers by its two parts: Action View and Action Controller. These two layers +are bundled in a single package due to their heavy interdependence. This is +unlike the relationship between the Active Record and Action Pack that is much +more separate. Each of these packages can be used independently outside of +Rails. You can read more about Action Pack in +link:files/vendor/rails/actionpack/README.html. + + +== Getting Started + +1. At the command prompt, create a new Rails application: + rails new myapp (where myapp is the application name) + +2. Change directory to myapp and start the web server: + cd myapp; rails server (run with --help for options) + +3. Go to http://localhost:3000/ and you'll see: + "Welcome aboard: You're riding Ruby on Rails!" + +4. Follow the guidelines to start developing your application. You can find +the following resources handy: + +* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html +* Ruby on Rails Tutorial Book: http://www.railstutorial.org/ + + +== Debugging Rails + +Sometimes your application goes wrong. Fortunately there are a lot of tools that +will help you debug it and get it back on the rails. + +First area to check is the application log files. Have "tail -f" commands +running on the server.log and development.log. Rails will automatically display +debugging and runtime information to these files. Debugging info will also be +shown in the browser on requests from 127.0.0.1. + +You can also log your own messages directly into the log file from your code +using the Ruby logger class from inside your controllers. Example: + + class WeblogController < ActionController::Base + def destroy + @weblog = Weblog.find(params[:id]) + @weblog.destroy + logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!") + end + end + +The result will be a message in your log file along the lines of: + + Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1! + +More information on how to use the logger is at http://www.ruby-doc.org/core/ + +Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are +several books available online as well: + +* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe) +* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide) + +These two books will bring you up to speed on the Ruby language and also on +programming in general. + + +== Debugger + +Debugger support is available through the debugger command when you start your +Mongrel or WEBrick server with --debugger. This means that you can break out of +execution at any point in the code, investigate and change the model, and then, +resume execution! You need to install ruby-debug to run the server in debugging +mode. With gems, use sudo gem install ruby-debug. Example: + + class WeblogController < ActionController::Base + def index + @posts = Post.all + debugger + end + end + +So the controller will accept the action, run the first line, then present you +with a IRB prompt in the server window. Here you can do things like: + + >> @posts.inspect + => "[#nil, "body"=>nil, "id"=>"1"}>, + #"Rails", "body"=>"Only ten..", "id"=>"2"}>]" + >> @posts.first.title = "hello from a debugger" + => "hello from a debugger" + +...and even better, you can examine how your runtime objects actually work: + + >> f = @posts.first + => #nil, "body"=>nil, "id"=>"1"}> + >> f. + Display all 152 possibilities? (y or n) + +Finally, when you're ready to resume execution, you can enter "cont". + + +== Console + +The console is a Ruby shell, which allows you to interact with your +application's domain model. Here you'll have all parts of the application +configured, just like it is when the application is running. You can inspect +domain models, change values, and save to the database. Starting the script +without arguments will launch it in the development environment. + +To start the console, run rails console from the application +directory. + +Options: + +* Passing the -s, --sandbox argument will rollback any modifications + made to the database. +* Passing an environment name as an argument will load the corresponding + environment. Example: rails console production. + +To reload your controllers and models after launching the console run +reload! + +More information about irb can be found at: +link:http://www.rubycentral.org/pickaxe/irb.html + + +== dbconsole + +You can go to the command line of your database directly through rails +dbconsole. You would be connected to the database with the credentials +defined in database.yml. Starting the script without arguments will connect you +to the development database. Passing an argument will connect you to a different +database, like rails dbconsole production. Currently works for MySQL, +PostgreSQL and SQLite 3. + +== Description of Contents + +The default directory structure of a generated Ruby on Rails application: + + |-- app + | |-- assets + | |-- images + | |-- javascripts + | `-- stylesheets + | |-- controllers + | |-- helpers + | |-- mailers + | |-- models + | `-- views + | `-- layouts + |-- config + | |-- environments + | |-- initializers + | `-- locales + |-- db + |-- doc + |-- lib + | `-- tasks + |-- log + |-- public + |-- script + |-- test + | |-- fixtures + | |-- functional + | |-- integration + | |-- performance + | `-- unit + |-- tmp + | |-- cache + | |-- pids + | |-- sessions + | `-- sockets + `-- vendor + |-- assets + `-- stylesheets + `-- plugins + +app + Holds all the code that's specific to this particular application. + +app/assets + Contains subdirectories for images, stylesheets, and JavaScript files. + +app/controllers + Holds controllers that should be named like weblogs_controller.rb for + automated URL mapping. All controllers should descend from + ApplicationController which itself descends from ActionController::Base. + +app/models + Holds models that should be named like post.rb. Models descend from + ActiveRecord::Base by default. + +app/views + Holds the template files for the view that should be named like + weblogs/index.html.erb for the WeblogsController#index action. All views use + eRuby syntax by default. + +app/views/layouts + Holds the template files for layouts to be used with views. This models the + common header/footer method of wrapping views. In your views, define a layout + using the layout :default and create a file named default.html.erb. + Inside default.html.erb, call <% yield %> to render the view using this + layout. + +app/helpers + Holds view helpers that should be named like weblogs_helper.rb. These are + generated for you automatically when using generators for controllers. + Helpers can be used to wrap functionality for your views into methods. + +config + Configuration files for the Rails environment, the routing map, the database, + and other dependencies. + +db + Contains the database schema in schema.rb. db/migrate contains all the + sequence of Migrations for your schema. + +doc + This directory is where your application documentation will be stored when + generated using rake doc:app + +lib + Application specific libraries. Basically, any kind of custom code that + doesn't belong under controllers, models, or helpers. This directory is in + the load path. + +public + The directory available for the web server. Also contains the dispatchers and the + default HTML files. This should be set as the DOCUMENT_ROOT of your web + server. + +script + Helper scripts for automation and generation. + +test + Unit and functional tests along with fixtures. When using the rails generate + command, template test files will be generated for you and placed in this + directory. + +vendor + External libraries that the application depends on. Also includes the plugins + subdirectory. If the app has frozen rails, those gems also go here, under + vendor/rails/. This directory is in the load path. diff --git a/Rakefile b/Rakefile new file mode 100644 index 00000000..d90f991d --- /dev/null +++ b/Rakefile @@ -0,0 +1,7 @@ +#!/usr/bin/env rake +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require File.expand_path('../config/application', __FILE__) + +Qrammer::Application.load_tasks diff --git a/app/assets/images/rails.png b/app/assets/images/rails.png new file mode 100644 index 00000000..d5edc04e Binary files /dev/null and b/app/assets/images/rails.png differ diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 00000000..57338106 --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,16 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// the compiled file. +// +// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD +// GO AFTER THE REQUIRES BELOW. +// +//= require jquery +//= require jquery_ujs +//= require twitter/bootstrap +//= require_tree . diff --git a/app/assets/javascripts/bootstrap.js.coffee b/app/assets/javascripts/bootstrap.js.coffee new file mode 100644 index 00000000..c9404a8e --- /dev/null +++ b/app/assets/javascripts/bootstrap.js.coffee @@ -0,0 +1,4 @@ +jQuery -> + $("a[rel=popover]").popover() + $(".tooltip").tooltip() + $("a[rel=tooltip]").tooltip() \ No newline at end of file diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 00000000..3192ec89 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,13 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the top of the + * compiled file, but it's generally better to create a new file per style scope. + * + *= require_self + *= require_tree . + */ diff --git a/app/assets/stylesheets/bootstrap_and_overrides.css.less b/app/assets/stylesheets/bootstrap_and_overrides.css.less new file mode 100644 index 00000000..14bf301d --- /dev/null +++ b/app/assets/stylesheets/bootstrap_and_overrides.css.less @@ -0,0 +1,32 @@ +@import "twitter/bootstrap/bootstrap"; +body { + padding-top: 60px; +} + +@import "twitter/bootstrap/responsive"; + +// Set the correct sprite paths +@iconSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings.png'); +@iconWhiteSpritePath: asset-path('twitter/bootstrap/glyphicons-halflings-white.png'); + +// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines) +// Note: If you use asset_path() here, your compiled boostrap_and_overrides.css will not +// have the proper paths. So for now we use the absolute path. +@fontAwesomeEotPath: '/assets/fontawesome-webfont.eot'; +@fontAwesomeWoffPath: '/assets/fontawesome-webfont.woff'; +@fontAwesomeTtfPath: '/assets/fontawesome-webfont.ttf'; +@fontAwesomeSvgPath: '/assets/fontawesome-webfont.svg'; + +// Font Awesome +@import "fontawesome"; + +// Your custom LESS stylesheets goes here +// +// Since bootstrap was imported above you have access to its mixins which +// you may use and inherit here +// +// If you'd like to override bootstrap's own variables, you can do so here as well +// See http://twitter.github.com/bootstrap/less.html for their names and documentation +// +// Example: +// @linkColor: #ff0000; diff --git a/app/assets/stylesheets/users.css.scss b/app/assets/stylesheets/users.css.scss new file mode 100644 index 00000000..31a2eacb --- /dev/null +++ b/app/assets/stylesheets/users.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Users controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 00000000..258705b5 --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,10 @@ +class ApplicationController < ActionController::Base + protect_from_forgery + + private + + def active_list + List.find(session[:list_id]) + end + helper_method :active_list +end diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb new file mode 100644 index 00000000..6860fdc3 --- /dev/null +++ b/app/controllers/dashboard_controller.rb @@ -0,0 +1,30 @@ +class DashboardController < ApplicationController + + def home + + end + + # Testing action + def select_qrcode + @tables = Table.all + end + + def create_list + @table = Table.find(params[:table_id]) + if @table.occupied? + redirect_to root_path, alert: t('table.is_occupied') + else + @list = List.new(table: @table) + #@list.add_user(current_user) + @list.save + session[:list_id] = @list.id + redirect_to root_path + end + end + + def show_products + @supplier = Supplier.first + + + end +end diff --git a/app/controllers/lists_controller.rb b/app/controllers/lists_controller.rb new file mode 100644 index 00000000..b2a888f5 --- /dev/null +++ b/app/controllers/lists_controller.rb @@ -0,0 +1,90 @@ +class ListsController < ApplicationController + before_filter :set_relation_options, only: [:new, :edit, :create, :update] + # GET /lists + # GET /lists.json + def index + @lists = List.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @lists } + end + end + + # GET /lists/1 + # GET /lists/1.json + def show + @list = List.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @list } + end + end + + # GET /lists/new + # GET /lists/new.json + def new + @list = List.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @list } + end + end + + # GET /lists/1/edit + def edit + @list = List.find(params[:id]) + end + + # POST /lists + # POST /lists.json + def create + @list = List.new(params[:list]) + + respond_to do |format| + if @list.save + format.html { redirect_to @list, notice: t('action.create.successfull', model: List.model_name.human) } + format.json { render json: @list, status: :created, location: @list } + else + format.html { render action: "new" } + format.json { render json: @list.errors, status: :unprocessable_entity } + end + end + end + + # PUT /lists/1 + # PUT /lists/1.json + def update + @list = List.find(params[:id]) + + respond_to do |format| + if @list.update_attributes(params[:list]) + format.html { redirect_to @list, notice: t('action.update.successfull', model: List.model_name.human) } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @list.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /lists/1 + # DELETE /lists/1.json + def destroy + @list = List.find(params[:id]) + @list.destroy + + respond_to do |format| + format.html { redirect_to lists_url, notice: t('action.destroy.successfull', model: List.model_name.human) } + format.json { head :no_content } + end + end + + private + + def set_relation_options + @tables = Table.all + end +end diff --git a/app/controllers/product_categories_controller.rb b/app/controllers/product_categories_controller.rb new file mode 100644 index 00000000..cc7fb69b --- /dev/null +++ b/app/controllers/product_categories_controller.rb @@ -0,0 +1,102 @@ +class ProductCategoriesController < ApplicationController + before_filter :set_relation_options, only: [:new, :edit, :create, :update] + # GET /product_categories + # GET /product_categories.json + def index + @product_categories = ProductCategory.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @product_categories } + end + end + + # GET /product_categories/1 + # GET /product_categories/1.json + def show + @product_category = ProductCategory.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @product_category } + end + end + + # GET /product_categories/new + # GET /product_categories/new.json + def new + @product_category = ProductCategory.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @product_category } + end + end + + # GET /product_categories/1/edit + def edit + @product_category = ProductCategory.find(params[:id]) + end + + # POST /product_categories + # POST /product_categories.json + def create + @product_category = ProductCategory.new(params[:product_category]) + + respond_to do |format| + if @product_category.save + format.html { redirect_to @product_category, notice: t('action.create.successfull', model: ProductCategory.model_name.human) } + format.json { render json: @product_category, status: :created, location: @product_category } + else + format.html { render action: "new" } + format.json { render json: @product_category.errors, status: :unprocessable_entity } + end + end + end + + # PUT /product_categories/1 + # PUT /product_categories/1.json + def update + @product_category = ProductCategory.find(params[:id]) + + respond_to do |format| + if @product_category.update_attributes(params[:product_category]) + format.html { redirect_to @product_category, notice: t('action.update.successfull', model: ProductCategory.model_name.human) } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @product_category.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /product_categories/1 + # DELETE /product_categories/1.json + def destroy + @product_category = ProductCategory.find(params[:id]) + @product_category.destroy + + respond_to do |format| + format.html { redirect_to product_categories_url, notice: t('action.destroy.successfull', model: ProductCategory.model_name.human) } + format.json { head :no_content } + end + end + + # GET /product_categories/qrcode + # GET /product_categories/qrcode.png + # GET /product_categories/qrcode.svg + def qrcode + respond_to do |format| + format.html + format.svg { render :qrcode => request.url, :level => :l, :unit => 10 } + format.png { render qrcode: request.url } + end + end + + private + + def set_relation_options + @suppliers = Supplier.all + @lists = List.all + end +end diff --git a/app/controllers/products_controller.rb b/app/controllers/products_controller.rb new file mode 100644 index 00000000..07a8febb --- /dev/null +++ b/app/controllers/products_controller.rb @@ -0,0 +1,91 @@ +class ProductsController < ApplicationController + before_filter :set_relation_options, only: [:new, :edit, :create, :update] + # GET /products + # GET /products.json + def index + @products = Product.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @products } + end + end + + # GET /products/1 + # GET /products/1.json + def show + @product = Product.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @product } + end + end + + # GET /products/new + # GET /products/new.json + def new + @product = Product.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @product } + end + end + + # GET /products/1/edit + def edit + @product = Product.find(params[:id]) + end + + # POST /products + # POST /products.json + def create + @product = Product.new(params[:product]) + + respond_to do |format| + if @product.save + format.html { redirect_to @product, notice: t('action.create.successfull', model: Product.model_name.human) } + format.json { render json: @product, status: :created, location: @product } + else + format.html { render action: "new" } + format.json { render json: @product.errors, status: :unprocessable_entity } + end + end + end + + # PUT /products/1 + # PUT /products/1.json + def update + @product = Product.find(params[:id]) + + respond_to do |format| + if @product.update_attributes(params[:product]) + format.html { redirect_to @product, notice: t('action.update.successfull', model: Product.model_name.human) } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @product.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /products/1 + # DELETE /products/1.json + def destroy + @product = Product.find(params[:id]) + @product.destroy + + respond_to do |format| + format.html { redirect_to products_url, notice: t('action.destroy.successfull', model: Product.model_name.human) } + format.json { head :no_content } + end + end + + private + + def set_relation_options + @suppliers = Supplier.all + @product_categories = ProductCategory.all + end +end diff --git a/app/controllers/suppliers_controller.rb b/app/controllers/suppliers_controller.rb new file mode 100644 index 00000000..1d533ea5 --- /dev/null +++ b/app/controllers/suppliers_controller.rb @@ -0,0 +1,106 @@ +class SuppliersController < ApplicationController + before_filter :set_relation_options, only: [:new, :edit, :create, :update] + # GET /suppliers + # GET /suppliers.json + def index + @suppliers = Supplier.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @suppliers } + end + end + + # GET /suppliers/1 + # GET /suppliers/1.json + def show + @supplier = Supplier.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @supplier } + end + end + + # GET /suppliers/new + # GET /suppliers/new.json + def new + @supplier = Supplier.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @supplier } + end + end + + # GET /suppliers/1/edit + def edit + @supplier = Supplier.find(params[:id]) + end + + # POST /suppliers + # POST /suppliers.json + def create + @supplier = Supplier.new(params[:supplier]) + + respond_to do |format| + if @supplier.save + format.html { redirect_to @supplier, notice: t('action.create.successfull', model: Supplier.model_name.human) } + format.json { render json: @supplier, status: :created, location: @supplier } + else + format.html { render action: "new" } + format.json { render json: @supplier.errors, status: :unprocessable_entity } + end + end + end + + # PUT /suppliers/1 + # PUT /suppliers/1.json + def update + @supplier = Supplier.find(params[:id]) + + respond_to do |format| + if @supplier.update_attributes(params[:supplier]) + format.html { redirect_to @supplier, notice: t('action.update.successfull', model: Supplier.model_name.human) } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @supplier.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /suppliers/1 + # DELETE /suppliers/1.json + def destroy + @supplier = Supplier.find(params[:id]) + @supplier.destroy + + respond_to do |format| + format.html { redirect_to suppliers_url, notice: t('action.destroy.successfull', model: Supplier.model_name.human) } + format.json { head :no_content } + end + end + + # GET /suppliers/1/product_list + # GET /suppliers/1/product_list.json + def product_list + @supplier = Supplier.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json do + products = @supplier.products + products.include_relation(:product_categories) + h = products.inject({}){|h, p| n = p.product_category.try(:name) || 'other'; h[n] ||= []; h[n] << p; h} + render json: h + end + end + end + private + + def set_relation_options + @suppliers = Supplier.all + @lists = List.all + end +end diff --git a/app/controllers/tables_controller.rb b/app/controllers/tables_controller.rb new file mode 100644 index 00000000..3febd009 --- /dev/null +++ b/app/controllers/tables_controller.rb @@ -0,0 +1,102 @@ +class TablesController < ApplicationController + before_filter :set_relation_options, only: [:new, :edit, :create, :update] + # GET /tables + # GET /tables.json + def index + @tables = Table.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @tables } + end + end + + # GET /tables/1 + # GET /tables/1.json + def show + @table = Table.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @table } + end + end + + # GET /tables/new + # GET /tables/new.json + def new + @table = Table.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @table } + end + end + + # GET /tables/1/edit + def edit + @table = Table.find(params[:id]) + end + + # POST /tables + # POST /tables.json + def create + @table = Table.new(params[:table]) + + respond_to do |format| + if @table.save + format.html { redirect_to @table, notice: t('action.create.successfull', model: Table.model_name.human) } + format.json { render json: @table, status: :created, location: @table } + else + format.html { render action: "new" } + format.json { render json: @table.errors, status: :unprocessable_entity } + end + end + end + + # PUT /tables/1 + # PUT /tables/1.json + def update + @table = Table.find(params[:id]) + + respond_to do |format| + if @table.update_attributes(params[:table]) + format.html { redirect_to @table, notice: t('action.update.successfull', model: Table.model_name.human) } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @table.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /tables/1 + # DELETE /tables/1.json + def destroy + @table = Table.find(params[:id]) + @table.destroy + + respond_to do |format| + format.html { redirect_to tables_url, notice: t('action.destroy.successfull', model: Table.model_name.human) } + format.json { head :no_content } + end + end + + # GET /tables/qrcode + # GET /tables/qrcode.png + # GET /tables/qrcode.svg + def qrcode + respond_to do |format| + format.html + format.svg { render :qrcode => request.url, :level => :l, :unit => 10 } + format.png { render qrcode: request.url } + end + end + + private + + def set_relation_options + @suppliers = Supplier.all + @lists = List.all + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb new file mode 100644 index 00000000..31c8b5c7 --- /dev/null +++ b/app/controllers/users_controller.rb @@ -0,0 +1,83 @@ +class UsersController < ApplicationController + # GET /users + # GET /users.json + def index + @users = User.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @users } + end + end + + # GET /users/1 + # GET /users/1.json + def show + @user = User.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @user } + end + end + + # GET /users/new + # GET /users/new.json + def new + @user = User.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @user } + end + end + + # GET /users/1/edit + def edit + @user = User.find(params[:id]) + end + + # POST /users + # POST /users.json + def create + @user = User.new(params[:user]) + + respond_to do |format| + if @user.save + format.html { redirect_to @user, notice: t('action.create.successfull', model: User.model_name.human) } + format.json { render json: @user, status: :created, location: @user } + else + format.html { render action: "new" } + format.json { render json: @user.errors, status: :unprocessable_entity } + end + end + end + + # PUT /users/1 + # PUT /users/1.json + def update + @user = User.find(params[:id]) + + respond_to do |format| + if @user.update_attributes(params[:user]) + format.html { redirect_to @user, notice: t('action.update.successfull', model: User.model_name.human) } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @user.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /users/1 + # DELETE /users/1.json + def destroy + @user = User.find(params[:id]) + @user.destroy + + respond_to do |format| + format.html { redirect_to users_url, notice: t('action.destroy.successfull', model: User.model_name.human) } + format.json { head :no_content } + end + end +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 00000000..9a1aef14 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,28 @@ +module ApplicationHelper + def title(*args) + content_tag :h1 do + if args.first.is_a?(Symbol) && (args[1].respond_to?(:model_name) || args[1].class.respond_to?(:model_name)) + model = args[1].respond_to?(:model_name) ? args[1] : args[1].class + if args.first == :index + t('action.index.label', models: model.model_name.human_plural) + else + t("action.#{args.first}.label", model: model.model_name.human) + end + else + args.first + end + end + end + + def are_you_sure? + t('helpers.links.are_you_sure') + end + + def list_open? + session[:list_id].present? + end + + def no_content_given(model) + t('helpers.list.no_records') + end +end diff --git a/app/mailers/.gitkeep b/app/mailers/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/app/models/.gitkeep b/app/models/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/app/models/list.rb b/app/models/list.rb new file mode 100644 index 00000000..183f1d8f --- /dev/null +++ b/app/models/list.rb @@ -0,0 +1,21 @@ +class List + include SimplyStored::Couch + + property :state + property :closed_at, type: Time + has_many :orders + belongs_to :table + has_and_belongs_to_many :users, storing_keys: true + + validates :table_id, presence: true + + def close! + self.state = 'closed' + self.closed_at = Time.now + save + end + + def supplier + table.supplier + end +end diff --git a/app/models/order.rb b/app/models/order.rb new file mode 100644 index 00000000..dcf5576c --- /dev/null +++ b/app/models/order.rb @@ -0,0 +1,9 @@ +class Order + include SimplyStored::Couch + + belongs_to :list + belongs_to :user + + has_many :product_orders + has_many :products, through: :product_orders +end diff --git a/app/models/product.rb b/app/models/product.rb new file mode 100644 index 00000000..8a9d68ae --- /dev/null +++ b/app/models/product.rb @@ -0,0 +1,14 @@ +class Product + include SimplyStored::Couch + + property :name + property :code + property :price + + belongs_to :product_category + belongs_to :supplier # direct! category is an aid + has_many :product_orders + + validates :supplier_id, presence: true + +end diff --git a/app/models/product_category.rb b/app/models/product_category.rb new file mode 100644 index 00000000..63437d58 --- /dev/null +++ b/app/models/product_category.rb @@ -0,0 +1,7 @@ +class ProductCategory + include SimplyStored::Couch + + property :name + belongs_to :supplier + has_many :products +end diff --git a/app/models/product_order.rb b/app/models/product_order.rb new file mode 100644 index 00000000..d0286dfc --- /dev/null +++ b/app/models/product_order.rb @@ -0,0 +1,6 @@ +class ProductOrder + include SimplyStored::Couch + + belongs_to :product + belongs_to :order +end diff --git a/app/models/supplier.rb b/app/models/supplier.rb new file mode 100644 index 00000000..d869d251 --- /dev/null +++ b/app/models/supplier.rb @@ -0,0 +1,10 @@ +class Supplier + include SimplyStored::Couch + + property :name + has_many :lists + has_many :orders, through: :lists + has_many :products + has_many :product_categories + has_many :tables +end diff --git a/app/models/table.rb b/app/models/table.rb new file mode 100644 index 00000000..39ee6b94 --- /dev/null +++ b/app/models/table.rb @@ -0,0 +1,23 @@ +class Table + include SimplyStored::Couch + + property :number, type: Fixnum, default: 1 + + belongs_to :supplier + has_many :lists + + validates :supplier_id, presence: true + #validates :list_id, presence: true + validates :number, numericality: {greater_than: 0} + + view :active_lists, type: :custom, map_function: %|function(doc){ + if(doc.ruby_class == 'List' && doc.state == 'active'){ + emit(doc._id, 1); + } + }|, reduce_function: '_sum' + + def occupied? + not self.class.database.view(self.class.active_lists(key: list_id, reduce: true)).zero? + end + +end diff --git a/app/models/user.rb b/app/models/user.rb new file mode 100644 index 00000000..944c9933 --- /dev/null +++ b/app/models/user.rb @@ -0,0 +1,10 @@ +class User + include SimplyStored::Couch + include Devise::Orm::SimplyStored + devise :database_authenticatable, :recoverable, :rememberable, :trackable + + has_and_belongs_to_many :lists, storing_keys: false + has_many :orders + + validates_uniqueness_of :email +end diff --git a/app/views/application/_error_messages.html.haml b/app/views/application/_error_messages.html.haml new file mode 100644 index 00000000..6437f6a7 --- /dev/null +++ b/app/views/application/_error_messages.html.haml @@ -0,0 +1,7 @@ +-if target.errors.any? + #error_explanation + .errors-content + %h2= t('helpers.forms.errors.title', :count => target.errors.count) + %ul + - for message in target.errors.full_messages + %li= message diff --git a/app/views/dashboard/home.html.slim b/app/views/dashboard/home.html.slim new file mode 100644 index 00000000..7ca57290 --- /dev/null +++ b/app/views/dashboard/home.html.slim @@ -0,0 +1,15 @@ +.page-header= title 'Home' +ul.nav.nav-tabs.nav-stacked + - if list_open? + li.active= link_to '€ 23,45'.html_safe, '#' + li= link_to 'Place order', '/show_products?supplier_id=' + active_list.supplier.id + li= link_to 'Active list', '#' + li= link_to 'Request bill', '#' + li= link_to 'I have a question', '#' + - else + li= link_to 'Place order', '/select_qrcode' + li= link_to 'Subscribe to list', '#' + +ul.nav.nav-tabs.nav-stacked + li= link_to 'View history', '#' + diff --git a/app/views/dashboard/select_qrcode.html.slim b/app/views/dashboard/select_qrcode.html.slim new file mode 100644 index 00000000..a9660972 --- /dev/null +++ b/app/views/dashboard/select_qrcode.html.slim @@ -0,0 +1,4 @@ +.page-header= title 'Select Qr code' +ul + - for table in @tables + li= link_to image_tag(url_for(qrcode_table_path(table, format: :png))), {action: :create_list, table_id: table.id} diff --git a/app/views/dashboard/show_products.html.slim b/app/views/dashboard/show_products.html.slim new file mode 100644 index 00000000..950bc197 --- /dev/null +++ b/app/views/dashboard/show_products.html.slim @@ -0,0 +1,17 @@ +table#products-table.table.table-striped.table-hover + tbody +- content_for :footer do + javascript: + jQuery(function(){ + $.get('#{product_list_supplier_path(@supplier, format: :json).html_safe}', function(res){ + window.products = res + body = $('#products-table tbody') + for(category in window.products){ + body.append('

'+category+'

') + for(iproduct in window.products[category]){ + body.append(''+window.products[category][iproduct].name+'') + } + } + }) + }) + diff --git a/app/views/layouts/application.html.slim b/app/views/layouts/application.html.slim new file mode 100644 index 00000000..2441dbe7 --- /dev/null +++ b/app/views/layouts/application.html.slim @@ -0,0 +1,68 @@ +doctype html +html lang="en" + head + meta charset="utf-8" + meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" + meta name="viewport" content="width=device-width, initial-scale=1.0" + title= content_for?(:title) ? yield(:title) : "Qrammer" + = csrf_meta_tags + + /! Le HTML5 shim, for IE6-8 support of HTML elements + /[if lt IE 9] + = javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js" + = stylesheet_link_tag "application", :media => "all" + link href="images/apple-touch-icon-144x144.png" rel="apple-touch-icon-precomposed" sizes="144x144" + link href="images/apple-touch-icon-114x114.png" rel="apple-touch-icon-precomposed" sizes="114x114" + link href="images/apple-touch-icon-72x72.png" rel="apple-touch-icon-precomposed" sizes="72x72" + link href="images/apple-touch-icon.png" rel="apple-touch-icon-precomposed" + link href="images/favicon.ico" rel="shortcut icon" + + body + .navbar.navbar-fixed-top + .navbar-inner + .container + a.btn.btn-navbar data-target=".nav-collapse" data-toggle="collapse" + span.icon-bar + span.icon-bar + span.icon-bar + a.brand href=root_path Qrammer + .container.nav-collapse + ul.nav + li= link_to User.model_name.human_plural, users_path + li= link_to Supplier.model_name.human_plural, suppliers_path + li= link_to Table.model_name.human_plural, tables_path + li= link_to Product.model_name.human_plural, products_path + li= link_to List.model_name.human_plural, lists_path + li= link_to ProductCategory.model_name.human_plural, product_categories_path + + .container + + .content + - if flash[:alert].present? + .alert.alert-error + a.close data-dismiss="alert" × + div= flash[:alert] + - if flash[:notice].present? + .alert.alert-success + a.close data-dismiss="alert" × + div= flash[:notice] + .row + .span9 + = yield + .span3 + .well.sidebar-nav + h3 Sidebar + ul.nav.nav-list + li.nav-header Sidebar + li= link_to "Link 1", "/path1" + li= link_to "Link 2", "/path2" + li= link_to "Link 3", "/path3" + + footer + p © Companytools 2012 + /! + Javascripts + \================================================== + /! Placed at the end of the document so the pages load faster + = javascript_include_tag "application" + = yield :footer diff --git a/app/views/lists/_form.html.slim b/app/views/lists/_form.html.slim new file mode 100644 index 00000000..f720146f --- /dev/null +++ b/app/views/lists/_form.html.slim @@ -0,0 +1,18 @@ += form_for @list, html: {class: 'form-horizontal' } do |f| + = render 'error_messages', target: @list + .control-group class=(@list.errors[:state].any? ? 'error' : nil) + = f.label :state, class: 'control-label' + .controls + = f.text_field :state, class: 'text_field' + .control-group class=(@list.errors[:closed_at].any? ? 'error' : nil) + = f.label :closed_at, class: 'control-label' + .controls + = f.text_field :closed_at, class: 'text_field' + .control-group class=(@list.errors[:table_id].any? ? 'error' : nil) + = f.label :table_id, Table.model_name.human, class: 'control-label' + .controls + = f.select :table_id, options_for_select(@tables.map{|a| [a.number, a.id]}), include_blank: nil + .form-actions + = f.submit nil, class: 'btn btn-primary' + ' + = link_to t("helpers.links.cancel"), lists_path, class: 'btn' diff --git a/app/views/lists/edit.html.slim b/app/views/lists/edit.html.slim new file mode 100644 index 00000000..ca61d424 --- /dev/null +++ b/app/views/lists/edit.html.slim @@ -0,0 +1,4 @@ +- model_class = List +.page-header + = title :edit, model_class += render 'form' diff --git a/app/views/lists/index.html.slim b/app/views/lists/index.html.slim new file mode 100644 index 00000000..521066c1 --- /dev/null +++ b/app/views/lists/index.html.slim @@ -0,0 +1,26 @@ +- model_class = List +div.page-header= title :index, model_class +- if @lists.any? + table.table.table-striped + thead + tr + th= model_class.human_attribute_name(:state) + th= model_class.human_attribute_name(:closed_at) + th= Table.model_name.human + th= model_class.human_attribute_name(:created_at) + th=t 'helpers.actions' + tbody + - @lists.each do |list| + tr + td= link_to list.state, list + td= list.closed_at + td= link_to list.table.number, list.table + td=l list.created_at, format: :short + td + = link_to t('helpers.links.edit'), [:edit, list], class: 'btn btn-mini' + ' + = link_to t("helpers.links.destroy"), list, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger' +- else + = no_content_given model_class += link_to t("helpers.links.new"), new_list_path, class: 'btn btn-primary' + diff --git a/app/views/lists/new.html.slim b/app/views/lists/new.html.slim new file mode 100644 index 00000000..bcaacff3 --- /dev/null +++ b/app/views/lists/new.html.slim @@ -0,0 +1,4 @@ +- model_class = List +.page-header + = title :new, model_class += render 'form' diff --git a/app/views/lists/show.html.slim b/app/views/lists/show.html.slim new file mode 100644 index 00000000..64a23be7 --- /dev/null +++ b/app/views/lists/show.html.slim @@ -0,0 +1,18 @@ +- model_class = List +.page-header= title :show, @list + +dl.dl-horizontal.show-list + dt= model_class.human_attribute_name(:state) + dd= @list.state + dt= model_class.human_attribute_name(:closed_at) + dd= @list.closed_at + - if @list.table.present? + dt= Table.model_name.human + dd= link_to @list.table.number, @list.table + +.form-actions + = link_to t("helpers.links.back"), lists_path, class: 'btn' + ' + = link_to t('helpers.links.edit'), [:edit, @list], class: 'btn' + ' + = link_to t("helpers.links.destroy"), @list, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger' diff --git a/app/views/product_categories/_form.html.slim b/app/views/product_categories/_form.html.slim new file mode 100644 index 00000000..62cda1ff --- /dev/null +++ b/app/views/product_categories/_form.html.slim @@ -0,0 +1,14 @@ += form_for @product_category, html: {class: 'form-horizontal' } do |f| + = render 'error_messages', target: @product_category + .control-group class=(@product_category.errors[:name].any? ? 'error' : nil) + = f.label :name, class: 'control-label' + .controls + = f.text_field :name, class: 'text_field' + .control-group class=(@product_category.errors[:supplier_id].any? ? 'error' : nil) + = f.label :supplier_id, Supplier.model_name.human, class: 'control-label' + .controls + = f.select :supplier_id, options_for_select(@suppliers.map{|a| [a.name, a.id]}), include_blank: nil + .form-actions + = f.submit nil, class: 'btn btn-primary' + ' + = link_to t("helpers.links.cancel"), product_categories_path, class: 'btn' diff --git a/app/views/product_categories/edit.html.slim b/app/views/product_categories/edit.html.slim new file mode 100644 index 00000000..b68302b0 --- /dev/null +++ b/app/views/product_categories/edit.html.slim @@ -0,0 +1,4 @@ +- model_class = ProductCategory +.page-header + = title :edit, model_class += render 'form' diff --git a/app/views/product_categories/index.html.slim b/app/views/product_categories/index.html.slim new file mode 100644 index 00000000..a3fb20d2 --- /dev/null +++ b/app/views/product_categories/index.html.slim @@ -0,0 +1,24 @@ +- model_class = ProductCategory +div.page-header= title :index, model_class +- if @product_categories.any? + table.table.table-striped + thead + tr + th= model_class.human_attribute_name(:name) + th= Supplier.model_name.human + th= model_class.human_attribute_name(:created_at) + th=t 'helpers.actions' + tbody + - @product_categories.each do |product_category| + tr + td= link_to product_category.name, product_category + td= link_to product_category.supplier.name, product_category.supplier + td=l product_category.created_at, format: :short + td + = link_to t('helpers.links.edit'), [:edit, product_category], class: 'btn btn-mini' + ' + = link_to t("helpers.links.destroy"), product_category, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger' +- else + = no_content_given model_class += link_to t("helpers.links.new"), new_product_category_path, class: 'btn btn-primary' + diff --git a/app/views/product_categories/new.html.slim b/app/views/product_categories/new.html.slim new file mode 100644 index 00000000..4c3f76bd --- /dev/null +++ b/app/views/product_categories/new.html.slim @@ -0,0 +1,4 @@ +- model_class = ProductCategory +.page-header + = title :new, model_class += render 'form' diff --git a/app/views/product_categories/show.html.slim b/app/views/product_categories/show.html.slim new file mode 100644 index 00000000..9b2ed4a7 --- /dev/null +++ b/app/views/product_categories/show.html.slim @@ -0,0 +1,15 @@ +- model_class = ProductCategory +.page-header= title :show, @product_category + +dl.dl-horizontal.show-list + dt= model_class.human_attribute_name(:name) + dd= @product_category.name + dt= Supplier.model_name.human + dd= link_to @product_category.supplier.name, @product_category.supplier + +.form-actions + = link_to t("helpers.links.back"), product_categories_path, class: 'btn' + ' + = link_to t('helpers.links.edit'), [:edit, @product_category], class: 'btn' + ' + = link_to t("helpers.links.destroy"), @product_category, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger' diff --git a/app/views/products/_form.html.slim b/app/views/products/_form.html.slim new file mode 100644 index 00000000..5896daaf --- /dev/null +++ b/app/views/products/_form.html.slim @@ -0,0 +1,26 @@ += form_for @product, html: {class: 'form-horizontal' } do |f| + = render 'error_messages', target: @product + .control-group class=(@product.errors[:name].any? ? 'error' : nil) + = f.label :name, class: 'control-label' + .controls + = f.text_field :name, class: 'text_field' + .control-group class=(@product.errors[:code].any? ? 'error' : nil) + = f.label :code, class: 'control-label' + .controls + = f.text_field :code, class: 'text_field' + .control-group class=(@product.errors[:price].any? ? 'error' : nil) + = f.label :price, class: 'control-label' + .controls + = f.text_field :price, class: 'text_field' + .control-group class=(@product.errors[:product_category_id].any? ? 'error' : nil) + = f.label :product_category_id, ProductCategory.model_name.human, class: 'control-label' + .controls + = f.select :product_category_id, options_for_select(@product_categories.map{|a| [a.name, a.id]}), include_blank: '' + .control-group class=(@product.errors[:supplier_id].any? ? 'error' : nil) + = f.label :supplier_id, Supplier.model_name.human, class: 'control-label' + .controls + = f.select :supplier_id, options_for_select(@suppliers.map{|a| [a.name, a.id]}), include_blank: nil + .form-actions + = f.submit nil, class: 'btn btn-primary' + ' + = link_to t("helpers.links.cancel"), products_path, class: 'btn' diff --git a/app/views/products/edit.html.slim b/app/views/products/edit.html.slim new file mode 100644 index 00000000..509b074f --- /dev/null +++ b/app/views/products/edit.html.slim @@ -0,0 +1,4 @@ +- model_class = Product +.page-header + = title :edit, model_class += render 'form' diff --git a/app/views/products/index.html.slim b/app/views/products/index.html.slim new file mode 100644 index 00000000..5bd89ce4 --- /dev/null +++ b/app/views/products/index.html.slim @@ -0,0 +1,30 @@ +- model_class = Product +div.page-header= title :index, model_class +- if @products.any? + table.table.table-striped + thead + tr + th= model_class.human_attribute_name(:name) + th= model_class.human_attribute_name(:code) + th= model_class.human_attribute_name(:price) + th= ProductCategory.model_name.human + th= Supplier.model_name.human + th= model_class.human_attribute_name(:created_at) + th=t 'helpers.actions' + tbody + - @products.each do |product| + tr + td= link_to product.name, product + td= product.code + td= product.price + td= link_to product.product_category.name, product.product_category + td= link_to product.supplier.name, product.supplier + td=l product.created_at, format: :short + td + = link_to t('helpers.links.edit'), [:edit, product], class: 'btn btn-mini' + ' + = link_to t("helpers.links.destroy"), product, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger' +- else + = no_content_given model_class += link_to t("helpers.links.new"), new_product_path, class: 'btn btn-primary' + diff --git a/app/views/products/new.html.slim b/app/views/products/new.html.slim new file mode 100644 index 00000000..80f6e521 --- /dev/null +++ b/app/views/products/new.html.slim @@ -0,0 +1,4 @@ +- model_class = Product +.page-header + = title :new, model_class += render 'form' diff --git a/app/views/products/show.html.slim b/app/views/products/show.html.slim new file mode 100644 index 00000000..f6e9cdc0 --- /dev/null +++ b/app/views/products/show.html.slim @@ -0,0 +1,23 @@ +- model_class = Product +.page-header= title :show, @product + +dl.dl-horizontal.show-list + dt= model_class.human_attribute_name(:name) + dd= @product.name + dt= model_class.human_attribute_name(:code) + dd= @product.code + dt= model_class.human_attribute_name(:price) + dd= @product.price + - if @product.product_category.present? + dt= ProductCategory.model_name.human + dd= link_to @product.product_category.name, @product.product_category + - if @product.supplier.present? + dt= Supplier.model_name.human + dd= link_to @product.supplier.name, @product.supplier + +.form-actions + = link_to t("helpers.links.back"), products_path, class: 'btn' + ' + = link_to t('helpers.links.edit'), [:edit, @product], class: 'btn' + ' + = link_to t("helpers.links.destroy"), @product, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger' diff --git a/app/views/suppliers/_form.html.slim b/app/views/suppliers/_form.html.slim new file mode 100644 index 00000000..f88d3eb8 --- /dev/null +++ b/app/views/suppliers/_form.html.slim @@ -0,0 +1,10 @@ += form_for @supplier, html: {class: 'form-horizontal' } do |f| + = render 'error_messages', target: @supplier + .control-group class=(@supplier.errors[:name].any? ? 'error' : nil) + = f.label :name, class: 'control-label' + .controls + = f.text_field :name, class: 'text_field' + .form-actions + = f.submit nil, class: 'btn btn-primary' + ' + = link_to t("helpers.links.cancel"), suppliers_path, class: 'btn' diff --git a/app/views/suppliers/edit.html.slim b/app/views/suppliers/edit.html.slim new file mode 100644 index 00000000..1a9547f5 --- /dev/null +++ b/app/views/suppliers/edit.html.slim @@ -0,0 +1,4 @@ +- model_class = Supplier +.page-header + = title :edit, model_class += render 'form' diff --git a/app/views/suppliers/index.html.slim b/app/views/suppliers/index.html.slim new file mode 100644 index 00000000..3d554fd0 --- /dev/null +++ b/app/views/suppliers/index.html.slim @@ -0,0 +1,22 @@ +- model_class = Supplier +div.page-header= title :index, model_class +- if @suppliers.any? + table.table.table-striped + thead + tr + th= model_class.human_attribute_name(:name) + th= model_class.human_attribute_name(:created_at) + th=t 'helpers.actions' + tbody + - @suppliers.each do |supplier| + tr + td= link_to supplier.name, supplier + td=l supplier.created_at, format: :short + td + = link_to t('helpers.links.edit'), [:edit, supplier], class: 'btn btn-mini' + ' + = link_to t("helpers.links.destroy"), supplier, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger' +- else + = no_content_given model_class += link_to t("helpers.links.new"), new_supplier_path, class: 'btn btn-primary' + diff --git a/app/views/suppliers/new.html.slim b/app/views/suppliers/new.html.slim new file mode 100644 index 00000000..e7dec9da --- /dev/null +++ b/app/views/suppliers/new.html.slim @@ -0,0 +1,4 @@ +- model_class = Supplier +.page-header + = title :new, model_class += render 'form' diff --git a/app/views/suppliers/show.html.slim b/app/views/suppliers/show.html.slim new file mode 100644 index 00000000..ba29b60f --- /dev/null +++ b/app/views/suppliers/show.html.slim @@ -0,0 +1,14 @@ +- model_class = Supplier +.page-header + = title :show, @supplier + +dl.dl-horizontal.show-list + dt= model_class.human_attribute_name(:name) + ':' + dd= @supplier.name + +.form-actions + = link_to t("helpers.links.back"), suppliers_path, class: 'btn' + ' + = link_to t('helpers.links.edit'), [:edit, @supplier], class: 'btn' + ' + = link_to t("helpers.links.destroy"), @supplier, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger' diff --git a/app/views/tables/_form.html.slim b/app/views/tables/_form.html.slim new file mode 100644 index 00000000..c3d0176e --- /dev/null +++ b/app/views/tables/_form.html.slim @@ -0,0 +1,14 @@ += form_for @table, html: {class: 'form-horizontal' } do |f| + = render 'error_messages', target: @table + .control-group class=(@table.errors[:number].any? ? 'error' : nil) + = f.label :number, class: 'control-label' + .controls + = f.text_field :number, class: 'text_field' + .control-group class=(@table.errors[:supplier_id].any? ? 'error' : nil) + = f.label :supplier_id, Supplier.model_name.human, class: 'control-label' + .controls + = f.select :supplier_id, options_for_select(@suppliers.map{|a| [a.name, a.id]}), include_blank: nil + .form-actions + = f.submit nil, class: 'btn btn-primary' + ' + = link_to t("helpers.links.cancel"), tables_path, class: 'btn' diff --git a/app/views/tables/edit.html.slim b/app/views/tables/edit.html.slim new file mode 100644 index 00000000..0f403e2a --- /dev/null +++ b/app/views/tables/edit.html.slim @@ -0,0 +1,4 @@ +- model_class = Table +.page-header + = title :edit, model_class += render 'form' diff --git a/app/views/tables/index.html.slim b/app/views/tables/index.html.slim new file mode 100644 index 00000000..b383a60f --- /dev/null +++ b/app/views/tables/index.html.slim @@ -0,0 +1,24 @@ +- model_class = Table +div.page-header= title :index, model_class +- if @tables.any? + table.table.table-striped + thead + tr + th= model_class.human_attribute_name(:number) + th= Supplier.model_name.human + th= model_class.human_attribute_name(:created_at) + th=t 'helpers.actions' + tbody + - @tables.each do |table| + tr + td= link_to table.number, table + td= link_to table.supplier.name, table.supplier + td=l table.created_at, format: :short + td + = link_to t('helpers.links.edit'), [:edit, table], class: 'btn btn-mini' + ' + = link_to t("helpers.links.destroy"), table, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger' +- else + = no_content_given model_class += link_to t("helpers.links.new"), new_table_path, class: 'btn btn-primary' + diff --git a/app/views/tables/new.html.slim b/app/views/tables/new.html.slim new file mode 100644 index 00000000..e30c254c --- /dev/null +++ b/app/views/tables/new.html.slim @@ -0,0 +1,4 @@ +- model_class = Table +.page-header + = title :new, model_class += render 'form' diff --git a/app/views/tables/show.html.slim b/app/views/tables/show.html.slim new file mode 100644 index 00000000..67a65ee5 --- /dev/null +++ b/app/views/tables/show.html.slim @@ -0,0 +1,16 @@ +- model_class = Table +.page-header= title :show, @table + +dl.dl-horizontal.show-list + dt= model_class.human_attribute_name(:number) + dd= @table.number + - if @table.supplier.present? + dt= Supplier.model_name.human + dd= link_to @table.supplier.name, @table.supplier + +.form-actions + = link_to t("helpers.links.back"), tables_path, class: 'btn' + ' + = link_to t('helpers.links.edit'), [:edit, @table], class: 'btn' + ' + = link_to t("helpers.links.destroy"), @table, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger' diff --git a/app/views/users/_form.html.slim b/app/views/users/_form.html.slim new file mode 100644 index 00000000..2aa2049c --- /dev/null +++ b/app/views/users/_form.html.slim @@ -0,0 +1,45 @@ += form_for @user, html: {class: 'form-horizontal' } do |f| + .control-group + = f.label :email, class: 'control-label' + .controls + = f.text_field :email, class: 'text_field' + .control-group + = f.label :encrypted_password, class: 'control-label' + .controls + = f.text_field :encrypted_password, class: 'text_field' + .control-group + = f.label :remember_token, class: 'control-label' + .controls + = f.text_field :remember_token, class: 'text_field' + .control-group + = f.label :remember_created_at, class: 'control-label' + .controls + = f.text_field :remember_created_at, class: 'text_field' + .control-group + = f.label :reset_password_token, class: 'control-label' + .controls + = f.text_field :reset_password_token, class: 'text_field' + .control-group + = f.label :sign_in_count, class: 'control-label' + .controls + = f.text_field :sign_in_count, class: 'text_field' + .control-group + = f.label :current_sign_in_at, class: 'control-label' + .controls + = f.text_field :current_sign_in_at, class: 'text_field' + .control-group + = f.label :last_sign_in_at, class: 'control-label' + .controls + = f.text_field :last_sign_in_at, class: 'text_field' + .control-group + = f.label :current_sign_in_ip, class: 'control-label' + .controls + = f.text_field :current_sign_in_ip, class: 'text_field' + .control-group + = f.label :last_sign_in_ip, class: 'control-label' + .controls + = f.text_field :last_sign_in_ip, class: 'text_field' + .form-actions + = f.submit nil, class: 'btn btn-primary' + ' + = link_to t("helpers.links.cancel"), users_path, class: 'btn' diff --git a/app/views/users/edit.html.slim b/app/views/users/edit.html.slim new file mode 100644 index 00000000..9c1d090e --- /dev/null +++ b/app/views/users/edit.html.slim @@ -0,0 +1,4 @@ +- model_class = User +.page-header + = title :edit, model_class += render 'form' diff --git a/app/views/users/index.html.slim b/app/views/users/index.html.slim new file mode 100644 index 00000000..c0e37557 --- /dev/null +++ b/app/views/users/index.html.slim @@ -0,0 +1,38 @@ +- model_class = User +div class="page-header"= title :index, model_class +table class="table table-striped" + thead + tr + th= model_class.human_attribute_name(:email) + th= model_class.human_attribute_name(:encrypted_password) + th= model_class.human_attribute_name(:remember_token) + th= model_class.human_attribute_name(:remember_created_at) + th= model_class.human_attribute_name(:reset_password_token) + th= model_class.human_attribute_name(:sign_in_count) + th= model_class.human_attribute_name(:current_sign_in_at) + th= model_class.human_attribute_name(:last_sign_in_at) + th= model_class.human_attribute_name(:current_sign_in_ip) + th= model_class.human_attribute_name(:last_sign_in_ip) + th= model_class.human_attribute_name(:created_at) + th=t 'helpers.actions' + tbody + - @users.each do |user| + tr + td= link_to user.email, user + td= user.encrypted_password + td= user.remember_token + td= user.remember_created_at + td= user.reset_password_token + td= user.sign_in_count + td= user.current_sign_in_at + td= user.last_sign_in_at + td= user.current_sign_in_ip + td= user.last_sign_in_ip + td=l user.created_at, format: :short + td + = link_to t('helpers.links.edit'), [:edit, user], class: 'btn btn-mini' + ' + = link_to t("helpers.links.destroy"), user, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger' + += link_to t("helpers.links.new"), new_user_path, class: 'btn btn-primary' + diff --git a/app/views/users/new.html.slim b/app/views/users/new.html.slim new file mode 100644 index 00000000..988d6a86 --- /dev/null +++ b/app/views/users/new.html.slim @@ -0,0 +1,4 @@ +- model_class = User +.page-header + = title :new, model_class += render 'form' diff --git a/app/views/users/show.html.slim b/app/views/users/show.html.slim new file mode 100644 index 00000000..c81d71eb --- /dev/null +++ b/app/views/users/show.html.slim @@ -0,0 +1,32 @@ +- model_class = User +.page-header + = title :show, @user + +dl.dl-horizontal.show-list + dt= model_class.human_attribute_name(:email) + ':' + dd= @user.email + dt= model_class.human_attribute_name(:encrypted_password) + ':' + dd= @user.encrypted_password + dt= model_class.human_attribute_name(:remember_token) + ':' + dd= @user.remember_token + dt= model_class.human_attribute_name(:remember_created_at) + ':' + dd= @user.remember_created_at + dt= model_class.human_attribute_name(:reset_password_token) + ':' + dd= @user.reset_password_token + dt= model_class.human_attribute_name(:sign_in_count) + ':' + dd= @user.sign_in_count + dt= model_class.human_attribute_name(:current_sign_in_at) + ':' + dd= @user.current_sign_in_at + dt= model_class.human_attribute_name(:last_sign_in_at) + ':' + dd= @user.last_sign_in_at + dt= model_class.human_attribute_name(:current_sign_in_ip) + ':' + dd= @user.current_sign_in_ip + dt= model_class.human_attribute_name(:last_sign_in_ip) + ':' + dd= @user.last_sign_in_ip + +.form-actions + = link_to t("helpers.links.back"), users_path, class: 'btn' + ' + = link_to t('helpers.links.edit'), [:edit, @user], class: 'btn' + ' + = link_to t("helpers.links.destroy"), @user, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger' diff --git a/config.ru b/config.ru new file mode 100644 index 00000000..24e1b14d --- /dev/null +++ b/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Qrammer::Application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 00000000..8be5c44a --- /dev/null +++ b/config/application.rb @@ -0,0 +1,79 @@ +require File.expand_path('../boot', __FILE__) + +#require 'rails/all' +require 'rails' +#require 'active_record/railtie' +require 'action_controller/railtie' +require 'action_mailer/railtie' +require 'active_resource/railtie' +require 'rails/test_unit/railtie' +require 'sprockets/railtie' + +if defined?(Bundler) + # If you precompile assets before deploying to production, use this line + Bundler.require(*Rails.groups(:assets => %w(development test))) + # If you want your assets lazily compiled in production, use this line + # Bundler.require(:default, :assets, Rails.env) +end + +module Qrammer + class Application < Rails::Application + # Settings in config/environments/* take precedence over those specified here. + # Application configuration should go into files in config/initializers + # -- all .rb files in that directory are automatically loaded. + + # Custom directories with classes and modules you want to be autoloadable. + # config.autoload_paths += %W(#{config.root}/extras) + + # Only load the plugins named here, in the order given (default is alphabetical). + # :all can be used as a placeholder for all plugins not explicitly named. + # config.plugins = [ :exception_notification, :ssl_requirement, :all ] + + # Activate observers that should always be running. + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer + + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. + # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + + # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. + # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] + # config.i18n.default_locale = :de + + # Configure the default encoding used in templates for Ruby 1.9. + config.encoding = "utf-8" + + # Configure sensitive parameters which will be filtered from the log file. + config.filter_parameters += [:password] + + # Enable escaping HTML in JSON. + config.active_support.escape_html_entities_in_json = true + + config.generators do |g| + g.orm :simply_stored + g.template_engine :slim + g.test_framework :rspec + end + + # Use SQL instead of Active Record's schema dumper when creating the database. + # This is necessary if your schema can't be completely dumped by the schema dumper, + # like if you have constraints or database-specific column types + # config.active_record.schema_format = :sql + + config.action_view.field_error_proc = Proc.new do |html_tag, instance| + "#{html_tag}".html_safe + end + + # Enforce whitelist mode for mass assignment. + # This will create an empty whitelist of attributes available for mass-assignment for all models + # in your app. As such, your models will need to explicitly whitelist or blacklist accessible + # parameters by using an attr_accessible or attr_protected declaration. + # config.active_record.whitelist_attributes = true + + # Enable the asset pipeline + config.assets.enabled = true + + # Version of your assets, change this if you want to expire all your assets + config.assets.version = '1.0' + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 00000000..4489e586 --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,6 @@ +require 'rubygems' + +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) diff --git a/config/couchdb.yml b/config/couchdb.yml new file mode 100644 index 00000000..413d31be --- /dev/null +++ b/config/couchdb.yml @@ -0,0 +1,9 @@ +development: + validation_framework: :active_model #optional + database: qrammer_development +test: + validation_framework: :active_model #optional + database: qrammer_test +production: + validation_framework: :active_model #optional + database: qrammer diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 00000000..51a4dd45 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,25 @@ +# SQLite version 3.x +# gem install sqlite3 +# +# Ensure the SQLite 3 gem is defined in your Gemfile +# gem 'sqlite3' +development: + adapter: sqlite3 + database: db/development.sqlite3 + pool: 5 + timeout: 5000 + +# Warning: The database defined as "test" will be erased and +# re-generated from your development database when you run "rake". +# Do not set this db to the same as development or production. +test: + adapter: sqlite3 + database: db/test.sqlite3 + pool: 5 + timeout: 5000 + +production: + adapter: sqlite3 + database: db/production.sqlite3 + pool: 5 + timeout: 5000 diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 00000000..441ca86e --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the rails application +require File.expand_path('../application', __FILE__) + +# Initialize the rails application +Qrammer::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 00000000..02d7998c --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,37 @@ +Qrammer::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # In the development environment your application's code is reloaded on + # every request. This slows down response time but is perfect for development + # since you don't have to restart the web server when you make code changes. + config.cache_classes = false + + # Log error messages when you accidentally call methods on nil. + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Don't care if the mailer can't send + config.action_mailer.raise_delivery_errors = false + + # Print deprecation notices to the Rails logger + config.active_support.deprecation = :log + + # Only use best-standards-support built into browsers + config.action_dispatch.best_standards_support = :builtin + + # Raise exception on mass assignment protection for Active Record models + # config.active_record.mass_assignment_sanitizer = :strict + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 + + # Do not compress assets + config.assets.compress = false + + # Expands the lines which load the assets + config.assets.debug = true +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 00000000..9f95c286 --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,67 @@ +Qrammer::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # Code is not reloaded between requests + config.cache_classes = true + + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Disable Rails's static asset server (Apache or nginx will already do this) + config.serve_static_assets = false + + # Compress JavaScripts and CSS + config.assets.compress = true + + # Don't fallback to assets pipeline if a precompiled asset is missed + config.assets.compile = false + + # Generate digests for assets URLs + config.assets.digest = true + + # Defaults to nil and saved in location specified by config.assets.prefix + # config.assets.manifest = YOUR_PATH + + # Specifies the header that your server uses for sending files + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # See everything in the log (default is :info) + # config.log_level = :debug + + # Prepend all log lines with the following tags + # config.log_tags = [ :subdomain, :uuid ] + + # Use a different logger for distributed setups + # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + + # Use a different cache store in production + # config.cache_store = :mem_cache_store + + # Enable serving of images, stylesheets, and JavaScripts from an asset server + # config.action_controller.asset_host = "http://assets.example.com" + + # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) + # config.assets.precompile += %w( search.js ) + + # Disable delivery errors, bad email addresses will be ignored + # config.action_mailer.raise_delivery_errors = false + + # Enable threaded mode + # config.threadsafe! + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners + config.active_support.deprecation = :notify + + # Log the query plan for queries taking more than this (works + # with SQLite, MySQL, and PostgreSQL) + # config.active_record.auto_explain_threshold_in_seconds = 0.5 +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 00000000..b77e0240 --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,37 @@ +Qrammer::Application.configure do + # Settings specified here will take precedence over those in config/application.rb + + # The test environment is used exclusively to run your application's + # test suite. You never need to work with it otherwise. Remember that + # your test database is "scratch space" for the test suite and is wiped + # and recreated between test runs. Don't rely on the data there! + config.cache_classes = true + + # Configure static asset server for tests with Cache-Control for performance + config.serve_static_assets = true + config.static_cache_control = "public, max-age=3600" + + # Log error messages when you accidentally call methods on nil + config.whiny_nils = true + + # Show full error reports and disable caching + config.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates + config.action_dispatch.show_exceptions = false + + # Disable request forgery protection in test environment + config.action_controller.allow_forgery_protection = false + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Raise exception on mass assignment protection for Active Record models + # config.active_record.mass_assignment_sanitizer = :strict + + # Print deprecation notices to the stderr + config.active_support.deprecation = :stderr +end diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb new file mode 100644 index 00000000..59385cdf --- /dev/null +++ b/config/initializers/backtrace_silencers.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. +# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } + +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. +# Rails.backtrace_cleaner.remove_silencers! diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 00000000..5d8d9be2 --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,15 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format +# (all these examples are active by default): +# ActiveSupport::Inflector.inflections do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end +# +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections do |inflect| +# inflect.acronym 'RESTful' +# end diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb new file mode 100644 index 00000000..72aca7e4 --- /dev/null +++ b/config/initializers/mime_types.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf +# Mime::Type.register_alias "text/html", :iphone diff --git a/config/initializers/model_human_plural.rb b/config/initializers/model_human_plural.rb new file mode 100644 index 00000000..9ae2309d --- /dev/null +++ b/config/initializers/model_human_plural.rb @@ -0,0 +1,7 @@ +module ActiveModel + class Name + def human_plural + I18n.t("activemodel.models.plural.#{underscore.gsub('/', '.')}", :default => nil ) || human.pluralize + end + end +end diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb new file mode 100644 index 00000000..cebe047e --- /dev/null +++ b/config/initializers/secret_token.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# Your secret key for verifying the integrity of signed cookies. +# If you change this key, all old signed cookies will become invalid! +# Make sure the secret is at least 30 characters and all random, +# no regular words or you'll be exposed to dictionary attacks. +Qrammer::Application.config.secret_token = 'a2d0002614aa5e1a04dd5f57c3a239765ee47df0f5e3214adf41c4893b84a95cd805f650f5edb321f2474adf6bb01a625b911d34a3c879815281d7e1db4415c8' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb new file mode 100644 index 00000000..63454c3b --- /dev/null +++ b/config/initializers/session_store.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +Qrammer::Application.config.session_store :cookie_store, key: '_qrammer_session' + +# Use the database for sessions instead of the cookie-based default, +# which shouldn't be used to store highly confidential information +# (create the session table with "rails generate session_migration") +# Qrammer::Application.config.session_store :active_record_store diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb new file mode 100644 index 00000000..999df201 --- /dev/null +++ b/config/initializers/wrap_parameters.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. +# +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters format: [:json] +end + +# Disable root element in JSON by default. +ActiveSupport.on_load(:active_record) do + self.include_root_in_json = false +end diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 00000000..4db28813 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,41 @@ +# Sample localization file for English. Add more files in this directory for other locales. +# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. + +en: + hello: "Hello world" + helpers: + links: + are_you_sure: 'Are you sure?' + forms: + errors: + title: There are problems found during saving (%{count}) + action: + index: + label: Listing %{models} + new: + label: New %{model} + show: + label: Showing %{model} + create: + successfull: '%{model} is successfully created' + update: + successfull: '%{model} is successfully updated' + destroy: + successfull: '%{model} is successfully destroyed' + table: + is_occupied: This table is occupied + activemodel: + models: + user: User + supplier: Restaurant + table: Table + list: List + product: Product + product_category: Product category + plural: + user: Users + supplier: Restaurants + table: Tables + list: Lists + product: Products + product_category: Product categories diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 00000000..37f14237 --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,75 @@ +Qrammer::Application.routes.draw do + resources :users + resources :tables do + member do + get :qrcode + end + end + resources :suppliers do + member do + get :product_list + end + end + resources :lists + resources :products + resources :product_categories + + match "/:action", controller: 'dashboard' + + # The priority is based upon order of creation: + # first created -> highest priority. + + # Sample of regular route: + # match 'products/:id' => 'catalog#view' + # Keep in mind you can assign values other than :controller and :action + + # Sample of named route: + # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase + # This route can be invoked with purchase_url(:id => product.id) + + # Sample resource route (maps HTTP verbs to controller actions automatically): + # resources :products + + # Sample resource route with options: + # resources :products do + # member do + # get 'short' + # post 'toggle' + # end + # + # collection do + # get 'sold' + # end + # end + + # Sample resource route with sub-resources: + # resources :products do + # resources :comments, :sales + # resource :seller + # end + + # Sample resource route with more complex sub-resources + # resources :products do + # resources :comments + # resources :sales do + # get 'recent', :on => :collection + # end + # end + + # Sample resource route within a namespace: + # namespace :admin do + # # Directs /admin/products/* to Admin::ProductsController + # # (app/controllers/admin/products_controller.rb) + # resources :products + # end + + # You can have the root of your site routed with "root" + # just remember to delete public/index.html. + root :to => 'dashboard#home' + + # See how all your routes lay out with "rake routes" + + # This is a legacy wild controller route that's not recommended for RESTful applications. + # Note: This route will make all actions in every controller accessible via GET requests. + # match ':controller(/:action(/:id))(.:format)' +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 00000000..4edb1e85 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,7 @@ +# This file should contain all the record creation needed to seed the database with its default values. +# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). +# +# Examples: +# +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) +# Mayor.create(name: 'Emanuel', city: cities.first) diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP new file mode 100644 index 00000000..fe41f5cc --- /dev/null +++ b/doc/README_FOR_APP @@ -0,0 +1,2 @@ +Use this README file to introduce your application and point to useful places in the API for learning more. +Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries. diff --git a/lib/assets/.gitkeep b/lib/assets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/lib/generators/bootstrap/themed/templates/_form.html.slim b/lib/generators/bootstrap/themed/templates/_form.html.slim new file mode 100644 index 00000000..a4b44bc3 --- /dev/null +++ b/lib/generators/bootstrap/themed/templates/_form.html.slim @@ -0,0 +1,18 @@ += form_for @<%= resource_name %>, html: {class: 'form-horizontal' } do |f| + = render 'error_messages', target: @<%= resource_name %> + <%- columns.each do |column| -%> + .control-group class=(@<%= resource_name %>.errors[:<%= column.name %>].any? ? 'error' : nil) + = f.label :<%= column.name %>, class: 'control-label' + .controls + = f.<%= column.field_type %> :<%= column.name %>, class: '<%= column.field_type %>' + <%- end -%> + <%- belongs_to_associations.each do |association| -%> + .control-group class=(@<%= resource_name %>.errors[:<%= association.name %>_id].any? ? 'error' : nil) + = f.label :<%= association.name %>_id, <%= association.options[:class_name] %>.model_name.human, class: 'control-label' + .controls + = f.select :<%= association.name %>_id, options_for_select(@<%= association.name.to_s.pluralize %>.map{|a| [a.<%= association.name_property%>, a.id]}), include_blank: <%= model_name.constantize.validators_on(:"#{association.name}_id").any? ? 'nil' : "''" %> + <%- end -%> + .form-actions + = f.submit nil, class: 'btn btn-primary' + ' + = link_to t("helpers.links.cancel"), <%= controller_routing_path %>_path, class: 'btn' diff --git a/lib/generators/bootstrap/themed/templates/edit.html.slim b/lib/generators/bootstrap/themed/templates/edit.html.slim new file mode 100644 index 00000000..18e9756e --- /dev/null +++ b/lib/generators/bootstrap/themed/templates/edit.html.slim @@ -0,0 +1,4 @@ +- model_class = <%= resource_name.classify %> +.page-header + = title :edit, model_class += render 'form' diff --git a/lib/generators/bootstrap/themed/templates/index.html.slim b/lib/generators/bootstrap/themed/templates/index.html.slim new file mode 100644 index 00000000..f6f4185e --- /dev/null +++ b/lib/generators/bootstrap/themed/templates/index.html.slim @@ -0,0 +1,35 @@ +- model_class = <%= resource_name.classify %> +div.page-header= title :index, model_class +- if @<%= plural_resource_name %>.any? + table.table.table-striped + thead + tr + <%- columns.each do |column| -%> + th= model_class.human_attribute_name(:<%= column.name %>) + <%- end -%> + <%- belongs_to_associations.each do |association| -%> + th= <%= association.options[:class_name] %>.model_name.human + <%- end -%> + th= model_class.human_attribute_name(:created_at) + th=t 'helpers.actions' + tbody + - @<%= plural_resource_name %>.each do |<%= resource_name %>| + tr + <%- columns.each.with_index do |column, index| -%> + <%- if index.zero? -%> + td= link_to <%= resource_name %>.<%= column.name %>, <%= resource_name %> + <%- else -%> + td= <%= resource_name %>.<%= column.name %> + <%- end end -%> + <%- belongs_to_associations.each do |association| -%> + td= link_to <%= resource_name %>.<%= association.name %>.<%= association.name_property %>, <%= resource_name %>.<%= association.name %> + <%- end -%> + td=l <%= resource_name %>.created_at, format: :short + td + = link_to t('helpers.links.edit'), [:edit, <%= resource_name %>], class: 'btn btn-mini' + ' + = link_to t("helpers.links.destroy"), <%= resource_name %>, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-mini btn-danger' +- else + = no_content_given model_class += link_to t("helpers.links.new"), new_<%= singular_controller_routing_path %>_path, class: 'btn btn-primary' + diff --git a/lib/generators/bootstrap/themed/templates/new.html.slim b/lib/generators/bootstrap/themed/templates/new.html.slim new file mode 100644 index 00000000..9cc144ca --- /dev/null +++ b/lib/generators/bootstrap/themed/templates/new.html.slim @@ -0,0 +1,4 @@ +- model_class = <%= resource_name.classify %> +.page-header + = title :new, model_class += render 'form' diff --git a/lib/generators/bootstrap/themed/templates/show.html.slim b/lib/generators/bootstrap/themed/templates/show.html.slim new file mode 100644 index 00000000..f89bf81c --- /dev/null +++ b/lib/generators/bootstrap/themed/templates/show.html.slim @@ -0,0 +1,20 @@ +- model_class = <%= resource_name.classify %> +.page-header= title :show, @<%= resource_name %> + +dl.dl-horizontal.show-list +<%- columns.each do |column| -%> + dt= model_class.human_attribute_name(:<%= column.name %>) + dd= @<%= resource_name %>.<%= column.name %> +<%- end -%> +<%- belongs_to_associations.each do |association| -%> + - if @<%= resource_name %>.<%= association.name %>.present? + dt= <%= association.options[:class_name] %>.model_name.human + dd= link_to @<%= resource_name %>.<%= association.name %>.<%= association.name_property %>, @<%= resource_name %>.<%= association.name %> +<%- end -%> + +.form-actions + = link_to t("helpers.links.back"), <%= controller_routing_path %>_path, class: 'btn' + ' + = link_to t('helpers.links.edit'), [:edit, @<%= resource_name %>], class: 'btn' + ' + = link_to t("helpers.links.destroy"), @<%= resource_name %>, method: :delete, data: {confirm: are_you_sure? }, class: 'btn btn-danger' diff --git a/lib/generators/bootstrap/themed/themed_generator.rb b/lib/generators/bootstrap/themed/themed_generator.rb new file mode 100644 index 00000000..135c462f --- /dev/null +++ b/lib/generators/bootstrap/themed/themed_generator.rb @@ -0,0 +1,119 @@ +require 'rails/generators' +require 'rails/generators/generated_attribute' + +module Bootstrap + module Generators + class ThemedGenerator < ::Rails::Generators::Base + NAME_COLUMNS = %w[name title number].map(&:to_sym) + source_root File.expand_path('../templates', __FILE__) + argument :controller_path, :type => :string + argument :model_name, :type => :string, :required => false + argument :layout, :type => :string, :default => "application", + :banner => "Specify application layout" + + def initialize(args, *options) + super(args, *options) + initialize_views_variables + end + + def copy_views + generate_views + end + + protected + + def initialize_views_variables + @base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path) + @controller_routing_path = @controller_file_path.gsub(/\//, '_') + @model_name = @controller_class_nesting + "::#{@base_name.singularize.camelize}" unless @model_name + @model_name = @model_name.camelize + end + + def controller_routing_path + @controller_routing_path + end + + def singular_controller_routing_path + @controller_routing_path.singularize + end + + def model_name + @model_name + end + + def plural_model_name + @model_name.pluralize + end + + def resource_name + @model_name.demodulize.underscore + end + + def plural_resource_name + resource_name.pluralize + end + + def name_columns + NAME_COLUMNS + end + + def columns + begin + excluded_column_names = %w[id created_at updated_at] + @model_name.constantize.columns.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type)} + rescue NoMethodError + begin + @model_name.constantize.fields.collect{|c| c[1]}.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type.to_s)} + rescue NoMethodError + # SimplyStored/CouchPotato + @model_name.constantize.properties.reject{|p| !(p.is_a?(CouchPotato::Persistence::SimpleProperty)) || p.name =~ /_ids?$/ || excluded_column_names.include?(p.name.to_s) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type.to_s)} + end + end + end + + def belongs_to_associations + #@model_name.constantize.properties.select{|p| p.is_a?(SimplyStored::Couch::BelongsTo::Property)} + associations= @model_name.constantize.properties.select{|p| p.is_a?(SimplyStored::Couch::BelongsTo::Property) && (p.options[:class_name].constantize.property_names & name_columns).any?} + for association in associations + def association.name_property + (options[:class_name].constantize.property_names & Bootstrap::Generators::ThemedGenerator::NAME_COLUMNS).first || :name + end + end + end + + def extract_modules(name) + modules = name.include?('/') ? name.split('/') : name.split('::') + name = modules.pop + path = modules.map { |m| m.underscore } + file_path = (path + [name.underscore]).join('/') + nesting = modules.map { |m| m.camelize }.join('::') + [name, path, file_path, nesting, modules.size] + end + + def generate_views + views = { + "index.html.#{ext}" => File.join('app/views', @controller_file_path, "index.html.#{ext}"), + "new.html.#{ext}" => File.join('app/views', @controller_file_path, "new.html.#{ext}"), + "edit.html.#{ext}" => File.join('app/views', @controller_file_path, "edit.html.#{ext}"), + "#{form_builder}_form.html.#{ext}" => File.join('app/views', @controller_file_path, "_form.html.#{ext}"), + "show.html.#{ext}" => File.join('app/views', @controller_file_path, "show.html.#{ext}")} + selected_views = views + options.engine == generate_erb(selected_views) + end + + def generate_erb(views) + views.each do |template_name, output_path| + template template_name, output_path + end + end + + def ext + ::Rails.application.config.generators.options[:rails][:template_engine] || :erb + end + + def form_builder + defined?(::SimpleForm) ? 'simple_form/' : '' + end + end + end +end diff --git a/lib/tasks/.gitkeep b/lib/tasks/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/log/.gitkeep b/log/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/public/404.html b/public/404.html new file mode 100644 index 00000000..9a48320a --- /dev/null +++ b/public/404.html @@ -0,0 +1,26 @@ + + + + The page you were looking for doesn't exist (404) + + + + + +
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+ + diff --git a/public/422.html b/public/422.html new file mode 100644 index 00000000..83660ab1 --- /dev/null +++ b/public/422.html @@ -0,0 +1,26 @@ + + + + The change you wanted was rejected (422) + + + + + +
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+ + diff --git a/public/500.html b/public/500.html new file mode 100644 index 00000000..f3648a0d --- /dev/null +++ b/public/500.html @@ -0,0 +1,25 @@ + + + + We're sorry, but something went wrong (500) + + + + + +
+

We're sorry, but something went wrong.

+
+ + diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 00000000..e69de29b diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 00000000..085187fa --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,5 @@ +# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file +# +# To ban all spiders from the entire site uncomment the next two lines: +# User-Agent: * +# Disallow: / diff --git a/script/rails b/script/rails new file mode 100755 index 00000000..f8da2cff --- /dev/null +++ b/script/rails @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. + +APP_PATH = File.expand_path('../../config/application', __FILE__) +require File.expand_path('../../config/boot', __FILE__) +require 'rails/commands' diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb new file mode 100644 index 00000000..52ff0eb2 --- /dev/null +++ b/spec/controllers/users_controller_spec.rb @@ -0,0 +1,164 @@ +require 'spec_helper' + +# This spec was generated by rspec-rails when you ran the scaffold generator. +# It demonstrates how one might use RSpec to specify the controller code that +# was generated by Rails when you ran the scaffold generator. +# +# It assumes that the implementation code is generated by the rails scaffold +# generator. If you are using any extension libraries to generate different +# controller code, this generated spec may or may not pass. +# +# It only uses APIs available in rails and/or rspec-rails. There are a number +# of tools you can use to make these specs even more expressive, but we're +# sticking to rails and rspec-rails APIs to keep things simple and stable. +# +# Compared to earlier versions of this generator, there is very limited use of +# stubs and message expectations in this spec. Stubs are only used when there +# is no simpler way to get a handle on the object needed for the example. +# Message expectations are only used when there is no simpler way to specify +# that an instance is receiving a specific message. + +describe UsersController do + + # This should return the minimal set of attributes required to create a valid + # User. As you add validations to User, be sure to + # update the return value of this method accordingly. + def valid_attributes + {} + end + + # This should return the minimal set of values that should be in the session + # in order to pass any filters (e.g. authentication) defined in + # UsersController. Be sure to keep this updated too. + def valid_session + {} + end + + describe "GET index" do + it "assigns all users as @users" do + user = User.create! valid_attributes + get :index, {}, valid_session + assigns(:users).should eq([user]) + end + end + + describe "GET show" do + it "assigns the requested user as @user" do + user = User.create! valid_attributes + get :show, {:id => user.to_param}, valid_session + assigns(:user).should eq(user) + end + end + + describe "GET new" do + it "assigns a new user as @user" do + get :new, {}, valid_session + assigns(:user).should be_a_new(User) + end + end + + describe "GET edit" do + it "assigns the requested user as @user" do + user = User.create! valid_attributes + get :edit, {:id => user.to_param}, valid_session + assigns(:user).should eq(user) + end + end + + describe "POST create" do + describe "with valid params" do + it "creates a new User" do + expect { + post :create, {:user => valid_attributes}, valid_session + }.to change(User, :count).by(1) + end + + it "assigns a newly created user as @user" do + post :create, {:user => valid_attributes}, valid_session + assigns(:user).should be_a(User) + assigns(:user).should be_persisted + end + + it "redirects to the created user" do + post :create, {:user => valid_attributes}, valid_session + response.should redirect_to(User.last) + end + end + + describe "with invalid params" do + it "assigns a newly created but unsaved user as @user" do + # Trigger the behavior that occurs when invalid params are submitted + User.any_instance.stub(:save).and_return(false) + post :create, {:user => {}}, valid_session + assigns(:user).should be_a_new(User) + end + + it "re-renders the 'new' template" do + # Trigger the behavior that occurs when invalid params are submitted + User.any_instance.stub(:save).and_return(false) + post :create, {:user => {}}, valid_session + response.should render_template("new") + end + end + end + + describe "PUT update" do + describe "with valid params" do + it "updates the requested user" do + user = User.create! valid_attributes + # Assuming there are no other users in the database, this + # specifies that the User created on the previous line + # receives the :update_attributes message with whatever params are + # submitted in the request. + User.any_instance.should_receive(:update_attributes).with({'these' => 'params'}) + put :update, {:id => user.to_param, :user => {'these' => 'params'}}, valid_session + end + + it "assigns the requested user as @user" do + user = User.create! valid_attributes + put :update, {:id => user.to_param, :user => valid_attributes}, valid_session + assigns(:user).should eq(user) + end + + it "redirects to the user" do + user = User.create! valid_attributes + put :update, {:id => user.to_param, :user => valid_attributes}, valid_session + response.should redirect_to(user) + end + end + + describe "with invalid params" do + it "assigns the user as @user" do + user = User.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + User.any_instance.stub(:save).and_return(false) + put :update, {:id => user.to_param, :user => {}}, valid_session + assigns(:user).should eq(user) + end + + it "re-renders the 'edit' template" do + user = User.create! valid_attributes + # Trigger the behavior that occurs when invalid params are submitted + User.any_instance.stub(:save).and_return(false) + put :update, {:id => user.to_param, :user => {}}, valid_session + response.should render_template("edit") + end + end + end + + describe "DELETE destroy" do + it "destroys the requested user" do + user = User.create! valid_attributes + expect { + delete :destroy, {:id => user.to_param}, valid_session + }.to change(User, :count).by(-1) + end + + it "redirects to the users list" do + user = User.create! valid_attributes + delete :destroy, {:id => user.to_param}, valid_session + response.should redirect_to(users_url) + end + end + +end diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb new file mode 100644 index 00000000..e65fff91 --- /dev/null +++ b/spec/helpers/users_helper_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the UsersHelper. For example: +# +# describe UsersHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# helper.concat_strings("this","that").should == "this that" +# end +# end +# end +describe UsersHelper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/users_spec.rb b/spec/requests/users_spec.rb new file mode 100644 index 00000000..0c7daf4e --- /dev/null +++ b/spec/requests/users_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe "Users" do + describe "GET /users" do + it "works! (now write some real specs)" do + # Run the generator again with the --webrat flag if you want to use webrat methods/matchers + get users_path + response.status.should be(200) + end + end +end diff --git a/spec/routing/users_routing_spec.rb b/spec/routing/users_routing_spec.rb new file mode 100644 index 00000000..69efc3e2 --- /dev/null +++ b/spec/routing/users_routing_spec.rb @@ -0,0 +1,35 @@ +require "spec_helper" + +describe UsersController do + describe "routing" do + + it "routes to #index" do + get("/users").should route_to("users#index") + end + + it "routes to #new" do + get("/users/new").should route_to("users#new") + end + + it "routes to #show" do + get("/users/1").should route_to("users#show", :id => "1") + end + + it "routes to #edit" do + get("/users/1/edit").should route_to("users#edit", :id => "1") + end + + it "routes to #create" do + post("/users").should route_to("users#create") + end + + it "routes to #update" do + put("/users/1").should route_to("users#update", :id => "1") + end + + it "routes to #destroy" do + delete("/users/1").should route_to("users#destroy", :id => "1") + end + + end +end diff --git a/spec/views/users/edit.html.slim_spec.rb b/spec/views/users/edit.html.slim_spec.rb new file mode 100644 index 00000000..a702cf53 --- /dev/null +++ b/spec/views/users/edit.html.slim_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "users/edit" do + before(:each) do + @user = assign(:user, stub_model(User)) + end + + it "renders the edit user form" do + render + + # Run the generator again with the --webrat flag if you want to use webrat matchers + assert_select "form", :action => users_path(@user), :method => "post" do + end + end +end diff --git a/spec/views/users/index.html.slim_spec.rb b/spec/views/users/index.html.slim_spec.rb new file mode 100644 index 00000000..def0c154 --- /dev/null +++ b/spec/views/users/index.html.slim_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "users/index" do + before(:each) do + assign(:users, [ + stub_model(User), + stub_model(User) + ]) + end + + it "renders a list of users" do + render + # Run the generator again with the --webrat flag if you want to use webrat matchers + end +end diff --git a/spec/views/users/new.html.slim_spec.rb b/spec/views/users/new.html.slim_spec.rb new file mode 100644 index 00000000..ba75098d --- /dev/null +++ b/spec/views/users/new.html.slim_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' + +describe "users/new" do + before(:each) do + assign(:user, stub_model(User).as_new_record) + end + + it "renders new user form" do + render + + # Run the generator again with the --webrat flag if you want to use webrat matchers + assert_select "form", :action => users_path, :method => "post" do + end + end +end diff --git a/spec/views/users/show.html.slim_spec.rb b/spec/views/users/show.html.slim_spec.rb new file mode 100644 index 00000000..f6329bb0 --- /dev/null +++ b/spec/views/users/show.html.slim_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe "users/show" do + before(:each) do + @user = assign(:user, stub_model(User)) + end + + it "renders attributes in

" do + render + # Run the generator again with the --webrat flag if you want to use webrat matchers + end +end diff --git a/stories b/stories new file mode 100644 index 00000000..f334df26 --- /dev/null +++ b/stories @@ -0,0 +1,23 @@ +Stories: +- Person moves to different table +- Person tries to create list on occupied table +- Person walks away without paying + +Person actions: + When list is open: + - Move table + - Make order + - Request bill + + When no list is open: + - Open list + - Subscribe to existing list + + General actions + - View history + - Access settings + - I have a question + +Alleen restaurant kan rekening afsluiten, als dit nog niet is gebeurd voor een tafel kan een nieuwe persoon geen lijst openen. Alert melding bij restaurant als iemand dit probeert + +Eén lijst tegelijk actief? (wel handig en duidelijk!!!) diff --git a/test/fixtures/.gitkeep b/test/fixtures/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/test/functional/.gitkeep b/test/functional/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/test/integration/.gitkeep b/test/integration/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/test/performance/browsing_test.rb b/test/performance/browsing_test.rb new file mode 100644 index 00000000..3fea27b9 --- /dev/null +++ b/test/performance/browsing_test.rb @@ -0,0 +1,12 @@ +require 'test_helper' +require 'rails/performance_test_help' + +class BrowsingTest < ActionDispatch::PerformanceTest + # Refer to the documentation for all available options + # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] + # :output => 'tmp/performance', :formats => [:flat] } + + def test_homepage + get '/' + end +end diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 00000000..8bf1192f --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,13 @@ +ENV["RAILS_ENV"] = "test" +require File.expand_path('../../config/environment', __FILE__) +require 'rails/test_help' + +class ActiveSupport::TestCase + # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. + # + # Note: You'll currently still have to declare fixtures explicitly in integration tests + # -- they do not yet inherit this setting + fixtures :all + + # Add more helper methods to be used by all tests here... +end diff --git a/test/unit/.gitkeep b/test/unit/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/assets/javascripts/.gitkeep b/vendor/assets/javascripts/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/assets/stylesheets/.gitkeep b/vendor/assets/stylesheets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/vendor/plugins/.gitkeep b/vendor/plugins/.gitkeep new file mode 100644 index 00000000..e69de29b