| |   |
| 31 | 31 | def show |
| 32 | 32 | end |
| 33 | 33 | |
| 34 | def edit |
| 35 | if @project |
| 36 | # Project article |
| 37 | @article = Article.find_by_id(params[:id], current_user) |
| 38 | if @article |
| 39 | @title = "Editing: " + @project.title + ": " + @article.title |
| 40 | render :action => "ac_project_edit" |
| 41 | else |
| 42 | flash[:error] = "Article not found." |
| 43 | redirect_to project_path(@project) |
| 44 | end |
| 45 | else |
| 46 | # Normal article index page |
| 47 | end |
| 48 | end |
| 49 | |
| 50 | def update |
| 51 | if @project |
| 52 | # Project article |
| 53 | @article = Article.find_by_id(params[:id], current_user) |
| 54 | if @article |
| 55 | #FIXME is this correct?, does deep_clone make one? (if not it should) |
| 56 | original_article = Article.new |
| 57 | original_article = @article.deep_clone |
| 58 | if @article.update_attributes(params[:article]) |
| 59 | @article.save |
| 60 | Journal.update(original_article, @article, request.env["REMOTE_ADDR"], @project.id, current_user.id) |
| 61 | flash[:notice] = "Article was successfully updated." |
| 62 | redirect_to project_articles_path(@project) |
| 63 | else |
| 64 | @title = "Editing: " + @project.title + ": " + @article.title |
| 65 | render :action => "ac_project_edit" |
| 66 | end |
| 67 | else |
| 68 | flash[:error] = "Article not found." |
| 69 | redirect_to project_path(@project) |
| 70 | end |
| 71 | else |
| 72 | # Normal Article |
| 73 | end |
| 74 | end |
| 75 | |
| 76 | def destroy |
| 77 | if @is_member |
| 78 | flash[:notice] = 'Article deleted.' |
| 79 | Article.find(params[:id]).destroy |
| 80 | redirect_to project_articles_path(@project) |
| 81 | end |
| 82 | rescue ActiveRecord::RecordNotFound |
| 83 | flash[:error] = 'Article ' + params[:id] + ' does not exist.' |
| 84 | redirect_to project_articles_path(@project) |
| 85 | end |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 34 | 91 | # Show all articles /2008 or /2008/11 or /2008/11/1 and render grouped by date |
| 35 | 92 | def find_by_date |
| 36 | 93 | @articles = Article.find_by_date(current_user, params[:year], params[:month], params[:day]) |
| toggle raw diff |
--- a/app/controllers/articles_controller.rb
+++ b/app/controllers/articles_controller.rb
@@ -31,6 +31,63 @@ class ArticlesController < ApplicationController
def show
end
+ def edit
+ if @project
+ # Project article
+ @article = Article.find_by_id(params[:id], current_user)
+ if @article
+ @title = "Editing: " + @project.title + ": " + @article.title
+ render :action => "ac_project_edit"
+ else
+ flash[:error] = "Article not found."
+ redirect_to project_path(@project)
+ end
+ else
+ # Normal article index page
+ end
+ end
+
+ def update
+ if @project
+ # Project article
+ @article = Article.find_by_id(params[:id], current_user)
+ if @article
+ #FIXME is this correct?, does deep_clone make one? (if not it should)
+ original_article = Article.new
+ original_article = @article.deep_clone
+ if @article.update_attributes(params[:article])
+ @article.save
+ Journal.update(original_article, @article, request.env["REMOTE_ADDR"], @project.id, current_user.id)
+ flash[:notice] = "Article was successfully updated."
+ redirect_to project_articles_path(@project)
+ else
+ @title = "Editing: " + @project.title + ": " + @article.title
+ render :action => "ac_project_edit"
+ end
+ else
+ flash[:error] = "Article not found."
+ redirect_to project_path(@project)
+ end
+ else
+ # Normal Article
+ end
+ end
+
+ def destroy
+ if @is_member
+ flash[:notice] = 'Article deleted.'
+ Article.find(params[:id]).destroy
+ redirect_to project_articles_path(@project)
+ end
+ rescue ActiveRecord::RecordNotFound
+ flash[:error] = 'Article ' + params[:id] + ' does not exist.'
+ redirect_to project_articles_path(@project)
+ end
+
+
+
+
+
# Show all articles /2008 or /2008/11 or /2008/11/1 and render grouped by date
def find_by_date
@articles = Article.find_by_date(current_user, params[:year], params[:month], params[:day]) |
| |   |
| 115 | 115 | original_wiki = Wiki.new |
| 116 | 116 | original_wiki = @wiki.deep_clone |
| 117 | 117 | if @wiki.update_attributes(params[:wiki]) |
| 118 | @wiki.save |
| 118 | 119 | Journal.update(original_wiki, @wiki, request.env["REMOTE_ADDR"], @project.id, current_user.id) |
| 119 | 120 | flash[:notice] = "Wiki was successfully updated." |
| 120 | 121 | @title = @wiki.title |
| … | … | |
| 140 | 140 | end |
| 141 | 141 | end |
| 142 | 142 | |
| 143 | def destroy |
| 144 | if @is_member |
| 145 | flash[:notice] = 'Wiki deleted.' |
| 146 | Wiki.find(params[:id]).destroy |
| 147 | redirect_to project_wikis_path(@project) |
| 148 | end |
| 149 | rescue ActiveRecord::RecordNotFound |
| 150 | flash[:error] = 'Wiki ' + params[:id] + ' does not exist.' |
| 151 | redirect_to project_wikis_path(@project) |
| 152 | end |
| 153 | |
| 154 | |
| 143 | 155 | #FIXME |
| 144 | 156 | def to_slug(s) |
| 145 | 157 | s.gsub(/\W+/, ' ').strip.downcase.gsub(/\ +/, '-') |
| toggle raw diff |
--- a/app/controllers/wikis_controller.rb
+++ b/app/controllers/wikis_controller.rb
@@ -115,6 +115,7 @@ class WikisController < ApplicationController
original_wiki = Wiki.new
original_wiki = @wiki.deep_clone
if @wiki.update_attributes(params[:wiki])
+ @wiki.save
Journal.update(original_wiki, @wiki, request.env["REMOTE_ADDR"], @project.id, current_user.id)
flash[:notice] = "Wiki was successfully updated."
@title = @wiki.title
@@ -139,6 +140,18 @@ class WikisController < ApplicationController
end
end
+ def destroy
+ if @is_member
+ flash[:notice] = 'Wiki deleted.'
+ Wiki.find(params[:id]).destroy
+ redirect_to project_wikis_path(@project)
+ end
+ rescue ActiveRecord::RecordNotFound
+ flash[:error] = 'Wiki ' + params[:id] + ' does not exist.'
+ redirect_to project_wikis_path(@project)
+ end
+
+
#FIXME
def to_slug(s)
s.gsub(/\W+/, ' ').strip.downcase.gsub(/\ +/, '-') |
| |   |
| 108 | 108 | out << actionbox_complex(:allow_shortcuts => true, :new_project_wiki => true) |
| 109 | 109 | else |
| 110 | 110 | out << actionbox_complex(:allow_shortcuts => true, :edit_project_wiki => true, :new_project_wiki => true, :list_project_wikis => true) |
| 111 | out << render_right_project_extrainfo |
| 112 | out << render_right_project_contributors |
| 111 | 113 | end |
| 112 | | out << render_right_project_extrainfo |
| 113 | | out << render_right_project_contributors |
| 114 | 114 | when PRJ_TAB_ACTIVITIES |
| 115 | 115 | out << actionbox_basic(:allow_shortcuts => true) |
| 116 | 116 | out << render(:partial => "ac_right_actionbox_post_message") if @is_member |
| … | … | |
| 138 | 138 | out << actionbox_complex(:allow_shortcuts => true, :new_ticket => true) |
| 139 | 139 | out << render(:partial => "ac_right_ticket_filter") |
| 140 | 140 | when PRJ_TAB_ARTICLES |
| 141 | | out << actionbox_complex(:allow_shortcuts => true, :new_article => true) |
| 141 | case subtab |
| 142 | when PRJ_TAB_ARTICLES_EDIT, PRJ_TAB_ARTICLES_NEW |
| 143 | out << actionbox_basic(:allow_shortcuts => true) |
| 144 | else |
| 145 | out << actionbox_complex(:allow_shortcuts => true, :new_article => true) |
| 146 | end |
| 142 | 147 | when PRJ_TAB_FORUM |
| 143 | 148 | out << actionbox_basic(:allow_shortcuts => true) |
| 144 | 149 | when PRJ_TAB_LOG |
| toggle raw diff |
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -108,9 +108,9 @@ module ProjectsHelper
out << actionbox_complex(:allow_shortcuts => true, :new_project_wiki => true)
else
out << actionbox_complex(:allow_shortcuts => true, :edit_project_wiki => true, :new_project_wiki => true, :list_project_wikis => true)
+ out << render_right_project_extrainfo
+ out << render_right_project_contributors
end
- out << render_right_project_extrainfo
- out << render_right_project_contributors
when PRJ_TAB_ACTIVITIES
out << actionbox_basic(:allow_shortcuts => true)
out << render(:partial => "ac_right_actionbox_post_message") if @is_member
@@ -138,7 +138,12 @@ module ProjectsHelper
out << actionbox_complex(:allow_shortcuts => true, :new_ticket => true)
out << render(:partial => "ac_right_ticket_filter")
when PRJ_TAB_ARTICLES
- out << actionbox_complex(:allow_shortcuts => true, :new_article => true)
+ case subtab
+ when PRJ_TAB_ARTICLES_EDIT, PRJ_TAB_ARTICLES_NEW
+ out << actionbox_basic(:allow_shortcuts => true)
+ else
+ out << actionbox_complex(:allow_shortcuts => true, :new_article => true)
+ end
when PRJ_TAB_FORUM
out << actionbox_basic(:allow_shortcuts => true)
when PRJ_TAB_LOG |
| |   |
| 28 | 28 | return at.to_s.capitalize |
| 29 | 29 | end |
| 30 | 30 | end |
| 31 | | |
| 31 | |
| 32 | def deep_clone |
| 33 | Marshal::load(Marshal.dump(self)) |
| 34 | end |
| 35 | |
| 32 | 36 | protected |
| 33 | 37 | |
| 34 | 38 | |
| … | … | |
| 81 | 81 | @projects = Project.list_for_user(curruser) |
| 82 | 82 | find(:all, :conditions => ["status = '#{:published}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC", :limit => 3) |
| 83 | 83 | end |
| 84 | |
| 85 | # finds articles for a user based on the user slug e.g. /profiles/test-user/articles |
| 86 | def self.find_by_id (id, curruser) |
| 87 | @projects = Project.list_for_user(curruser) |
| 88 | find(:first, :conditions => ["status = '#{:published}' AND id = '#{id}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"]) |
| 89 | end |
| 84 | 90 | |
| 85 | 91 | # finds articles for a user based on the user slug e.g. /profiles/test-user/articles |
| 86 | 92 | def self.find_by_user (user_id, curruser) |
| toggle raw diff |
--- a/app/models/article.rb
+++ b/app/models/article.rb
@@ -28,7 +28,11 @@ class Article < ActiveRecord::Base
return at.to_s.capitalize
end
end
-
+
+ def deep_clone
+ Marshal::load(Marshal.dump(self))
+ end
+
protected
@@ -77,6 +81,12 @@ protected
@projects = Project.list_for_user(curruser)
find(:all, :conditions => ["status = '#{:published}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"], :order => "created_at DESC", :limit => 3)
end
+
+ # finds articles for a user based on the user slug e.g. /profiles/test-user/articles
+ def self.find_by_id (id, curruser)
+ @projects = Project.list_for_user(curruser)
+ find(:first, :conditions => ["status = '#{:published}' AND id = '#{id}' AND ( audience = '#{:public}' OR project_id IN (" << @projects << ") )"])
+ end
# finds articles for a user based on the user slug e.g. /profiles/test-user/articles
def self.find_by_user (user_id, curruser) |
| |   |
| 0 | | <p> |
| 1 | | <%= form.label :title -%><br /> |
| 2 | | <%= form.text_field :title, :class => "text" -%> |
| 3 | | </p> |
| 4 | | <% unless ["edit", "update"].include?(controller.action_name) -%> |
| 5 | | <p> |
| 6 | | <%= form.label :slug, "Slug (for urls etc)" -%><br /> |
| 7 | | <%= form.text_field :slug, :class => "text" -%> |
| 8 | | </p> |
| 9 | | <script type="text/javascript" charset="utf-8"> |
| 10 | | var slugger = new ProjectSluggorizer("project_title", "project_slug"); |
| 11 | | </script> |
| 12 | | <% end -%> |
| 13 | | <p> |
| 14 | | <%= form.label :tag_list, "Categories (space seperated)" -%><br /> |
| 15 | | <%= form.text_field :tag_list, :class => "text" -%> |
| 16 | | </p> |
| 17 | | <p> |
| 18 | | <%= form.label :license -%><br /> |
| 19 | | <%= form.select :license, Project::LICENSES -%> |
| 20 | | </p> |
| 21 | | <p> |
| 22 | | <%= form.label :home_url, "Home URL (eg Rubyforge etc)" -%><br /> |
| 23 | | <%= form.text_field :home_url, :class => "text" -%> |
| 24 | | </p> |
| 25 | | <p> |
| 26 | | <%= form.label :mailinglist_url, "Mailinglist URL (if any)" -%><br /> |
| 27 | | <%= form.text_field :mailinglist_url, :class => "text" -%> |
| 28 | | </p> |
| 29 | | <p> |
| 30 | | <%= form.label :bugtracker_url, "Bugtracker URL (if any)" -%><br /> |
| 31 | | <%= form.text_field :bugtracker_url, :class => "text" -%> |
| 32 | | </p> |
| 33 | | <p> |
| 34 | | <%= form.label :description -%><br /> |
| 35 | | <small class="hint"> |
| 36 | | <a href="http://daringfireball.net/projects/markdown/">Markdown</a> and |
| 37 | | basic html is allowed |
| 38 | | </small><br /> |
| 39 | | <%= form.text_area :description, :class => "text wide tall" -%> |
| 40 | | </p> |
| toggle raw diff |
--- a/app/views/articles/_ac_form.html.erb
+++ b/app/views/articles/_ac_form.html.erb
@@ -1,41 +0,0 @@
-<p>
- <%= form.label :title -%><br />
- <%= form.text_field :title, :class => "text" -%>
-</p>
-<% unless ["edit", "update"].include?(controller.action_name) -%>
- <p>
- <%= form.label :slug, "Slug (for urls etc)" -%><br />
- <%= form.text_field :slug, :class => "text" -%>
- </p>
- <script type="text/javascript" charset="utf-8">
- var slugger = new ProjectSluggorizer("project_title", "project_slug");
- </script>
-<% end -%>
-<p>
- <%= form.label :tag_list, "Categories (space seperated)" -%><br />
- <%= form.text_field :tag_list, :class => "text" -%>
-</p>
-<p>
- <%= form.label :license -%><br />
- <%= form.select :license, Project::LICENSES -%>
-</p>
-<p>
- <%= form.label :home_url, "Home URL (eg Rubyforge etc)" -%><br />
- <%= form.text_field :home_url, :class => "text" -%>
-</p>
-<p>
- <%= form.label :mailinglist_url, "Mailinglist URL (if any)" -%><br />
- <%= form.text_field :mailinglist_url, :class => "text" -%>
-</p>
-<p>
- <%= form.label :bugtracker_url, "Bugtracker URL (if any)" -%><br />
- <%= form.text_field :bugtracker_url, :class => "text" -%>
-</p>
-<p>
- <%= form.label :description -%><br />
- <small class="hint">
- <a href="http://daringfireball.net/projects/markdown/">Markdown</a> and
- basic html is allowed
- </small><br />
- <%= form.text_area :description, :class => "text wide tall" -%>
-</p>
\ No newline at end of file |
| |   |
| 5 | 5 | |
| 6 | 6 | <%= div_formattedtext_open %> |
| 7 | 7 | |
| 8 | | <%= error_messages_for :wiki %> |
| 8 | <%= error_messages_for :article %> |
| 9 | 9 | |
| 10 | | <% form_for :wiki, :url => project_wiki_path(@project.slug, @wiki.slug), :html => {:method => :put, :name => 'editwiki', :id => 'input'} do |f| -%> |
| 10 | <% form_for :article, :url => project_article_path(@project.slug, @article.id), :html => {:method => :put, :name => 'editarticle', :id => 'input'} do |f| -%> |
| 11 | 11 | |
| 12 | 12 | <h2><%= @title %></h2> |
| 13 | 13 | |
| 14 | 14 | <p>The wiki title is automatically prefixed with the project title when the wiki is displayed.</p> |
| 15 | 15 | |
| 16 | | <%= render :partial => "ac_form", :locals => { :f => f } %> |
| 16 | <%= render :partial => "ac_form" %> |
| 17 | 17 | |
| 18 | 18 | <p> |
| 19 | | <%= f.label :slug -%><br/> |
| 20 | | <%= f.text_field :slug -%> |
| 19 | <%= f.label :title -%><br/> |
| 20 | <%= f.text_field :title -%> |
| 21 | 21 | </p> |
| 22 | 22 | |
| 23 | 23 | <p> |
| 24 | | <%= link_to "Cancel", project_wiki_path(@project.slug, @wiki.slug) %> |
| 25 | | <a href="javascript:document.editwiki.submit();">Preview</a> |
| 26 | | <a href="javascript:document.editwiki.submit();">Update</a> |
| 24 | <%= f.label :body -%><br/> |
| 25 | <%= f.text_area :body, :rows => 20 -%> |
| 26 | </p> |
| 27 | |
| 28 | <p> |
| 29 | <%= f.label :body_summary -%><br/> |
| 30 | <%= f.text_area :body_summary, :rows => 10 -%> |
| 31 | </p> |
| 32 | |
| 33 | <p> |
| 34 | <%= f.label :permalink -%><br/> |
| 35 | <%= f.text_field :permalink -%> |
| 36 | </p> |
| 37 | |
| 38 | <p> |
| 39 | <%= link_to "Cancel", project_articles_path(@project.slug) %> |
| 40 | <a href="javascript:document.editarticle.submit();">Preview</a> |
| 41 | <a href="javascript:document.editarticle.submit();">Update</a> |
| 27 | 42 | </p> |
| 28 | 43 | |
| 29 | 44 | <% end -%> |
| … | … | |
| 46 | 46 | <br /> |
| 47 | 47 | <br /> |
| 48 | 48 | |
| 49 | | <%= render_wiki %> |
| 49 | <%= render_article(@article, false, false) %> |
| 50 | 50 | <%= div_formattedtext_close %> |
| 51 | 51 | |
| 52 | 52 | <%= render :partial => "projects/ac_project_footer" %> |
| toggle raw diff |
--- a/app/views/articles/ac_project_edit.html.erb
+++ b/app/views/articles/ac_project_edit.html.erb
@@ -5,25 +5,40 @@
<%= div_formattedtext_open %>
-<%= error_messages_for :wiki %>
+<%= error_messages_for :article %>
-<% form_for :wiki, :url => project_wiki_path(@project.slug, @wiki.slug), :html => {:method => :put, :name => 'editwiki', :id => 'input'} do |f| -%>
+<% form_for :article, :url => project_article_path(@project.slug, @article.id), :html => {:method => :put, :name => 'editarticle', :id => 'input'} do |f| -%>
<h2><%= @title %></h2>
<p>The wiki title is automatically prefixed with the project title when the wiki is displayed.</p>
- <%= render :partial => "ac_form", :locals => { :f => f } %>
+ <%= render :partial => "ac_form" %>
<p>
- <%= f.label :slug -%><br/>
- <%= f.text_field :slug -%>
+ <%= f.label :title -%><br/>
+ <%= f.text_field :title -%>
</p>
<p>
- <%= link_to "Cancel", project_wiki_path(@project.slug, @wiki.slug) %>
- <a href="javascript:document.editwiki.submit();">Preview</a>
- <a href="javascript:document.editwiki.submit();">Update</a>
+ <%= f.label :body -%><br/>
+ <%= f.text_area :body, :rows => 20 -%>
+ </p>
+
+ <p>
+ <%= f.label :body_summary -%><br/>
+ <%= f.text_area :body_summary, :rows => 10 -%>
+ </p>
+
+ <p>
+ <%= f.label :permalink -%><br/>
+ <%= f.text_field :permalink -%>
+ </p>
+
+ <p>
+ <%= link_to "Cancel", project_articles_path(@project.slug) %>
+ <a href="javascript:document.editarticle.submit();">Preview</a>
+ <a href="javascript:document.editarticle.submit();">Update</a>
</p>
<% end -%>
@@ -31,7 +46,7 @@
<br />
<br />
-<%= render_wiki %>
+<%= render_article(@article, false, false) %>
<%= div_formattedtext_close %>
<%= render :partial => "projects/ac_project_footer" %>
\ No newline at end of file |
| |   |
| 35 | 35 | <td align=center><%= 0 %></td> |
| 36 | 36 | <td align=center><%= article.views %></td> |
| 37 | 37 | <td width=<%= STYLE_TABLE_COL_WIDTH_ACTION_SHORT %>><%= link_to("Edit", edit_project_article_path(@project.slug, article.id)) %></td> |
| 38 | | <td width=<%= STYLE_TABLE_COL_WIDTH_ACTION_SHORT %>><%= link_to("Del.", project_article_path(@project.slug, article.id), :action => "destroy") %></td> |
| 38 | <td width=<%= STYLE_TABLE_COL_WIDTH_ACTION_SHORT %>><%= link_to("Del.", project_article_path(@project.slug, article.id), :method => :delete) %></td> |
| 39 | 39 | <% end %> |
| 40 | 40 | </tr> |
| 41 | 41 | <% end %> |
| toggle raw diff |
--- a/app/views/shared/_ac_article_list.html.erb
+++ b/app/views/shared/_ac_article_list.html.erb
@@ -35,7 +35,7 @@
<td align=center><%= 0 %></td>
<td align=center><%= article.views %></td>
<td width=<%= STYLE_TABLE_COL_WIDTH_ACTION_SHORT %>><%= link_to("Edit", edit_project_article_path(@project.slug, article.id)) %></td>
- <td width=<%= STYLE_TABLE_COL_WIDTH_ACTION_SHORT %>><%= link_to("Del.", project_article_path(@project.slug, article.id), :action => "destroy") %></td>
+ <td width=<%= STYLE_TABLE_COL_WIDTH_ACTION_SHORT %>><%= link_to("Del.", project_article_path(@project.slug, article.id), :method => :delete) %></td>
<% end %>
</tr>
<% end %> |
| |   |
| 4 | 4 | # also it's 7 because there are 6 migrations before it on the project being merged in, the order |
| 5 | 5 | # of the migrations is importand for foreign_key_migrations plugin |
| 6 | 6 | # |
| 7 | | # Some fields have an _jid this is an identifier for journaling system that tracks changes |
| 8 | | # |
| 9 | 7 | |
| 10 | 8 | class CreateArticles < ActiveRecord::Migration |
| 11 | 9 | |
| … | … | |
| 22 | 22 | |
| 23 | 23 | create_table :articles do |t| |
| 24 | 24 | t.string :title, :default => "Empty", :null => false |
| 25 | | t.integer :title_jid |
| 26 | | # |
| 27 | 25 | t.text :body |
| 28 | | t.integer :body_jid |
| 29 | | # |
| 30 | 26 | t.text :body_summary |
| 31 | | t.integer :body_summary_jid |
| 32 | 27 | #also need to change the article_type table/fixtures |
| 33 | 28 | t.column :article_type, :enum, :limit => [:news, :code, :release, :howto, :issue, :other], :default => :other, :null => true |
| 34 | | t.integer :article_type_jid |
| 35 | | # |
| 36 | 29 | t.column :status, :enum, :limit => [:draft, :published, :test, :deleted], :default => :draft |
| 37 | | t.integer :status_jid |
| 38 | | # who is allowed to post comments |
| 39 | 30 | t.column :comment_status, :enum, :limit => [:open, :closed, :users, :administrators], :default => :open |
| 40 | | t.integer :comment_status_jid |
| 41 | | # slug friendly name e.g. sample-title |
| 42 | 31 | t.string :permalink, :null => false |
| 43 | | t.integer :permalink_jid |
| 44 | | # who is allowed to view (members = project members) |
| 45 | 32 | t.column :audience, :enum, :limit => [:public, :members], :default => :public |
| 46 | | t.integer :audience_jid |
| 47 | | # |
| 48 | 33 | t.integer :views, :default => 0 |
| 49 | 34 | #t.boolean :members_only, :default => false, :null => false |
| 50 | 35 | t.timestamps |
| 51 | 36 | #foreign keys |
| 52 | 37 | t.integer :user_id, :on_delete => :cascade, :on_update => :cascade, :default => 1 |
| 53 | | t.integer :user_id_jid |
| 54 | | # |
| 55 | 38 | t.integer :category_id, :on_delete => :cascade, :on_update => :cascade, :default => 1 |
| 56 | | t.integer :category_id_jid |
| 57 | | # |
| 58 | 39 | #FIXME allow project|version|release polymorphic (maybe, it would help the project filter on the article tab) |
| 59 | 40 | t.integer :project_id, :on_delete => :cascade, :on_update => :cascade, :default => 1 |
| 60 | | t.integer :project_id_jid |
| 61 | 41 | end |
| 62 | 42 | add_index :articles, [:id] |
| 63 | 43 | add_index :articles, [:status, :audience] |
| toggle raw diff |
--- a/db/migrate/014_create_articles.rb
+++ b/db/migrate/014_create_articles.rb
@@ -4,8 +4,6 @@
# also it's 7 because there are 6 migrations before it on the project being merged in, the order
# of the migrations is importand for foreign_key_migrations plugin
#
-# Some fields have an _jid this is an identifier for journaling system that tracks changes
-#
class CreateArticles < ActiveRecord::Migration
@@ -24,42 +22,22 @@ class CreateArticles < ActiveRecord::Migration
create_table :articles do |t|
t.string :title, :default => "Empty", :null => false
- t.integer :title_jid
- #
t.text :body
- t.integer :body_jid
- #
t.text :body_summary
- t.integer :body_summary_jid
#also need to change the article_type table/fixtures
t.column :article_type, :enum, :limit => [:news, :code, :release, :howto, :issue, :other], :default => :other, :null => true
- t.integer :article_type_jid
- #
t.column :status, :enum, :limit => [:draft, :published, :test, :deleted], :default => :draft
- t.integer :status_jid
- # who is allowed to post comments
t.column :comment_status, :enum, :limit => [:open, :closed, :users, :administrators], :default => :open
- t.integer :comment_status_jid
- # slug friendly name e.g. sample-title
t.string :permalink, :null => false
- t.integer :permalink_jid
- # who is allowed to view (members = project members)
t.column :audience, :enum, :limit => [:public, :members], :default => :public
- t.integer :audience_jid
- #
t.integer :views, :default => 0
#t.boolean :members_only, :default => false, :null => false
t.timestamps
#foreign keys
t.integer :user_id, :on_delete => :cascade, :on_update => :cascade, :default => 1
- t.integer :user_id_jid
- #
t.integer :category_id, :on_delete => :cascade, :on_update => :cascade, :default => 1
- t.integer :category_id_jid
- #
#FIXME allow project|version|release polymorphic (maybe, it would help the project filter on the article tab)
t.integer :project_id, :on_delete => :cascade, :on_update => :cascade, :default => 1
- t.integer :project_id_jid
end
add_index :articles, [:id]
add_index :articles, [:status, :audience] |