Merge branch 'staging'

This commit is contained in:
2017-11-16 14:52:16 +01:00
40 changed files with 656 additions and 45 deletions
+6 -3
View File
@@ -14,9 +14,15 @@ gem 'coffee-rails', '~> 4.1.0'
# Integrate Paperclip into Mongoid.
gem 'mongoid-paperclip'
# Markdown rendering
gem 'redcarpet'
# Stripe integration
gem 'stripe'
# Render your navigation as HTML list, link list or breadcrumbs.
gem 'simple-navigation'
# To extend paperclip with locales
gem 'paperclip-i18n'
@@ -37,9 +43,6 @@ gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Easily generate a Twitter Bootstrap navbar in your Rails app
gem 'rails_bootstrap_navbar'
# Kaminari Mongoid adapter.
gem 'kaminari-mongoid'
gem 'kaminari-actionview'
+6 -8
View File
@@ -52,8 +52,6 @@ GEM
benchmark-ips (2.7.2)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
bootstrap-navbar (2.5.0)
gem_config (~> 0.3)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
@@ -114,7 +112,6 @@ GEM
ffi (1.9.18)
font-awesome-rails (4.7.0.2)
railties (>= 3.2, < 5.2)
gem_config (0.3.1)
geocoder (1.4.4)
get_process_mem (0.2.1)
globalid (0.4.0)
@@ -251,9 +248,6 @@ GEM
rails (>= 4.0, < 6)
remotipart (~> 1.3)
sass-rails (>= 4.0, < 6)
rails_bootstrap_navbar (2.0.1)
bootstrap-navbar (~> 2.0)
rails (>= 3.0.0)
rails_serve_static_assets (0.0.5)
rails_stdout_logging (0.0.5)
railties (4.2.10)
@@ -266,6 +260,7 @@ GEM
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rdoc (4.3.0)
redcarpet (3.4.0)
remotipart (1.3.1)
responders (2.4.0)
actionpack (>= 4.2.0, < 5.3)
@@ -314,6 +309,8 @@ GEM
sdoc (0.4.2)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
simple-navigation (4.0.5)
activesupport (>= 2.3.2)
simple_form (3.5.0)
actionpack (> 4, < 5.2)
activemodel (> 4, < 5.2)
@@ -384,12 +381,13 @@ DEPENDENCIES
rails-i18n
rails_12factor
rails_admin
rails_bootstrap_navbar
redcarpet
roadie-rails (~> 1.0)
route_translator
rspec-rails (~> 3.0)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
simple-navigation
simple_form
slim
slim-rails
@@ -402,4 +400,4 @@ RUBY VERSION
ruby 2.3.1p112
BUNDLED WITH
1.14.6
1.16.0
+3
View File
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
+21 -1
View File
@@ -20,6 +20,17 @@
@import "footnotes"
@import "statements"
@import "donations"
@import "nav"
*:focus
outline: 0
-webkit-box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.075), 0 0 8px red
box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.075), 0 0 8px red
.form-control:focus, input:focus
outline: 0
-webkit-box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.075), 0 0 8px $brand-success
box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.075), 0 0 8px $brand-success
.alert-alert
@extend .alert-danger
@@ -58,6 +69,12 @@ body
.container
padding-left: 0px
header > .row
margin-bottom: 12px
main > h1
margin-top: 0px
ul#topnav
font-size: 1.2em
@@ -135,4 +152,7 @@ body
a
color: #FFF
.row.fix
display: flex
flex-wrap: wrap
width: 100%
+14
View File
@@ -0,0 +1,14 @@
// Place all the styles related to the Greendays controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
.well > h2
margin-top: 0px
#map
width: 100%
height: 300px
margin-bottom: 12px
.col-lg-4
width: 32% !important
+34
View File
@@ -0,0 +1,34 @@
@import "variables"
nav#mainnav
marign-top: 12px
font-size: 16pt
a
color: $brand-success
a.selected
font-weight: bold
ul
list-style: none
padding: 0px
li
padding: 5px 5px 5px 10px
ul
padding-left: 20px
li
font-size: 12pt
li.selected
background-color: $brand-success
a
color: white
#greendays
margin-bottom: 12px
border: 1px solid $brand-success
+30
View File
@@ -0,0 +1,30 @@
.field_with_errors {
padding: 2px;
background-color: red;
display: table;
}
#error_explanation {
width: 450px;
border: 2px solid red;
padding: 7px;
padding-bottom: 0;
margin-bottom: 20px;
background-color: #f0f0f0;
h2 {
text-align: left;
font-weight: bold;
padding: 5px 5px 5px 15px;
font-size: 12px;
margin: -7px;
margin-bottom: 0px;
background-color: #c00;
color: #fff;
}
ul li {
font-size: 12px;
list-style: square;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
$brand-success: #66903F
$brand-success: #4b7d1c
$navbar-default-bg: #FFF
$navbar-default-border: none
$font-size-base: 14px
+65
View File
@@ -0,0 +1,65 @@
class GreendaysController < ApplicationController
before_action :only_admin, except: [:index, :show]
before_action :set_greenday, only: [:show, :edit, :update, :destroy]
def index
@greendays = Greenday.all.sort(title: 1)
end
def new
@greenday = Greenday.new
end
def edit; end
def create
@greenday = Greenday.new(greenday_params)
respond_to do |format|
if @greenday.save
format.html { redirect_to greendays_path, success: 'Greenday was successfully created.' }
format.json { render :show, status: :created, location: @greenday }
else
format.html { render :new }
format.json { render json: @greenday.errors, status: :unprocessable_entity }
end
end
end
def update
respond_to do |format|
if @greenday.update(greenday_params)
format.html { redirect_to greendays_path, notice: 'Greenday was successfully updated.' }
format.json { render :show, status: :ok, location: @greenday }
else
format.html { render :edit }
format.json { render json: @greenday.errors, status: :unprocessable_entity }
end
end
end
def destroy
@greenday.destroy
respond_to do |format|
format.html { redirect_to greendays_path, notice: 'Greenday was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_greenday
@greenday = Greenday.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def greenday_params
params.require(:greenday).permit(:title, :address, :homepage, :description, :logo, :delete_logo)
end
def only_admin
return true if current_supporter && current_supporter.admin?
raise ActionController::RoutingError, 'Not Found'
end
end
+1 -1
View File
@@ -21,7 +21,7 @@ class SupportersController < ApplicationController
private
def supporter_form_params
params.require(:supporter).permit(:first_name, :last_name, :street, :zip, :email, :support, :li_membership, :age_category, :city, :comments)
params.require(:supporter).permit(:first_name, :last_name, :street, :zip, :email, :support, :li_membership, :age_category, :city, :comments, :tel)
end
# We use sendy for newsletters atm
+9
View File
@@ -3,4 +3,13 @@ module ApplicationHelper
content_for :title, strip_tags(page_title.to_s)
page_title
end
def markdown(content)
@markdown ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, space_after_headers: true)
@markdown.render(content)
end
def admin?
current_supporter && current_supporter.admin?
end
end
+43
View File
@@ -0,0 +1,43 @@
class Greenday
include Mongoid::Document
include Mongoid::Timestamps
include Geocoder::Model::Mongoid
include Mongoid::Paperclip
before_save :delete_logo?
has_mongoid_attached_file :logo,
path: ':attachment/:id/:style.:extension',
styles: {
original: ['1920x1680>', :jpg],
small: ['100x100#', :jpg],
medium: ['250x250', :jpg],
large: ['500x500>', :jpg]
},
convert_options: { all: '-background white -flatten +matte' }
field :title, type: String
field :address, type: String
field :homepage, type: String
field :description, type: String
field :coordinates, type: Array
geocoded_by :address
after_validation :geocode # auto-fetch coordinates
validates :title, presence: true
validates :address, presence: true
validates_attachment_content_type :logo, content_type: ['image/jpg', 'image/jpeg', 'image/png', 'image/gif']
def delete_logo
@delete_logo ||= '0'
end
attr_writer :delete_logo
private
def delete_logo?
logo.clear if @delete_logo == '1'
end
end
+1
View File
@@ -45,6 +45,7 @@ class Supporter
field :comments, type: String
field :language, type: String
field :duplicate, type: Boolean, default: false
field :tel, type: String
validates :first_name, presence: true
validates :last_name, presence: true
+4
View File
@@ -0,0 +1,4 @@
b Am 23. November ist Nationaler CBD-Tag!
p Um die #{link_to 'Finanzierung der Sammlung und Beglaubigung', donation_path} der eidgenössischen #{link_to 'Volksinitiative zur Cannabislegalisierung', initiative_text_path} in der Schweiz voranzutreiben, lanciert der Verein Legalize it! in Zusammenarbeit mit dem #{link_to 'Branchenverband IG Hanf', 'https://www.ighanf.ch/D_about.html', target: '_blank'} am 23. November 2017 den ersten nationalen CBD-Tag.
p An diesem Tag gibt es in zahlreichen CBD-Läden 10 Prozent Rabatt auf ausgewählte CBD-Produkte. In jedem Laden steht eine Spendenbox, welche für Spenden für die Initiative benutzt werden kann und die dem Verein Legalize it! zugute kommt.
p Welche Läden mitmachen, seht ihr auf der Karte:
+14
View File
@@ -0,0 +1,14 @@
= simple_form_for(@greenday) do |f|
= f.error_notification
.form-inputs
= f.input :title
= f.input :address, as: :text
= f.input :homepage
= f.input :description, as: :text
= f.input :logo, as: :file, required: false
= image_tag f.object.logo.url(:original), alt: '', class: 'img-responsive'
= f.input :delete_logo, as: :boolean
.form-actions
= f.button :submit, 'Shop speichern'
@@ -0,0 +1,2 @@
json.extract! greenday, :id, :title, :address, :coordinates, :homepage, :logo, :description, :created_at, :updated_at
json.url greenday_url(greenday, format: :json)
+8
View File
@@ -0,0 +1,8 @@
h1 Editing greenday
== render 'form'
= link_to 'Show', @greenday
' |
= link_to 'Back', greendays_path
+69
View File
@@ -0,0 +1,69 @@
h1.sr-only = title 'Gründonnerstag'
= render 'description'
#map
= link_to 'Neuen Shop erfassen', new_greenday_path if admin?
.row.fix
- @greendays.each do |greenday|
.col-xs-12.col-sm-6.col-lg-4
.well
h2 = greenday.title
- if greenday.logo.url(:original) != '/logos/original/missing.png'
= image_tag greenday.logo.url(:original), alt: '', class: 'img-responsive'
address = simple_format(greenday.address)
- if greenday.homepage
= link_to(greenday.homepage, greenday.homepage, target: "_blank")
p = markdown(greenday.description).html_safe
- if admin?
= link_to 'Bearbeiten', edit_greenday_path(greenday)
| &nbsp;
= link_to 'Löschen', greenday, data: { confirm: 'Are you sure?' }, method: :delete
javascript:
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
zoom: 8, center: {lat: 47.242, lng: 8.133},
});
var greendays_url = "#{greendays_url(format: :json)}"
var infowindow = new google.maps.InfoWindow({
content: '',
maxWidth: 200
});
$.getJSON(greendays_url, function(json) {
$.each(json, function(key, data) {
var marker = new google.maps.Marker({
position: {lat: data.coordinates[1], lng: data.coordinates[0] },
map: map,
title: data.title
});
marker.addListener('click', function() {
infowindow.open(map, marker);
var content = '<b>' + data.title + '</b>'
if(data.logo) {
content += '<img src="' + data.logo + ' alt="" width="100%"/>'
}
content += '<address>' + data.address.replace(/\n/g,"<br>")
if(data.homepage) {
content += '<br/><a href="' + data.homepage + '" target="_blank">' +data.homepage + '</a>'
}
content += '</address>'
if(data.description) {
content += '<p>' + data.description + '</p>'
}
infowindow.setContent(content);
});
});
});
}
script async="" defer="" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBbwMtGKDqf4i8x9-OVP1-H_QVAKp92h2M&callback=initMap&libraries=visualization"
+1
View File
@@ -0,0 +1 @@
json.array! @greendays, partial: 'greendays/greenday', as: :greenday
+5
View File
@@ -0,0 +1,5 @@
h1 New greenday
== render 'form'
= link_to 'Back', greendays_path
+5 -2
View File
@@ -65,8 +65,11 @@ html lang="#{I18n.locale}"
.container.content
= render 'shared/flashes'
= render 'shared/header'
= render 'shared/topnavigation'
= yield
.row
.col-xs-12.col-sm-3
nav#mainnav = render_navigation
.col-xs-12.col-sm-9
main= yield
hr
footer.row
.col-xs-12.col-sm-6
-19
View File
@@ -1,19 +0,0 @@
= navbar do
= navbar_header
= navbar_collapse do
= navbar_group id: 'topnav' do
= navbar_item "Home", "/#{I18n.locale}"
= navbar_dropdown t('.initiative') do
= navbar_item t('.initiative_text'), initiative_text_path
= navbar_item t('.arguments'), arguments_path
= navbar_item t('.faq'), faq_path
= navbar_item t('.numbers'), numbers_path
= navbar_item t('.collection_concept'), collection_concept_path
= navbar_item t('.statements'), statements_path
= navbar_item t('donation'), donation_path
= navbar_item 'Blog', 'http://blog.cannabis-initiative.ch'
= navbar_item t('.sign_in'), new_supporter_session_path unless supporter_signed_in?
= navbar_item t('.sign_out'), destroy_supporter_session_path, nil, 'data-method' => :delete if supporter_signed_in?
- if supporter_signed_in? && current_supporter.admin?
= navbar_dropdown t('admin.title') do
= navbar_item t('admin.publicities.index.title'), admin_publicities_path
+1
View File
@@ -9,6 +9,7 @@
= f.input :city, placeholder: t('.placeholders.city')
= f.input :zip, placeholder: t('.placeholders.zip')
= f.input :email, placeholder: t('.placeholders.email')
= f.input :tel, placeholder: '+41 (0) xxxx'
= f.input :support, as: :radio_buttons, collection: t('support_type').map{ |x| [x.first, raw(x.last)]}, label_method: :last, value_method: :first
= f.input :li_membership, as: :boolean
= f.input :age_category, as: :radio_buttons, collection: t('age_category'), label_method: :last, value_method: :first
+2
View File
@@ -23,6 +23,8 @@
dd == t("age_category.#{current_supporter.age_category}")
dt = Supporter.human_attribute_name(:language)
dd = t("languages.#{current_supporter.language}")
dt = Supporter.human_attribute_name(:tel)
dd = current_supporter.tel
p
= link_to t('.edit'), edit_supporter_registration_path(), class: 'pull-right'
@@ -21,7 +21,6 @@
= f.input :language, as: :radio_buttons, collection: t('languages').map{ |x| [x.first, raw(x.last)]}, label_method: :last, value_method: :first
.form-actions
= f.button :submit, t("devise.registrations.edit.update"), class: 'btn btn-primary'
p = link_to t("devise.shared.links.back"), :back
hr
p = link_to t("devise.registrations.edit.cancel_my_account"), registration_path(resource_name), data: { confirm: t("devise.registrations.edit.are_you_sure") }, method: :delete, class: 'btn btn-danger btn-sm pull-right'
+107
View File
@@ -0,0 +1,107 @@
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
config.middleware.insert_before(::Rack::Runtime, "::Rack::Auth::Basic", "Staging") do |_u, p|
p == ENV['STAGING_PASSWORD']
end
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# 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
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :warn
# 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'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
config.action_mailer.default_url_options = { host: 'ch420-staging.herokuapp.com' }
config.action_mailer.asset_host = 'https://ch420-staging.herokuapp.com'
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
port: '587',
address: ENV['SMTP_HOST'],
user_name: ENV['SMTP_USER'],
password: ENV['SMTP_PASSWORD'],
domain: 'hanflegal.ch',
authentication: :plain,
enable_starttls_auto: true
}
config.paperclip_defaults = {
storage: :s3,
s3_protocol: :https,
s3_region: ENV["S3_REGION"],
s3_host_name: ENV["S3_HOST_NAME"],
s3_credentials: {
bucket: "cannabis-initiative-staging",
access_key_id: ENV["S3_ACCESS_KEY"],
secret_access_key: ENV["S3_ACCESS_SECRET"]
}
}
end
@@ -1,4 +0,0 @@
BootstrapNavbar.configure do |config|
config.bootstrap_version = '3.3.6'
config.root_paths = ['/', '/de', '/fr', '/it'] # default: ['/']
end
+6 -2
View File
@@ -7,6 +7,8 @@ de:
logo: Logo der Initiative
title_html: Ja, ich will <strong class="text-success">Cannabis</strong> in der Schweiz <strong class="text-success">legalisieren</strong>
topnavigation:
support: Unterstützen
my_account: Mein Konto
sign_in: Anmelden
sign_out: Abmelden
initiative_text: Der Initiativtext im Wortlaut
@@ -15,7 +17,7 @@ de:
faq: Fragen und Antworten
sponsoring: Sponsoren
numbers: Zahlen
statementes: Statements
statements: Statements
collection_concept: Wie macht man eine Volksinitiative?
lang: Sprache
@@ -80,7 +82,7 @@ de:
new:
title: Hallo %{name}
edit: Meine Daten bearbeiten...
edit: Meine Daten bearbeiten
my_data: Meine Daten
publicities:
@@ -117,6 +119,7 @@ de:
numbers: zahlen
statementes: statements
collection_concept: Sammelkonzept
greendays: gründonnerstag
mongoid:
models:
@@ -138,6 +141,7 @@ de:
language: Sprache
password_confirmation: Passwort bestätigen
current_password: Aktuelles Passwort
tel: Telefon (optional)
publicity:
state: Status
organisation: Organisation
+5 -1
View File
@@ -12,6 +12,7 @@ fr:
logo: Logo de l'initiative
title_html: Oui, je veux <strong class="text-success">légaliser le cannabis</strong> en Suisse.
topnavigation:
support: Soutenez-nous
sign_out: déconnecter
sign_in: Connexion
initiative: l' initiative
@@ -22,6 +23,7 @@ fr:
numbers: Chiffres (en allemand)
statements: Déclarations
collection_concept: Comment faire une initiative populaire? (en allemand)
my_account: Mon compte
lang: Langue
are_you_sure: Tu es sûre?
@@ -77,7 +79,7 @@ fr:
new:
title: Salut %{name}
edit: Modifier mes données ...
edit: Modifier mes données
my_data: Mes données
publicities:
@@ -114,6 +116,7 @@ fr:
numbers: chiffres
statements: declarations
collection_concept: plan_de_collecte
greendays: jeudi_vert
mongoid:
models:
@@ -135,6 +138,7 @@ fr:
language: Langue
password_confirmation: confirmer le mot de passe
current_password: Mot de passe actuel
tel: Téléphone (facultatif)
publicity:
status: Statu
+5 -1
View File
@@ -9,6 +9,7 @@ it:
logo: Logo dell'iniziativa
title_html: Si, voglio <strong class="text-success">legalizzare</strong> la <strong class="text-success">cannabis in Svizzera</strong>
topnavigation:
support: Sostenici
sign_out: Disconnettersi
sign_in: Registro
initiative_text: Il testo delliniziativa (in tedesco)
@@ -19,6 +20,7 @@ it:
numbers: Numeri (in tedesco)
statements: Dichiarazioni
collection_concept: Come fare un iniziativa popolare? (in tedesco)
my_account: Il mio account
counter:
supporters: "Sostenitore:"
@@ -81,7 +83,7 @@ it:
new:
title: Ciao %{name}
edit: Modifica i miei dati ...
edit: Modifica i miei dati
my_data: Miei dati
publicities:
@@ -118,6 +120,7 @@ it:
numbers: numeri
statements: dichiarazioni
collection_concept: sistema_di_raccolta
greendays: giovedi_verdi
mongoid:
attributes:
@@ -137,6 +140,7 @@ it:
language: Lingua
password_confirmation: conferma password
current_password: Password corrente
tel: Telefono (opzionale)
publicity:
status: Statu
organisation: Organizzazione
+5
View File
@@ -13,6 +13,11 @@ test:
hosts:
- localhost:27017
staging:
clients:
default:
uri: <%= ENV['MONGODB_URI'] %>
production:
clients:
default:
+87
View File
@@ -0,0 +1,87 @@
# -*- coding: utf-8 -*-
# Configures your navigation
SimpleNavigation::Configuration.run do |navigation|
# Specify a custom renderer if needed.
# The default renderer is SimpleNavigation::Renderer::List which renders HTML lists.
# The renderer can also be specified as option in the render_navigation call.
# navigation.renderer = Your::Custom::Renderer
# Specify the class that will be applied to active navigation items. Defaults to 'selected'
#navigation.selected_class = 'selected'
# Specify the class that will be applied to the current leaf of
# active navigation items. Defaults to 'simple-navigation-active-leaf'
#navigation.active_leaf_class = 'simple-navigation-active-leaf'
# Specify if item keys are added to navigation items as id. Defaults to true
#navigation.autogenerate_item_ids = true
# You can override the default logic that is used to autogenerate the item ids.
# To do this, define a Proc which takes the key of the current item as argument.
# The example below would add a prefix to each key.
#navigation.id_generator = Proc.new {|key| "my-prefix-#{key}"}
# If you need to add custom html around item names, you can define a proc that
# will be called with the name you pass in to the navigation.
# The example below shows how to wrap items spans.
#navigation.name_generator = Proc.new {|name, item| "<span>#{name}</span>"}
# Specify if the auto highlight feature is turned on (globally, for the whole navigation). Defaults to true
#navigation.auto_highlight = true
# Specifies whether auto highlight should ignore query params and/or anchors when
# comparing the navigation items with the current URL. Defaults to true
#navigation.ignore_query_params_on_auto_highlight = true
#navigation.ignore_anchors_on_auto_highlight = true
# If this option is set to true, all item names will be considered as safe (passed through html_safe). Defaults to false.
#navigation.consider_item_names_as_safe = false
# Define the primary navigation
navigation.items do |primary|
# Add an item to the primary navigation. The following params apply:
# key - a symbol which uniquely defines your navigation item in the scope of the primary_navigation
# name - will be displayed in the rendered navigation. This can also be a call to your I18n-framework.
# url - the address that the generated item links to. You can also use url_helpers (named routes, restful routes helper, url_for etc.)
# options - can be used to specify attributes that will be included in the rendered navigation item (e.g. id, class etc.)
# some special options that can be set:
# :if - Specifies a proc to call to determine if the item should
# be rendered (e.g. <tt>if: -> { current_user.admin? }</tt>). The
# proc should evaluate to a true or false value and is evaluated in the context of the view.
# :unless - Specifies a proc to call to determine if the item should not
# be rendered (e.g. <tt>unless: -> { current_user.admin? }</tt>). The
# proc should evaluate to a true or false value and is evaluated in the context of the view.
# :method - Specifies the http-method for the generated link - default is :get.
# :highlights_on - if autohighlighting is turned off and/or you want to explicitly specify
# when the item should be highlighted, you can set a regexp which is matched
# against the current URI. You may also use a proc, or the symbol <tt>:subpath</tt>.
#
primary.item :greendays, 'Gründonnerstag', greendays_path
unless supporter_signed_in?
primary.item :home, I18n.t('.shared.topnavigation.support'), "/#{I18n.locale}"
end
primary.item :initiative, I18n.t('.shared.topnavigation.initiative'), initiative_text_path do | initiative |
initiative.item :arguments, I18n.t('.shared.topnavigation.arguments'), arguments_path
initiative.item :faq, I18n.t('.shared.topnavigation.faq'), faq_path
initiative.item :numbers, I18n.t('.shared.topnavigation.numbers'), numbers_path
initiative.item :collection_concept, I18n.t('.shared.topnavigation.collection_concept'), collection_concept_path
end
primary.item :statements, I18n.t('.shared.topnavigation.statements'), statements_path do |statements|
statements.item :new_statement, I18n.t('.supporters.publicity.renew'), new_publicity_path
end
primary.item :donation, I18n.t('donation'), donation_path
primary.item :blog, 'Blog', 'http://blog.cannabis-initiative.ch/', link_html: { target: '_blank'}
if supporter_signed_in?
primary.item :home, I18n.t('.shared.topnavigation.my_account'), "/#{I18n.locale}" do |my_account|
my_account.item :edit_account, I18n.t('.supporters.new.edit'), edit_supporter_registration_path()
my_account.item :sign_out, I18n.t('.shared.topnavigation.sign_out'), destroy_supporter_session_path, link_html: { 'data-method' => :delete }
end
else
primary.item :home, I18n.t('.shared.topnavigation.sign_in'), new_supporter_session_path
end
end
end
+1
View File
@@ -11,6 +11,7 @@ Rails.application.routes.draw do
end
localized do
resources :greendays
get '/initiative_text', to: 'pages#show', as: :initiative_text, page: 'initiative_text'
get '/arguments', to: 'pages#show', as: :arguments, page: 'arguments'
get '/faq', to: 'pages#show', as: :faq, page: 'faq'
+4
View File
@@ -16,6 +16,10 @@ development:
test:
secret_key_base: f9c7c3d851c4c3c44390cb50e69491b241ae26d0e3b9d488579590963d30ff8e7e5d91b0930ec9b282661a59b24ef6abe4fc5615607e787f9e0ac76cb81f42fd
staging:
secret_key_base: 88f843073f09ab3f825b53df5d179d8818abea1848cd4717a4f6f0e3c8b4cb11c719d2fe5cb867755cab5d3aaf7feab62c6f9df7d56a270ebeaf7e0ab9be6ba8
# Do not keep production secrets in the repository,
# instead read values from the environment.
production:
+2
View File
@@ -10,6 +10,7 @@ feature 'Support' do
fill_in 'Postleitzahl', with: '8704'
fill_in 'Ort', with: 'Herrliberg'
fill_in 'E-Mail', with: 'blocher@blocher.ch'
fill_in 'Telefon', with: '12345'
fill_in 'Kommentar / Feedback', with: 'Test text'
choose 'Ich würde eine Volksinitiative für die Legalisierung von Cannabis unterschreiben und helfe aktiv Unterschriften in meiner Umgebung zu sammeln.'
@@ -30,6 +31,7 @@ feature 'Support' do
expect(supporter.comments).to eq 'Test text'
expect(supporter.language).to eq 'de'
expect(supporter.li_membership).to eq true
expect(supporter.tel).to eq '12345'
end
scenario 'A bot tries to enter data' do
+5
View File
@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe Greenday, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end
+10
View File
@@ -0,0 +1,10 @@
require 'rails_helper'
RSpec.describe "Greendays", type: :request do
describe "GET /greendays" do
it "works! (now write some real specs)" do
get greendays_path
expect(response).to have_http_status(200)
end
end
end
@@ -0,0 +1,24 @@
require 'rails_helper'
RSpec.describe "greendays/edit", type: :view do
before(:each) do
@greenday = assign(:greenday, Greenday.create!(
:title => "MyString",
:address => "MyText",
:description => "MyText"
))
end
it "renders the edit greenday form" do
render
assert_select "form[action=?][method=?]", greenday_path(@greenday), "post" do
assert_select "input#greenday_title[name=?]", "greenday[title]"
assert_select "textarea#greenday_address[name=?]", "greenday[address]"
assert_select "textarea#greenday_description[name=?]", "greenday[description]"
end
end
end
@@ -0,0 +1,25 @@
require 'rails_helper'
RSpec.describe 'greendays/index' do
before(:each) do
assign(:greendays, [
Greenday.create!(
title: 'Title',
address: 'Address',
description: 'MyText'
),
Greenday.create!(
title: 'Title',
address: 'Address',
description: 'MyText'
)
])
end
it 'renders a list of greendays' do
render
assert_select 'h2', text: 'Title'.to_s, count: 2
assert_select "address", :text => "Address".to_s, count: 2
assert_select "p", :text => "MyText".to_s, count: 2
end
end
@@ -0,0 +1,24 @@
require 'rails_helper'
RSpec.describe "greendays/new", type: :view do
before(:each) do
assign(:greenday, Greenday.new(
:title => "MyString",
:address => "MyText",
:description => "MyText"
))
end
it "renders new greenday form" do
render
assert_select "form[action=?][method=?]", greendays_path, "post" do
assert_select "input#greenday_title[name=?]", "greenday[title]"
assert_select "textarea#greenday_address[name=?]", "greenday[address]"
assert_select "textarea#greenday_description[name=?]", "greenday[description]"
end
end
end