Permalink
Browse files

uploading latest changes - still no use

  • Loading branch information...
1 parent 7e22450 commit d8a7f6a950b477083cfb81614cdeed54e2c429c8 @pjammer committed Apr 18, 2009
Showing with 784 additions and 6 deletions.
  1. +1 −0 .gitignore
  2. +104 −0 app/controllers/admin/ad_photos_controller.rb
  3. +88 −0 app/controllers/admin/affiliate_links_controller.rb
  4. +89 −0 app/controllers/admin/affiliate_settings_controller.rb
  5. +2 −2 app/controllers/admin/affiliates_controller.rb
  6. +23 −0 app/controllers/affiliate_links_controller.rb
  7. +3 −0 app/helpers/ad_photos_helper.rb
  8. +6 −0 app/helpers/admin/affiliate_links_helper.rb
  9. +6 −0 app/helpers/affiliate_links_helper.rb
  10. +4 −0 app/helpers/affiliate_settings_helper.rb
  11. +8 −0 app/models/ad_photo.rb
  12. +2 −0 app/models/affiliate.rb
  13. +5 −0 app/models/affiliate_link.rb
  14. +4 −0 app/models/affiliate_setting.rb
  15. +52 −0 app/views/admin/ad_photos/edit.html.erb
  16. +38 −0 app/views/admin/ad_photos/index.html.erb
  17. +23 −0 app/views/admin/ad_photos/new.html.erb
  18. +55 −0 app/views/admin/ad_photos/show.html.erb
  19. +12 −0 app/views/admin/affiliate_links/_form_fields.html.erb
  20. +8 −0 app/views/admin/affiliate_links/edit.html.erb
  21. +24 −0 app/views/admin/affiliate_links/index.html.erb
  22. +9 −0 app/views/admin/affiliate_links/new.html.erb
  23. +14 −0 app/views/admin/affiliate_links/show.html.erb
  24. +9 −0 app/views/admin/affiliate_settings/_form_fields.html.erb
  25. +8 −0 app/views/admin/affiliate_settings/edit.html.erb
  26. +9 −0 app/views/admin/affiliate_settings/index.html.erb
  27. +8 −0 app/views/admin/affiliate_settings/new.html.erb
  28. +7 −0 app/views/admin/affiliate_settings/show.html.erb
  29. +1 −1 app/views/admin/affiliates/index.html.erb
  30. +24 −0 app/views/affiliate_links/edit.html.erb
  31. +21 −0 app/views/affiliate_links/index.html.erb
  32. +18 −0 app/views/affiliate_links/new.html.erb
  33. +18 −0 app/views/affiliate_links/show.html.erb
  34. +15 −0 db/migrate/20090311213330_create_affiliates.rb
  35. +16 −0 db/migrate/20090315142419_create_affiliate_settings.rb
  36. +15 −0 db/migrate/20090315165921_create_affiliate_links.rb
  37. +9 −0 db/migrate/20090315165922_adding_to_affiliate_links.rb
  38. +22 −0 db/migrate/20090319121342_create_ad_photos.rb
  39. +4 −3 routes.rb
View
1 .gitignore
@@ -0,0 +1 @@
+.DS_Store
View
104 app/controllers/admin/ad_photos_controller.rb
@@ -0,0 +1,104 @@
+class Admin::AdPhotosController < ApplicationController
+ before_filter :login_required
+ before_filter :has_role_admin
+ layout "admin"
+ # GET /ad_photos
+ # GET /ad_photos.xml
+ def index
+ @ad_photos = AdPhoto.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @ad_photos }
+ end
+ end
+
+ # GET /ad_photos/1
+ # GET /ad_photos/1.xml
+ def show
+ @ad_photo = AdPhoto.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @ad_photo }
+ end
+ end
+
+ # GET /ad_photos/new
+ # GET /ad_photos/new.xml
+ def new
+ @ad_photo = AdPhoto.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @ad_photo }
+ end
+ end
+
+ # GET /ad_photos/1/edit
+ def edit
+ @ad_photo = AdPhoto.find(params[:id])
+ end
+
+ # POST /ad_photos
+ # POST /ad_photos.xml
+ def create
+ @ad_photo = AdPhoto.new(params[:ad_photo])
+
+ respond_to do |format|
+ if @ad_photo.save
+ flash[:notice] = 'AdPhoto was successfully created.'
+ format.html { redirect_to([:admin, @ad_photo]) }
+ format.xml { render :xml => @ad_photo, :status => :created, :location => @ad_photo }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @ad_photo.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /ad_photos/1
+ # PUT /ad_photos/1.xml
+ def update
+ @ad_photo = AdPhoto.find(params[:id])
+
+ respond_to do |format|
+ if @ad_photo.update_attributes(params[:ad_photo])
+ flash[:notice] = 'AdPhoto was successfully updated.'
+ format.html { redirect_to([:admin, @ad_photo]) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @ad_photo.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /ad_photos/1
+ # DELETE /ad_photos/1.xml
+ def destroy
+ @ad_photo = AdPhoto.find(params[:id])
+ @ad_photo.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(admin_ad_photos_url) }
+ format.xml { head :ok }
+ end
+ end
+
+ #taken from http://garbageburrito.com/blog/entry/135/javascript-image-cropping-with-jscropperui-and-rails
+ def crop_and_close
+ @setting = AdPhoto.find(params[:id]) #how they got their image
+ if params[:x1]
+ img = Magick::Image::read(@setting.full_filename).first
+ img.crop!(::Magick::CenterGravity, params[:x1].to_i, params[:y1].to_i,
+ params[:width].to_i, params[:height].to_i, true)
+ img.write @setting.full_filename
+ end
+ respond_to do |format|
+ format.html { redirect_to(admin_ad_photos_url) }
+ format.xml { head :ok }
+ end
+ end
+
+end
View
88 app/controllers/admin/affiliate_links_controller.rb
@@ -0,0 +1,88 @@
+class Admin::AffiliateLinksController < ApplicationController
+ before_filter :login_required
+ before_filter :has_role_admin
+ layout "admin"
+ # GET /affiliate_settings # GET /affiliate_links
+ # GET /affiliate_links.xml
+ def index
+ @affiliate_links = AffiliateLink.find(:all)
+ @affiliate_setting = AffiliateSetting.find_by_account_id(current_account)
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @affiliate_links }
+ end
+ end
+
+ # GET /affiliate_links/1
+ # GET /affiliate_links/1.xml
+ def show
+ @affiliate_link = AffiliateLink.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @affiliate_link }
+ end
+ end
+
+ # GET /affiliate_links/new
+ # GET /affiliate_links/new.xml
+ def new
+ @affiliate_link = AffiliateLink.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @affiliate_link }
+ end
+ end
+
+ # GET /affiliate_links/1/edit
+ def edit
+ @affiliate_link = AffiliateLink.find(params[:id])
+ end
+
+ # POST /affiliate_links
+ # POST /affiliate_links.xml
+ def create
+ @affiliate_link = AffiliateLink.new(params[:affiliate_link])
+ @affiliate_link.affiliate_id = current_account.id
+ respond_to do |format|
+ if @affiliate_link.save
+ flash[:notice] = 'AffiliateLink was successfully created.'
+ format.html { redirect_to(@affiliate_link) }
+ format.xml { render :xml => @affiliate_link, :status => :created, :location => @affiliate_link }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @affiliate_link.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /affiliate_links/1
+ # PUT /affiliate_links/1.xml
+ def update
+ @affiliate_link = AffiliateLink.find(params[:id])
+
+ respond_to do |format|
+ if @affiliate_link.update_attributes(params[:affiliate_link])
+ flash[:notice] = 'AffiliateLink was successfully updated.'
+ format.html { redirect_to(@affiliate_link) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @affiliate_link.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /affiliate_links/1
+ # DELETE /affiliate_links/1.xml
+ def destroy
+ @affiliate_link = AffiliateLink.find(params[:id])
+ @affiliate_link.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(affiliate_links_url) }
+ format.xml { head :ok }
+ end
+ end
+end
View
89 app/controllers/admin/affiliate_settings_controller.rb
@@ -0,0 +1,89 @@
+class Admin::AffiliateSettingsController < ApplicationController
+ before_filter :login_required
+ before_filter :has_role_admin
+ layout "admin"
+ # GET /affiliate_settings
+ # GET /affiliate_settings.xml
+ def index
+ @affiliate_settings = AffiliateSetting.find(:all)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @affiliate_settings }
+ end
+ end
+
+ # GET /affiliate_settings/1
+ # GET /affiliate_settings/1.xml
+ def show
+ @affiliate_setting = AffiliateSetting.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @affiliate_setting }
+ end
+ end
+
+ # GET /affiliate_settings/new
+ # GET /affiliate_settings/new.xml
+ def new
+ @affiliate_setting = AffiliateSetting.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.xml { render :xml => @affiliate_setting }
+ end
+ end
+
+ # GET /affiliate_settings/1/edit
+ def edit
+ @affiliate_setting = AffiliateSetting.find(params[:id])
+ end
+
+ # POST /affiliate_settings
+ # POST /affiliate_settings.xml
+ def create
+ @affiliate_setting = AffiliateSetting.new(params[:affiliate_setting])
+ @affiliate_setting.account_id = current_account.id
+ @affiliate_setting.user_id = current_user.id
+ respond_to do |format|
+ if @affiliate_setting.save
+ flash[:notice] = 'AffiliateSetting was successfully created.'
+ format.html { redirect_to([:admin, @affiliate_setting]) }
+ format.xml { render :xml => @affiliate_setting, :status => :created, :location => @affiliate_setting }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @affiliate_setting.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /affiliate_settings/1
+ # PUT /affiliate_settings/1.xml
+ def update
+ @affiliate_setting = AffiliateSetting.find(params[:id])
+
+ respond_to do |format|
+ if @affiliate_setting.update_attributes(params[:affiliate_setting])
+ flash[:notice] = 'AffiliateSetting was successfully updated.'
+ format.html { redirect_to([:admin, @affiliate_setting]) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @affiliate_setting.errors, :status => :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /affiliate_settings/1
+ # DELETE /affiliate_settings/1.xml
+ def destroy
+ @affiliate_setting = AffiliateSetting.find(params[:id])
+ @affiliate_setting.destroy
+
+ respond_to do |format|
+ format.html { redirect_to(admin_affiliate_settings_url) }
+ format.xml { head :ok }
+ end
+ end
+end
View
4 app/controllers/admin/affiliates_controller.rb
@@ -1,12 +1,12 @@
class Admin::AffiliatesController < ApplicationController
before_filter :login_required
- before_filter :admin?
+ before_filter :has_role_admin
layout "admin"
#Show all users who are affiliates.
#TODO: Add a quick look table of what you owe to who. integrate into paypal somehow for them to send the money.
def index
@affiliates = @account.affiliates.paginate(:page => params[:page], :order => "id desc")
-
+ @affiliate = Affiliate.find_by_user_id(current_user)
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @affiliates }
View
23 app/controllers/affiliate_links_controller.rb
@@ -0,0 +1,23 @@
+class AffiliateLinksController < ApplicationController
+ # GET /affiliate_links
+ # GET /affiliate_links.xml
+ def index
+ @affiliate_links = AffiliateLink.paginate(:page => params[:page])
+ @affiliate = Affiliate.find_by_user_id(current_user)
+ respond_to do |format|
+ format.html # index.html.erb
+ format.xml { render :xml => @affiliate_links }
+ end
+ end
+
+ # GET /affiliate_links/1
+ # GET /affiliate_links/1.xml
+ def show
+ @affiliate_link = AffiliateLink.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.xml { render :xml => @affiliate_link }
+ end
+ end
+end
View
3 app/helpers/ad_photos_helper.rb
@@ -0,0 +1,3 @@
+module AdPhotosHelper
+
+end
View
6 app/helpers/admin/affiliate_links_helper.rb
@@ -0,0 +1,6 @@
+module Admin::AffiliateLinksHelper
+ #Link used to show the relevant code for the affiliate.
+ def display_link(text, affiliate_link_id, code)
+ link_to text, affiliate_link_url("#{affiliate_link_id}")+"?#{code}"
+ end
+end
View
6 app/helpers/affiliate_links_helper.rb
@@ -0,0 +1,6 @@
+module AffiliateLinksHelper
+ #Link used to show the relevant code for the affiliate.
+ def display_link(text, code, link_url=root_url)
+ link_to text, link_url+"?#{code}"
+ end
+end
View
4 app/helpers/affiliate_settings_helper.rb
@@ -0,0 +1,4 @@
+module AffiliateSettingsHelper
+
+
+end
View
8 app/models/ad_photo.rb
@@ -0,0 +1,8 @@
+class AdPhoto < ActiveRecord::Base
+ attr_accessible :id, :parent_id, :user_id, :created_at, :updated_at, :current_user_id
+ has_attachment :content_type => :image,
+ :storage => :file_system,
+ :size => 0.megabyte..2.megabytes,
+ :resize_to => '450x450',
+ :thumbnails => { :thumb => '150x150'}
+end
View
2 app/models/affiliate.rb
@@ -3,6 +3,8 @@ class Affiliate < ActiveRecord::Base
#TODO: remove these filters, add a lib/before_filters.rb file or comment out but include what SHOULD go there.
belongs_to :account
belongs_to :user
+ has_one :affiliate_setting
+ has_many :affiliate_links
validates_presence_of :paypal_email
validates_format_of :paypal_email, :with => Authentication.email_regex, :message => Authentication.bad_email_message
#ToDo: add valadation that checks for user_id and account_id only one user and account_id combo allowed per account.
View
5 app/models/affiliate_link.rb
@@ -0,0 +1,5 @@
+class AffiliateLink < ActiveRecord::Base
+ belongs_to :account
+ belongs_to :affiliate
+ LINK_TYPES = ["Text", "Banner", "Half Banner"]
+end
View
4 app/models/affiliate_setting.rb
@@ -0,0 +1,4 @@
+class AffiliateSetting < ActiveRecord::Base
+ belongs_to :account
+ PERCENTAGES = (5..70).step(5)
+end
View
52 app/views/admin/ad_photos/edit.html.erb
@@ -0,0 +1,52 @@
+<h1>Editing ad_photo</h1>
+
+<% form_for(@ad_photo) do |f| %>
+ <%= f.error_messages %>
+
+ <p>
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </p>
+ <p>
+ <%= f.label :description %><br />
+ <%= f.text_area :description %>
+ </p>
+ <p>
+ <%= f.label :user_id %><br />
+ <%= f.text_field :user_id %>
+ </p>
+ <p>
+ <%= f.label :content_type %><br />
+ <%= f.text_field :content_type %>
+ </p>
+ <p>
+ <%= f.label :filename %><br />
+ <%= f.text_field :filename %>
+ </p>
+ <p>
+ <%= f.label :size %><br />
+ <%= f.text_field :size %>
+ </p>
+ <p>
+ <%= f.label :parent_id %><br />
+ <%= f.text_field :parent_id %>
+ </p>
+ <p>
+ <%= f.label :thumbnail %><br />
+ <%= f.text_field :thumbnail %>
+ </p>
+ <p>
+ <%= f.label :width %><br />
+ <%= f.text_field :width %>
+ </p>
+ <p>
+ <%= f.label :height %><br />
+ <%= f.text_field :height %>
+ </p>
+ <p>
+ <%= f.submit "Update" %>
+ </p>
+<% end %>
+
+<%= link_to 'Show', @ad_photo %> |
+<%= link_to 'Back', ad_photos_path %>
View
38 app/views/admin/ad_photos/index.html.erb
@@ -0,0 +1,38 @@
+<h1>Listing ad_photos</h1>
+
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Description</th>
+ <th>User</th>
+ <th>Content type</th>
+ <th>Filename</th>
+ <th>Size</th>
+ <th>Parent</th>
+ <th>Thumbnail</th>
+ <th>Width</th>
+ <th>Height</th>
+ </tr>
+
+<% for ad_photo in @ad_photos %>
+ <tr>
+ <td><%=h ad_photo.name %></td>
+ <td><%=h ad_photo.description %></td>
+ <td><%=h ad_photo.user_id %></td>
+ <td><%=h ad_photo.content_type %></td>
+ <td><%=h ad_photo.filename %></td>
+ <td><%=h ad_photo.size %></td>
+ <td><%=h ad_photo.parent_id %></td>
+ <td><%=h ad_photo.thumbnail %></td>
+ <td><%=h ad_photo.width %></td>
+ <td><%=h ad_photo.height %></td>
+ <td><%= link_to 'Show', [:admin, ad_photo] %></td>
+ <td><%= link_to 'Edit', edit_admin_ad_photo_path(ad_photo) %></td>
+ <td><%= link_to 'Destroy', [:admin, ad_photo], :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New ad_photo', new_admin_ad_photo_path %>
View
23 app/views/admin/ad_photos/new.html.erb
@@ -0,0 +1,23 @@
+<h1>Add a New Ad Photo</h1>
+
+<% form_for(:ad_photo, :url => admin_ad_photos_path, :html => {:multipart => true}) do |f| %>
+<p>
+ <%= f.label :name %><br />
+ <%= f.text_field :name %>
+ </p>
+ <p>
+ <b>Select File:</b><br />
+ <%= f.file_field :uploaded_data %>
+ </p>
+
+ <p>
+ <b>Description</b><br />
+ <%= f.text_area :description %>
+ </p>
+
+ <p>
+ <%= f.submit "Upload Photo" %>
+ </p>
+<% end %>
+
+<%= link_to 'Back', admin_ad_photos_path %>
View
55 app/views/admin/ad_photos/show.html.erb
@@ -0,0 +1,55 @@
+
+<p>
+ <b>Name:</b>
+ <%=h @ad_photo.name %>
+</p>
+
+<p>
+ <b>Description:</b>
+ <%=h @ad_photo.description %>
+</p>
+
+<p>
+ <%= image_tag(@ad_photo.public_filename, :id => "testImage") %></p><p>
+<div id="previewWrap"></div>
+<script type="text/javascript" language="javascript">function onEndCrop( coords, dimensions ) {
+ $( 'x1' ).value = coords.x1;
+ $( 'y1' ).value = coords.y1;
+ $( 'x2' ).value = coords.x2;
+ $( 'y2' ).value = coords.y2;
+ $( 'width' ).value = dimensions.width;
+ $( 'height' ).value = dimensions.height;
+};
+ Event.observe( window, 'load', function() {
+ new Cropper.ImgWithPreview(
+ 'testImage',
+ {
+ previewWrap: 'previewWrap',
+ minWidth: 120,
+ minHeight: 120,
+ ratioDim: { x: 200, y: 120 },
+ onEndCrop: onEndCrop
+ }
+ );
+ } );
+</script>
+</p>
+
+<p>
+<% form_tag(crop_and_close_admin_ad_photo_path) do |f| -%>
+
+
+ <%= text_field_tag :x1 %>
+ <%= text_field_tag :y1 %>
+ <%= text_field_tag :x2 %>
+ <%= text_field_tag :y2 %>
+ <%= text_field_tag :width %>
+ <%= text_field_tag :height %>
+ <%= submit_tag "Crop Image" %>
+ <% end -%>
+</p>
+
+
+
+<%= link_to 'Edit', edit_admin_ad_photo_path(@ad_photo) %> |
+<%= link_to 'Back', admin_ad_photos_path %>
View
12 app/views/admin/affiliate_links/_form_fields.html.erb
@@ -0,0 +1,12 @@
+<%= f.error_messages %>
+ <p>
+ <%= f.label :link_type %><br />
+ <%= f.select :link_type, AffiliateLink::LINK_TYPES %>
+ </p>
+ <p>
+ <%= f.label :ad_text %><br />
+ <%= f.text_field :ad_text %>
+ </p>
+ <p>
+ <%= f.submit button_name %>
+ </p>
View
8 app/views/admin/affiliate_links/edit.html.erb
@@ -0,0 +1,8 @@
+<h1>Editing affiliate_link</h1>
+
+<% form_for([:admin, @affiliate_link]) do |f| %>
+ <%= render :partial => 'form_fields', :locals => {:f => f, :button_name => "Update"}%>
+<% end %>
+
+<%= link_to 'Show', [:admin, @affiliate_link] %> |
+<%= link_to 'Back', admin_affiliate_links_path %>
View
24 app/views/admin/affiliate_links/index.html.erb
@@ -0,0 +1,24 @@
+<h1>Listing Affiliate Links</h1>
+See your Affiliate Settings <%= link_to "here", admin_affiliate_setting_path(@affiliate_setting) %>
+<table>
+ <tr>
+ <th>Link Code</th>
+ <th>Link Type</th>
+ <th>Text in Ad</th>
+ </tr>
+
+<% for affiliate_link in @affiliate_links %>
+ <tr>
+ <td><%=h display_link(affiliate_link.ad_text, 1, 1) %></td>
+ <td><%=h affiliate_link.link_type %></td>
+ <td><%=h affiliate_link.ad_text %></td>
+ <td><%= link_to 'Show', affiliate_link %></td>
+ <td><%= link_to 'Edit', edit_affiliate_link_path(affiliate_link) %></td>
+ <td><%= link_to 'Destroy', affiliate_link, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
+<br />
+
+<%= link_to 'New affiliate_link', new_admin_affiliate_link_path %>
View
9 app/views/admin/affiliate_links/new.html.erb
@@ -0,0 +1,9 @@
+<h1>New affiliate_link</h1>
+
+<% form_for([:admin, @affiliate_link]) do |f| %>
+
+ <%= render :partial => 'form_fields', :locals => {:f => f, :button_name => "Create"}%>
+
+<% end %>
+
+<%= link_to 'Back', admin_affiliate_links_path %>
View
14 app/views/admin/affiliate_links/show.html.erb
@@ -0,0 +1,14 @@
+<h1>Affiliate Link</h1>
+<p>
+ <b>Link type:</b>
+ <%=h @affiliate_link.link_type %>
+</p>
+
+<p>
+ <b>Ad text:</b>
+ <%=h @affiliate_link.ad_text %>
+</p>
+
+
+<%= link_to 'Edit', edit_admin_affiliate_link_path(@affiliate_link) %> |
+<%= link_to 'Back', admin_affiliate_links_path %>
View
9 app/views/admin/affiliate_settings/_form_fields.html.erb
@@ -0,0 +1,9 @@
+ <%= f.error_messages %>
+
+ <p>
+ <%= f.label :affiliate_percentage %><br />
+ <%= f.select :affiliate_percentage, AffiliateSetting::PERCENTAGES %>
+ </p>
+ <p>
+ <%= f.submit button_name %>
+ </p>
View
8 app/views/admin/affiliate_settings/edit.html.erb
@@ -0,0 +1,8 @@
+<h1>Editing affiliate_setting</h1>
+
+<% form_for([:admin, @affiliate_setting]) do |f| %>
+<%= render :partial => 'form_fields', :locals => {:f => f, :button_name => "Update"}%>
+<% end %>
+
+<%= link_to 'Show', [:admin, @affiliate_setting] %> |
+<%= link_to 'Back', admin_affiliate_settings_path %>
View
9 app/views/admin/affiliate_settings/index.html.erb
@@ -0,0 +1,9 @@
+<h1>Your Affiliate Settings</h1>
+
+
+
+ <p>Your affiliates will get <%=h @affiliate_setting.affiliate_percentage %> of each applicable sale.</p>
+
+ <p>Click here to <%= link_to 'Edit', edit_admin_affiliate_setting_path(@affiliate_setting) %> this setting.</p>
+
+
View
8 app/views/admin/affiliate_settings/new.html.erb
@@ -0,0 +1,8 @@
+<h1>New affiliate_setting</h1>
+
+<% form_for([:admin, @affiliate_setting]) do |f| %>
+<%= render :partial => 'form_fields', :locals => {:f => f, :button_name => "Create"}%>
+
+<% end %>
+
+<%= link_to 'Back', admin_affiliate_settings_path %>
View
7 app/views/admin/affiliate_settings/show.html.erb
@@ -0,0 +1,7 @@
+<h1>Your Affiliate Settings</h1>
+
+
+
+ <p>Your affiliates will get <%=h @affiliate_setting.affiliate_percentage %>% of each applicable sale.</p>
+
+ <p>Click here to <%= link_to 'Edit', edit_admin_affiliate_setting_path(@affiliate_setting) %> this setting.</p>
View
2 app/views/admin/affiliates/index.html.erb
@@ -1,5 +1,5 @@
<h1>Affiliate Management</h1>
-<p>Edit your Affiliate Settings <%= link_to "here", root_url %> </p>
+<p>Edit your Affiliate Settings <%= link_to "here", root_path %> </p>
<p>The following is a list of users who are affiliates in your affiliate program</p>
<table>
<tr>
View
24 app/views/affiliate_links/edit.html.erb
@@ -0,0 +1,24 @@
+<h1>Editing affiliate_link</h1>
+
+<% form_for(@affiliate_link) do |f| %>
+ <%= f.error_messages %>
+
+ <p>
+ <%= f.label :affiliate_id %><br />
+ <%= f.text_field :affiliate_id %>
+ </p>
+ <p>
+ <%= f.label :link_type %><br />
+ <%= f.text_field :link_type %>
+ </p>
+ <p>
+ <%= f.label :ad_text %><br />
+ <%= f.text_field :ad_text %>
+ </p>
+ <p>
+ <%= f.submit "Update" %>
+ </p>
+<% end %>
+
+<%= link_to 'Show', @affiliate_link %> |
+<%= link_to 'Back', affiliate_links_path %>
View
21 app/views/affiliate_links/index.html.erb
@@ -0,0 +1,21 @@
+<h1>Listing affiliate_links</h1>
+<%= will_paginate @affiliate_links %>
+<table>
+ <tr>
+ <th>Affiliate</th>
+ <th>Link type</th>
+ <th>Ad text</th>
+ </tr>
+
+<% for affiliate_link in @affiliate_links %>
+ <tr>
+ <td><%=h display_link(affiliate_link.ad_text, @affiliate.affiliate_code) %></td>
+ <td><%=h affiliate_link.link_type %></td>
+ <td><%=h affiliate_link.ad_text %></td>
+ <td><%= link_to 'Show', affiliate_link %></td>
+ <td><%= link_to 'Edit', edit_affiliate_link_path(affiliate_link) %></td>
+ <td><%= link_to 'Destroy', affiliate_link, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+<% end %>
+</table>
+
View
18 app/views/affiliate_links/new.html.erb
@@ -0,0 +1,18 @@
+<h1>New affiliate_link</h1>
+
+<% form_for(@affiliate_links) do |f| %>
+ <%= f.error_messages %>
+ <p>
+ <%= f.label :link_type %><br />
+ <%= f.collection_select( :link_type, AffiliateLink::LINK_TYPES, :link_type, :link_type, {:prompt => true}) %>
+ </p>
+ <p>
+ <%= f.label :ad_text %><br />
+ <%= f.text_field :ad_text %>
+ </p>
+ <p>
+ <%= f.submit "Create" %>
+ </p>
+<% end %>
+
+<%= link_to 'Back', affiliate_links_path %>
View
18 app/views/affiliate_links/show.html.erb
@@ -0,0 +1,18 @@
+<p>
+ <b>Affiliate:</b>
+ <%=h @affiliate_link.affiliate_id %>
+</p>
+
+<p>
+ <b>Link type:</b>
+ <%=h @affiliate_link.link_type %>
+</p>
+
+<p>
+ <b>Ad text:</b>
+ <%=h @affiliate_link.ad_text %>
+</p>
+
+
+<%= link_to 'Edit', edit_affiliate_link_path(@affiliate_link) %> |
+<%= link_to 'Back', affiliate_links_path %>
View
15 db/migrate/20090311213330_create_affiliates.rb
@@ -0,0 +1,15 @@
+class CreateAffiliates < ActiveRecord::Migration
+ def self.up
+ create_table :affiliates do |t|
+ t.integer :user_id
+ t.string :paypal_email
+ t.integer :account_id
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :affiliates
+ end
+end
View
16 db/migrate/20090315142419_create_affiliate_settings.rb
@@ -0,0 +1,16 @@
+class CreateAffiliateSettings < ActiveRecord::Migration
+ def self.up
+ create_table :affiliate_settings do |t|
+ t.integer :user_id
+ t.integer :affiliate_id
+ t.integer :account_id
+ t.integer :affiliate_percentage
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :affiliate_settings
+ end
+end
View
15 db/migrate/20090315165921_create_affiliate_links.rb
@@ -0,0 +1,15 @@
+class CreateAffiliateLinks < ActiveRecord::Migration
+ def self.up
+ create_table :affiliate_links do |t|
+ t.integer :affiliate_id
+ t.string :link_type
+ t.string :ad_text
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :affiliate_links
+ end
+end
View
9 db/migrate/20090315165922_adding_to_affiliate_links.rb
@@ -0,0 +1,9 @@
+class AddingToAffiliateLinks < ActiveRecord::Migration
+ def self.up
+ add_column :affiliate_links, :account_id, :integer
+ end
+
+ def self.down
+ remove_column :affiliate_links, :account_id
+ end
+end
View
22 db/migrate/20090319121342_create_ad_photos.rb
@@ -0,0 +1,22 @@
+class CreateAdPhotos < ActiveRecord::Migration
+ def self.up
+ create_table :ad_photos do |t|
+ t.string :name
+ t.text :description
+ t.integer :user_id
+ t.string :content_type
+ t.string :filename
+ t.integer :size
+ t.integer :parent_id
+ t.string :thumbnail
+ t.integer :width
+ t.integer :height
+
+ t.timestamps
+ end
+ end
+
+ def self.down
+ drop_table :ad_photos
+ end
+end
View
7 routes.rb
@@ -1,7 +1,8 @@
-# Add your custom routes here. If in config/routes.rb you would
-# add <tt>map.resources</tt>, here you would add just <tt>resources</tt>
-
resources :affiliates
+resources :affiliate_links
namespace :admin do |admin|
admin.resources :affiliates
+ admin.resources :affiliate_settings
+ admin.resources :affiliate_links
+ admin.resources :ad_photos, :member => {:crop_and_close => :post}
end

0 comments on commit d8a7f6a

Please sign in to comment.