Permalink
Browse files

Documents added

  • Loading branch information...
1 parent b4846dc commit 636487363d1a51ba43872d95a179f91bc9ea3110 @metamn committed Apr 27, 2012
@@ -0,0 +1,7 @@
+class DocumentsController < ApplicationController
+
+ hobo_model_controller
+
+ auto_actions :all
+
+end
View
@@ -10,9 +10,13 @@ class Campaign < ActiveRecord::Base
end
belongs_to :project
+
has_many :tasks, :dependent => :destroy
children :tasks
+ has_many :documents, :dependent => :destroy, :accessible => :true
+
+
# --- Permissions --- #
def create_permitted?
View
@@ -0,0 +1,34 @@
+class Document < ActiveRecord::Base
+
+ hobo_model # Don't put anything above this
+
+ fields do
+ title :string
+ url :string
+ description :text
+ timestamps
+ end
+
+ belongs_to :project
+ belongs_to :campaign
+ belongs_to :task
+
+ # --- Permissions --- #
+
+ def create_permitted?
+ acting_user.administrator?
+ end
+
+ def update_permitted?
+ acting_user.administrator?
+ end
+
+ def destroy_permitted?
+ acting_user.administrator?
+ end
+
+ def view_permitted?(field)
+ true
+ end
+
+end
View
@@ -10,7 +10,9 @@ class Project < ActiveRecord::Base
has_many :campaigns, :dependent => :destroy
children :campaigns
-
+
+ has_many :documents, :dependent => :destroy, :accessible => :true
+
# --- Permissions --- #
def create_permitted?
View
@@ -10,9 +10,11 @@ class Task < ActiveRecord::Base
end
belongs_to :campaign
+
has_many :task_assignments, :dependent => :destroy
has_many :users, :through => :task_assignments
+ has_many :documents, :dependent => :destroy, :accessible => :true
# --- Permissions --- #
@@ -26,5 +26,9 @@
<nav-item with="&Project"><ht key="project.nav_item" count="100"><model-name-human count="100"/></ht></nav-item>
<nav-item with="&Campaign"><ht key="campaign.nav_item" count="100"><model-name-human count="100"/></ht></nav-item>
<nav-item with="&Task"><ht key="task.nav_item" count="100"><model-name-human count="100"/></ht></nav-item>
+ <nav-item with="&Document"><ht key="document.nav_item" count="100"><model-name-human count="100"/></ht></nav-item>
</navigation>
</def>
+
+
+
@@ -14,6 +14,17 @@
</card>
</def>
+<def tag="card" for="Document">
+ <card class="document" param="default" merge>
+ <header: param>
+ <h4 param="heading"><name/></h4>
+ </header:>
+ <body: param>
+ <view:description param="description"/>
+ </body:>
+ </card>
+</def>
+
<def tag="card" for="Project">
<card class="project" param="default" merge>
<header: param>
@@ -13,6 +13,14 @@
</card>
</def>
+<def tag="card" for="Document">
+ <card class="document" param="default" merge>
+ <header: param>
+ <h4 param="heading"><a><name/></a></h4>
+ </header:>
+ </card>
+</def>
+
<def tag="card" for="Project">
<card class="project" param="default" merge>
<header: param>
@@ -3,7 +3,7 @@
<def tag="form" for="Campaign">
<form merge param="default">
<error-messages param/>
- <field-list fields="name, description, status, project" param/>
+ <field-list fields="name, description, status, documents, project" param/>
<div param="actions">
<submit label="#{ht 'campaign.actions.save', :default=>['Save']}" param/><or-cancel param="cancel"/>
</div>
@@ -12,10 +12,22 @@
+<def tag="form" for="Document">
+ <form merge param="default">
+ <error-messages param/>
+ <field-list fields="title, url, description, campaign, project, task" param/>
+ <div param="actions">
+ <submit label="#{ht 'document.actions.save', :default=>['Save']}" param/><or-cancel param="cancel"/>
+ </div>
+ </form>
+</def>
+
+
+
<def tag="form" for="Project">
<form merge param="default">
<error-messages param/>
- <field-list fields="name, description" param/>
+ <field-list fields="name, description, documents" param/>
<div param="actions">
<submit label="#{ht 'project.actions.save', :default=>['Save']}" param/><or-cancel param="cancel"/>
</div>
@@ -27,7 +39,7 @@
<def tag="form" for="Task">
<form merge param="default">
<error-messages param/>
- <field-list fields="name, description, status, campaign" param/>
+ <field-list fields="name, description, status, campaign, documents" param/>
<div param="actions">
<submit label="#{ht 'task.actions.save', :default=>['Save']}" param/><or-cancel param="cancel"/>
</div>
@@ -6,6 +6,7 @@
<navigation class="main-nav" merge-attrs param="default">
<nav-item href="#{base_url}/">Home</nav-item>
<nav-item with="&Campaign"><ht key="campaign.nav_item" count="100"><model-name-human count="100"/></ht></nav-item>
+ <nav-item with="&Document"><ht key="document.nav_item" count="100"><model-name-human count="100"/></ht></nav-item>
<nav-item with="&Project"><ht key="project.nav_item" count="100"><model-name-human count="100"/></ht></nav-item>
<nav-item with="&Task"><ht key="task.nav_item" count="100"><model-name-human count="100"/></ht></nav-item>
</navigation>
@@ -83,7 +84,6 @@
<content: param>
<header param="content-header">
- <a:project param="parent-link">&laquo; <ht key="campaign.actions.back_to_parent" parent="Project" name="&this">Back to <name/></ht></a:project>
<h2 param="heading">
<ht key="campaign.show.heading" name="#{name(:no_wrapper => true)}">
Campaign <name/>
@@ -101,7 +101,7 @@
<section param="content-body">
<view:description param="description" />
- <field-list fields="status" param/>
+ <field-list fields="status, project" param/>
<section param="collection-section">
<h3 param="collection-heading">
<ht key="task.collection.heading" count="&this.tasks.count" >
@@ -189,6 +189,128 @@
+<!-- ====== Document Pages ====== -->
+
+<def tag="index-page" for="Document">
+ <page merge title="#{ht 'document.index.title', :default=>[model.model_name.human(:count=>100)] }">
+ <body: class="index-page document" param/>
+
+ <content: param>
+ <header param="content-header">
+ <h2 param="heading">
+ <ht key="document.index.heading">
+ <model-name-human model="&model"/>
+ </ht>
+ </h2>
+
+ <p param="count" if>
+ <ht key="document.collection.count" count="&collection_count">
+ <count summary/>
+ </ht>
+ </p>
+ </header>
+
+ <section param="content-body">
+ <a action="new" to="&model" param="new-link">
+ <ht key="document.actions.new">New Document</ht>
+ </a>
+
+ <page-nav param="top-page-nav"/>
+
+ <collection param/>
+
+ <page-nav param="bottom-page-nav"/>
+
+
+ </section>
+ </content:>
+ </page>
+</def>
+
+
+<def tag="new-page" for="Document">
+ <page merge title="#{ht 'document.new.title', :default=>[' New Document'] }">
+ <body: class="new-page document" param/>
+
+ <content: param>
+ <section param="content-header">
+ <h2 param="heading">
+ <ht key="document.new.heading">
+ New Document
+ </ht>
+ </h2>
+ </section>
+
+ <section param="content-body">
+ <form param>
+ <submit: label="#{ht 'document.actions.create', :default=>['Create Document']}"/>
+ </form>
+ </section>
+ </content:>
+ </page>
+</def>
+
+
+<def tag="show-page" for="Document">
+ <page merge title="#{ht 'document.show.title', :default=>['Document'], :name => name(:no_wrapper => true) }">
+
+ <body: class="show-page document" param/>
+
+ <content: param>
+ <header param="content-header">
+ <a:campaign param="parent-link">&laquo; <ht key="document.actions.back_to_parent" parent="Campaign" name="&this">Back to <name/></ht></a:campaign>
+ <h2 param="heading">
+ <ht key="document.show.heading" name="#{name(:no_wrapper => true)}">
+ Document <name/>
+ </ht>
+ </h2>
+
+ <record-flags fields="" param/>
+
+ <a action="edit" if="&can_edit?" param="edit-link">
+ <ht key="document.actions.edit" name="#{name(:no_wrapper => true)}">
+ Edit Document
+ </ht>
+ </a>
+ </header>
+
+ <section param="content-body">
+ <view:description param="description" />
+ <field-list fields="url, project, task" param/>
+ </section>
+ </content:>
+
+ </page>
+</def>
+
+
+<def tag="edit-page" for="Document">
+ <page merge title="#{ht 'document.edit.title', :default=>['Edit Document'], :name => name(:no_wrapper => true) }">
+
+ <body: class="edit-page document" param/>
+
+ <content:>
+ <section param="content-header">
+ <h2 param="heading">
+ <ht key="document.edit.heading" name="#{name(:no_wrapper => true)}">
+ Edit Document
+ </ht>
+ </h2>
+ <delete-button label="#{ht 'document.actions.delete', :default=>['Remove This Document']}" param/>
+ </section>
+
+ <section param="content-body">
+ <form param/>
+ </section>
+ </content:>
+
+ </page>
+</def>
+
+
+
+
+
<!-- ====== Project Pages ====== -->
<def tag="index-page" for="Project">
View
@@ -32,6 +32,16 @@
post 'projects/:project_id/campaigns(.:format)' => 'campaigns#create_for_project', :as => 'create_campaign_for_project'
+ # Resource routes for controller "documents"
+ get 'documents(.:format)' => 'documents#index', :as => 'documents'
+ get 'documents/new(.:format)', :as => 'new_document'
+ get 'documents/:id/edit(.:format)' => 'documents#edit', :as => 'edit_document'
+ get 'documents/:id(.:format)' => 'documents#show', :as => 'document', :constraints => { :id => %r([^/.?]+) }
+ post 'documents(.:format)' => 'documents#create', :as => 'create_document'
+ put 'documents/:id(.:format)' => 'documents#update', :as => 'update_document', :constraints => { :id => %r([^/.?]+) }
+ delete 'documents/:id(.:format)' => 'documents#destroy', :as => 'destroy_document', :constraints => { :id => %r([^/.?]+) }
+
+
# Lifecycle routes for controller "users"
put 'users/:id/accept_invitation(.:format)' => 'users#do_accept_invitation', :as => 'do_user_accept_invitation'
get 'users/:id/accept_invitation(.:format)' => 'users#accept_invitation', :as => 'user_accept_invitation'
@@ -0,0 +1,21 @@
+class HoboMigration2 < ActiveRecord::Migration
+ def self.up
+ create_table :documents do |t|
+ t.string :title
+ t.string :url
+ t.text :description
+ t.datetime :created_at
+ t.datetime :updated_at
+ t.integer :project_id
+ t.integer :campaign_id
+ t.integer :task_id
+ end
+ add_index :documents, [:project_id]
+ add_index :documents, [:campaign_id]
+ add_index :documents, [:task_id]
+ end
+
+ def self.down
+ drop_table :documents
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120427073239) do
+ActiveRecord::Schema.define(:version => 20120427092441) do
create_table "campaigns", :force => true do |t|
t.string "name"
@@ -24,6 +24,21 @@
add_index "campaigns", ["project_id"], :name => "index_campaigns_on_project_id"
+ create_table "documents", :force => true do |t|
+ t.string "title"
+ t.string "url"
+ t.text "description"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ t.integer "project_id"
+ t.integer "campaign_id"
+ t.integer "task_id"
+ end
+
+ add_index "documents", ["campaign_id"], :name => "index_documents_on_campaign_id"
+ add_index "documents", ["project_id"], :name => "index_documents_on_project_id"
+ add_index "documents", ["task_id"], :name => "index_documents_on_task_id"
+
create_table "projects", :force => true do |t|
t.string "name"
t.text "description"
Oops, something went wrong.

0 comments on commit 6364873

Please sign in to comment.