Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
maxgronlund committed Nov 3, 2015
1 parent 7ac4dbb commit 77207f7
Show file tree
Hide file tree
Showing 22 changed files with 194 additions and 44 deletions.
3 changes: 3 additions & 0 deletions app/assets/javascripts/faq.coffee
Original file line number Diff line number Diff line change
@@ -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/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/faq.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the faq controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
2 changes: 1 addition & 1 deletion app/controllers/admin/blogs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def create
end

def update
params[:blog][:version] = @blog.version + 1
#params[:blog][:version] = @blog.version + 1
if @blog.update(blog_params)
redirect_to admin_blogs_path(page: params[:page])
else
Expand Down
11 changes: 11 additions & 0 deletions app/controllers/faq_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class FaqController < ApplicationController
def index
PageView.create(url: '/faq' )
@blog = Blog.cached_find('FAQ')
@user = current_user
end

def show

end
end
6 changes: 2 additions & 4 deletions app/controllers/user/publishers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ def create
if @publisher.save
@user.copy_address_to( @publisher.address )
CopyMachine.setup_publisher @publisher.id
#if @publisher.personal_publisher
# @user.copy_address_to( @publisher.address )
#end

format.html { redirect_to edit_user_user_publisher_legal_info_path(@publisher.user, @publisher), info: 'Please add legal informations.' }
format.json { render :show, status: :created, location: @publisher }
else
format.html { render :new, info: 'Publisher was successfully destroyed.' }
format.html { render :new, info: 'Unable to create publisher.' }
format.json { render json: @publisher.errors, status: :unprocessable_entity }
end
end
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/faq_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module FaqHelper
end
10 changes: 8 additions & 2 deletions app/models/publisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ class Publisher < ActiveRecord::Base
#after_create :create_user_publisher
after_commit :flush_cache

before_destroy :reset_common_work_ipis
before_destroy :sanitize_relations

def reset_common_work_ipis
def sanitize_relations

if self.user_publishers
user_publishers.destroy_all
end


common_work_ipis.update_all(publisher_id: nil)
end

Expand Down
10 changes: 7 additions & 3 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ class User < ActiveRecord::Base

has_one :ipi, dependent: :destroy
has_one :address
has_one :publisher
#has_one :publisher
accepts_nested_attributes_for :address
accepts_nested_attributes_for :publisher
#accepts_nested_attributes_for :publisher
include AddressMix

has_one :account
Expand All @@ -77,7 +77,7 @@ class User < ActiveRecord::Base
# A user can have many publishers that he uses for publishing other persons
#has_many :user_publishers
#has_many :publishers, :through => :user_publishers
has_many :publishers
#has_many :publishers
has_many :distribution_agreements

has_many :comments, as: :commentable, dependent: :destroy
Expand Down Expand Up @@ -552,6 +552,10 @@ def sanitize_relations
)
end

if self.user_publishers
user_publishers.destroy_all
end

end

def self.system_user
Expand Down
11 changes: 10 additions & 1 deletion app/services/copy_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ def self.setup_publisher publisher_id
'34debb4c-5e09-11e5-a542-d43d7eecec4d',
publishing_agreement
)


UserPublisher.where(
publisher_id: publisher_id,
user_id: publisher.user_id
)
.first_or_create(
publisher_id: publisher_id,
user_id: publisher.user_id,
email: publisher.email
)
end

def self.setup_publishing_agreement(publisher_id, personal_agreement, title, user)
Expand Down
54 changes: 54 additions & 0 deletions app/views/faq/index.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#wrapper
.full-width-top
== render 'shared/navigationbar', page: 'opportunities'


#sidebar-wrapper
ul class="sidebar-nav"
== render 'public_opportunities/sidebar', selected: 'opportunities'


#page-content-wrapper
.container-fluid
== render 'shared/breadcrumbs', breadcrumbs: { links: { admin: admin_index_path }, current: ''}
.row
.col-sm-5

h2 = @blog.title

/.col-sm-7
/ .pull-down-10
/ = simple_form_for [ @blog ], :url => url_for(:action => 'index', \
/ :controller => 'faq'), \
/ :method => 'get',
/ turboboost: true do |f|
/
/ .input-group
/ span class="input-group-addon"
/ i class= 'fa fa-search'
/ = text_field_tag "query", "", :class => 'search-query form-control', \
/ :placeholder => 'Search topic', \
/ value: params[:query]
/ .input-group-btn
/ = f.submit 'Search', class: "btn btn-info"
/ '&nbsp;
/ = link_to 'Clear', faq_path, class: 'btn btn-default'
/
/
.pull-down-10

/def self.cached_find('FAQ , @blog)
.digi-box
- @blog.blog_posts.each do |blog_post|
h4 = blog_post.title
= simple_format blog_post.body
- if super?
.row
.col-sm-12
.pull-right
= link_to 'Add question', new_admin_blog_blog_post_path(@blog), class: 'btn btn-info'



== render 'shared/site_footer'
20 changes: 10 additions & 10 deletions app/views/user/ipi_publishers/edit.slim
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@



b
'*Revenue stream
== render 'shared/popover', identifier: 'Select the revenue stream for this creator'
.chosen-label.pull-down-6
= f.input :publishing_agreement_id,
collection: @publishing_agreements,
include_blank: false,
label: false,
input_html: { class: 'chosen-select', 'data-placeholder'.to_sym => "Distribution agreement" }

/b
/ '*Revenue stream
/== render 'shared/popover', identifier: 'Select the revenue stream for this creator'
/.chosen-label.pull-down-6
/ = f.input :publishing_agreement_id,
/ collection: @publishing_agreements,
/ include_blank: false,
/ label: false,
/ input_html: { class: 'chosen-select', 'data-placeholder'.to_sym => "Distribution agreement" }
/
.row
.col-sm-12
.pull-right
Expand Down
28 changes: 14 additions & 14 deletions app/views/user/ipi_publishers/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@
'*Email
== render 'shared/popover', identifier: 'This email is used to link a creator to this publisher, the creator should receive an email asking for confirmation'
.pull-down-6
= f.input :email, label: false
= f.input :email, label: false, placeholder: 'Creators email'



b
'* Revenue stream
== render 'shared/popover', identifier: 'The revenue stream defines your share as a publisher, you can add as many streams as you want'
.chosen-label
= f.input :publishing_agreement_id,
collection: @publishing_agreements,
include_blank: false,
label: false,
multiple: false,
input_html: { class: 'chosen-select', 'data-placeholder'.to_sym => "Select recording..." }



/b
/ '* Revenue stream
/== render 'shared/popover', identifier: 'The revenue stream defines your share as a publisher, you can add as many streams as you want'
/.chosen-label
/ = f.input :publishing_agreement_id,
/ collection: @publishing_agreements,
/ include_blank: false,
/ label: false,
/ multiple: false,
/ input_html: { class: 'chosen-select', 'data-placeholder'.to_sym => "Select recording..." }
/
/
/
.row
.col-sm-12
.pull-right
Expand Down
7 changes: 4 additions & 3 deletions app/views/user/publishers/new.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
.digi-box
= simple_form_for [:user, @user, @publisher] do |f|
= f.error_notification

.form-inputs
== render 'shared/flash_message'
.row
Expand All @@ -49,9 +49,10 @@
= f.input :show_on_public_page, input_html: { class: 'icheck-me acceptance', 'data-skin'.to_sym => "square", 'data-color'.to_sym => "blue" }

span.help-block Make this publisher avaliable to the public

.pull-down-24
= f.input :ipi_code, placeholder: 'Optional', label: 'IPI code'
.col-sm-6
= f.input :email, :hint => "Publishers email"
= f.input :email, placeholder: "Publishers email", hint: "Uniqe email used to identify the publisher"
= f.input :legal_name, :hint => "Publishers legal name"
.form-actions
.row
Expand Down
5 changes: 4 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@





#resources :document_users
get 'landing_page/index'

Expand All @@ -29,7 +31,8 @@

resources :addresses



get 'faq', to: 'faq#index', as: 'faq'

namespace :stripe do
resources :success
Expand Down
17 changes: 17 additions & 0 deletions db/migrate/20151101133316_secure_user_publishers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class SecureUserPublishers < ActiveRecord::Migration
def change
Publisher.find_each do |publisher|
UserPublisher.where(
user_id: publisher.user_id,
publisher_id: publisher.id

)
.first_or_create(
user_id: publisher.user_id,
publisher_id: publisher.id,
email: publisher.email
)

end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class RemoveForeignKeysOnUserPublishers < ActiveRecord::Migration
def change
remove_foreign_key "user_publishers", "users"
remove_foreign_key "user_publishers", "publishers"
end
end
4 changes: 1 addition & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20151101091707) do
ActiveRecord::Schema.define(version: 20151101141315) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -3845,7 +3845,5 @@
add_foreign_key "subscriptions", "coupons"
add_foreign_key "subscriptions", "plans"
add_foreign_key "user_notifications", "users", on_delete: :cascade
add_foreign_key "user_publishers", "publishers"
add_foreign_key "user_publishers", "users"
add_foreign_key "widgets", "accounts", on_delete: :cascade
end
Binary file modified documents/strategy/DIGIRAMP strategy-1.6.1.docx
Binary file not shown.
7 changes: 5 additions & 2 deletions documents/strategy/Indie labels.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ http://www.privco.com/private-company/reverbnation
Funding: $8.6M in 3 Rounds from 3 Investors

----------------------------------------------------------------------------------------------------------

http://www.dup.nu/

Sources
*1 https://en.wikipedia.org/wiki/Category:American_independent_record_labels
Expand All @@ -159,4 +159,7 @@ Sources

https://digiramp.com/users/sun-records

Scot bounty
Scot bounty


a typical indilabel has 10 albums with 14 songs = 280 songs
12 changes: 12 additions & 0 deletions spec/controllers/faq_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'rails_helper'

RSpec.describe FaqController, type: :controller do

describe "GET #index" do
it "returns http success" do
get :index
expect(response).to have_http_status(:success)
end
end

end
15 changes: 15 additions & 0 deletions spec/helpers/faq_helper_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'rails_helper'

# Specs in this file have access to a helper object that includes
# the FaqHelper. For example:
#
# describe FaqHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe FaqHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end
5 changes: 5 additions & 0 deletions spec/views/faq/index.html.slim_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

RSpec.describe "faq/index.html.slim", type: :view do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit 77207f7

Please sign in to comment.