Commit ef2bf152 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

1.0.2

parent 7b5799a9
...@@ -19,6 +19,7 @@ gem "albino", :git => "git://github.com/gitlabhq/albino.git" ...@@ -19,6 +19,7 @@ gem "albino", :git => "git://github.com/gitlabhq/albino.git"
gem "kaminari" gem "kaminari"
gem "thin" gem "thin"
gem "git" gem "git"
gem "acts_as_list"
group :assets do group :assets do
gem 'sass-rails', " ~> 3.1.0" gem 'sass-rails', " ~> 3.1.0"
......
...@@ -61,6 +61,7 @@ GEM ...@@ -61,6 +61,7 @@ GEM
activesupport (= 3.1.0) activesupport (= 3.1.0)
activesupport (3.1.0) activesupport (3.1.0)
multi_json (~> 1.0) multi_json (~> 1.0)
acts_as_list (0.1.4)
addressable (2.2.6) addressable (2.2.6)
ansi (1.3.0) ansi (1.3.0)
archive-tar-minitar (0.5.2) archive-tar-minitar (0.5.2)
...@@ -240,6 +241,7 @@ PLATFORMS ...@@ -240,6 +241,7 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
acts_as_list
albino! albino!
annotate! annotate!
autotest autotest
......
# 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://jashkenas.github.com/coffee-script/
# 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://jashkenas.github.com/coffee-script/
# 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://jashkenas.github.com/coffee-script/
...@@ -34,6 +34,7 @@ $(document).ready(function(){ ...@@ -34,6 +34,7 @@ $(document).ready(function(){
e.preventDefault(); e.preventDefault();
} }
}); });
}); });
function focusSearch() { function focusSearch() {
......
...@@ -539,3 +539,13 @@ tbody tr:nth-child(2n) td, tbody tr.even td { ...@@ -539,3 +539,13 @@ tbody tr:nth-child(2n) td, tbody tr.even td {
float:left; float:left;
} }
} }
.handle:hover{
cursor: move;
}
.handle{
width: 12px;
height: 12px;
padding: 10px;
}
...@@ -61,4 +61,8 @@ class ApplicationController < ActionController::Base ...@@ -61,4 +61,8 @@ class ApplicationController < ActionController::Base
def render_404 def render_404
render :file => File.join(Rails.root, "public", "404"), :layout => false, :status => "404" render :file => File.join(Rails.root, "public", "404"), :layout => false, :status => "404"
end end
def require_non_empty_project
redirect_to @project unless @project.repo_exists?
end
end end
...@@ -6,6 +6,7 @@ class CommitsController < ApplicationController ...@@ -6,6 +6,7 @@ class CommitsController < ApplicationController
# Authorize # Authorize
before_filter :add_project_abilities before_filter :add_project_abilities
before_filter :authorize_read_project! before_filter :authorize_read_project!
before_filter :require_non_empty_project
def index def index
load_refs # load @branch, @tag & @ref load_refs # load @branch, @tag & @ref
......
...@@ -5,7 +5,7 @@ class IssuesController < ApplicationController ...@@ -5,7 +5,7 @@ class IssuesController < ApplicationController
# Authorize # Authorize
before_filter :add_project_abilities before_filter :add_project_abilities
before_filter :authorize_read_issue! before_filter :authorize_read_issue!
before_filter :authorize_write_issue!, :only => [:new, :create, :close, :edit, :update] before_filter :authorize_write_issue!, :only => [:new, :create, :close, :edit, :update, :sort]
before_filter :authorize_admin_issue!, :only => [:destroy] before_filter :authorize_admin_issue!, :only => [:destroy]
respond_to :js respond_to :js
...@@ -69,4 +69,14 @@ class IssuesController < ApplicationController ...@@ -69,4 +69,14 @@ class IssuesController < ApplicationController
format.js { render :nothing => true } format.js { render :nothing => true }
end end
end end
def sort
@issues = @project.issues.where(:id => params['issue'])
@issues.each do |issue|
issue.position = params['issue'].index(issue.id.to_s) + 1
issue.save
end
render :nothing => true
end
end end
...@@ -6,6 +6,8 @@ class ProjectsController < ApplicationController ...@@ -6,6 +6,8 @@ class ProjectsController < ApplicationController
before_filter :authorize_read_project!, :except => [:index, :new, :create] before_filter :authorize_read_project!, :except => [:index, :new, :create]
before_filter :authorize_admin_project!, :only => [:edit, :update, :destroy] before_filter :authorize_admin_project!, :only => [:edit, :update, :destroy]
before_filter :require_non_empty_project, :only => [:blob, :tree]
def index def index
@projects = current_user.projects.all @projects = current_user.projects.all
end end
...@@ -48,7 +50,7 @@ class ProjectsController < ApplicationController ...@@ -48,7 +50,7 @@ class ProjectsController < ApplicationController
def update def update
respond_to do |format| respond_to do |format|
if project.update_attributes(params[:project]) if project.update_attributes(params[:project])
format.html { redirect_to project, notice: 'Project was successfully updated.' } format.html { redirect_to project, :notice => 'Project was successfully updated.' }
format.js format.js
else else
format.html { render action: "edit" } format.html { render action: "edit" }
......
...@@ -21,6 +21,8 @@ class Issue < ActiveRecord::Base ...@@ -21,6 +21,8 @@ class Issue < ActiveRecord::Base
scope :opened, where(:closed => false) scope :opened, where(:closed => false)
scope :closed, where(:closed => true) scope :closed, where(:closed => true)
scope :assigned, lambda { |u| where(:assignee_id => u.id)} scope :assigned, lambda { |u| where(:assignee_id => u.id)}
acts_as_list
end end
# == Schema Information # == Schema Information
# #
......
...@@ -3,7 +3,7 @@ require "grit" ...@@ -3,7 +3,7 @@ require "grit"
class Project < ActiveRecord::Base class Project < ActiveRecord::Base
belongs_to :owner, :class_name => "User" belongs_to :owner, :class_name => "User"
has_many :issues, :dependent => :destroy has_many :issues, :dependent => :destroy, :order => "position"
has_many :users_projects, :dependent => :destroy has_many :users_projects, :dependent => :destroy
has_many :users, :through => :users_projects has_many :users, :through => :users_projects
has_many :notes, :dependent => :destroy has_many :notes, :dependent => :destroy
...@@ -16,6 +16,8 @@ class Project < ActiveRecord::Base ...@@ -16,6 +16,8 @@ class Project < ActiveRecord::Base
validates :path, validates :path,
:uniqueness => true, :uniqueness => true,
:presence => true, :presence => true,
:format => { :with => /^[a-zA-Z0-9_\-]*$/,
:message => "only letters, digits & '_' '-' allowed" },
:length => { :within => 0..255 } :length => { :within => 0..255 }
validates :description, validates :description,
...@@ -24,14 +26,15 @@ class Project < ActiveRecord::Base ...@@ -24,14 +26,15 @@ class Project < ActiveRecord::Base
validates :code, validates :code,
:presence => true, :presence => true,
:uniqueness => true, :uniqueness => true,
:length => { :within => 3..12 } :format => { :with => /^[a-zA-Z0-9_\-]*$/,
:message => "only letters, digits & '_' '-' allowed" },
:length => { :within => 3..16 }
validates :owner, validates :owner,
:presence => true :presence => true
validate :check_limit validate :check_limit
before_save :format_code
after_destroy :destroy_gitosis_project after_destroy :destroy_gitosis_project
after_save :update_gitosis_project after_save :update_gitosis_project
...@@ -47,10 +50,6 @@ class Project < ActiveRecord::Base ...@@ -47,10 +50,6 @@ class Project < ActiveRecord::Base
notes.where(:noteable_type => ["", nil]) notes.where(:noteable_type => ["", nil])
end end
def format_code
read_attribute(:code).downcase.strip.gsub(' ', '')
end
def update_gitosis_project def update_gitosis_project
Gitosis.new.configure do |c| Gitosis.new.configure do |c|
c.update_project(path, gitosis_writers) c.update_project(path, gitosis_writers)
......
%tr{ :id => dom_id(issue), :class => "issue", :url => project_issue_path(@project, issue) } %tr{ :id => dom_id(issue), :class => "issue", :url => project_issue_path(@project, issue) }
%td %td
= image_tag "move.png" , :class => [:handle, :left]
= image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;" = image_tag gravatar_icon(issue.assignee.email), :class => "left", :width => 40, :style => "padding:0 5px;"
= truncate issue.assignee.name, :lenght => 20 = truncate issue.assignee.name, :lenght => 20
%td ##{issue.id} %td ##{issue.id}
......
...@@ -22,3 +22,29 @@ ...@@ -22,3 +22,29 @@
:javascript :javascript
$('.delete-issue').live('ajax:success', function() { $('.delete-issue').live('ajax:success', function() {
$(this).closest('tr').fadeOut(); }); $(this).closest('tr').fadeOut(); });
function setSortable(){
$('#issues-table>tbody').sortable({
axis: 'y',
dropOnEmpty: false,
handle: '.handle',
cursor: 'crosshair',
items: 'tr',
opacity: 0.4,
scroll: true,
update: function(){
$.ajax({
type: 'post',
data: $('#issues-table>tbody').sortable('serialize'),
dataType: 'script',
complete: function(request){
$('#issues-table>tbody').effect('highlight');
},
url: "#{sort_project_issues_path(@project)}"})
}
});
}
$(function(){
setSortable();
});
:plain :plain
$('#issues-table-holder').html("#{escape_javascript(render('issues'))}"); $('#issues-table-holder').html("#{escape_javascript(render('issues'))}");
setSortable();
...@@ -10,12 +10,13 @@ ...@@ -10,12 +10,13 @@
</div> </div>
<div class="right"> <div class="right">
<%= link_to truncate(@project.name, :length => 20), project_path(@project), :class => "current button" if @project && !@project.new_record? %> <%= link_to truncate(@project.name, :length => 20), project_path(@project), :class => "current button" if @project && !@project.new_record? %>
<%= link_to 'Home', root_path, :class => current_page?(root_url) ? "current button" : "button" %>
<%= link_to 'Projects', projects_path, :class => current_page?(projects_path) ? "current button" : "button" %> <%= link_to 'Projects', projects_path, :class => current_page?(projects_path) ? "current button" : "button" %>
<%= link_to 'Profile', profile_path, :class => (controller.controller_name == "keys") ? "current button" : "button" %>
<%= link_to('Admin', admin_root_path, :class => admin_namespace? ? "current button" : "button" ) if current_user.is_admin? %> <%= link_to('Admin', admin_root_path, :class => admin_namespace? ? "current button" : "button" ) if current_user.is_admin? %>
<%#= link_to 'Profile', edit_user_registration_path, :class => "button" %> <%= link_to profile_path, :class => ((controller.controller_name == "keys" || controller.controller_name == "profile") ? "current button" : "button") do %>
<%= link_to 'Logout', destroy_user_session_path, :class => "button", :method => :delete %> <%= image_tag gravatar_icon(current_user.email) %>
<%= current_user.name.split(" ").first %>
<% end %>
<%= link_to 'Logout', destroy_user_session_path, :style => "border-left: 1px solid #666;", :class => "button", :method => :delete %>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
%td{:align => "left", :style => "padding: 20px 0 0;"} %td{:align => "left", :style => "padding: 20px 0 0;"}
%h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "}
New comment for commmit New comment for commmit
= link_to truncate(@commit.id.to_s, :length => 16), project_commit_url(@project, :id => @commit.id) = link_to truncate(@commit.id.to_s, :length => 16), project_commit_url(@project, :id => @commit.id, :anchor => "note_#{@note.id}")
%td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
%tr %tr
%td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
%td{:align => "left", :style => "padding: 20px 0 0;"} %td{:align => "left", :style => "padding: 20px 0 0;"}
%h2{:style => "color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} %h2{:style => "color:#646464 !important; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "}
New comment - New comment -
= link_to project_issue_url(@project, @issue) do = link_to project_issue_url(@project, @issue, :anchor => "note_#{@note.id}") do
= "Issue ##{@issue.id.to_s}" = "Issue ##{@issue.id.to_s}"
= truncate(@issue.title, :length => 35) = truncate(@issue.title, :length => 35)
%td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
%td{:align => "left", :style => "padding: 20px 0 0;"} %td{:align => "left", :style => "padding: 20px 0 0;"}
%h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "} %h2{:style => "color:#646464; font-weight: bold; margin: 0; padding: 0; line-height: 26px; font-size: 18px; font-family: Helvetica, Arial, sans-serif; "}
New message on New message on
= link_to "Project Wall", wall_project_url(@project) = link_to "Project Wall", wall_project_url(@project, :anchor => "note_#{@note.id}")
%td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
%tr %tr
%td{:style => "font-size: 1px; line-height: 1px;", :width => "21"} %td{:style => "font-size: 1px; line-height: 1px;", :width => "21"}
......
%div{:class => "tile", :style => view_mode_style("tile")} - unless @projects.empty?
= render "tile" %div{:class => "tile", :style => view_mode_style("tile")}
%div{:class => "list", :style => view_mode_style("list")} = render "tile"
= render "list" %div{:class => "list", :style => view_mode_style("list")}
= render "list"
- else
%center.prepend-top
%h2
%cite Nothing here
if defined?(Footnotes) && Rails.env.development? #if defined?(Footnotes) && Rails.env.development?
Footnotes.run! # first of all #Footnotes.run! # first of all
# ... other init code # ... other init code
end #end
...@@ -32,7 +32,7 @@ Gitlab::Application.routes.draw do ...@@ -32,7 +32,7 @@ Gitlab::Application.routes.draw do
get "tree/:commit_id/:path" => "projects#tree", get "tree/:commit_id/:path" => "projects#tree",
:as => :tree_file, :as => :tree_file,
:constraints => { :constraints => {
:id => /[a-zA-Z0-9]+/, :id => /[a-zA-Z0-9_\-]+/,
:commit_id => /[a-zA-Z0-9]+/, :commit_id => /[a-zA-Z0-9]+/,
:path => /.*/ :path => /.*/
} }
...@@ -40,7 +40,11 @@ Gitlab::Application.routes.draw do ...@@ -40,7 +40,11 @@ Gitlab::Application.routes.draw do
end end
resources :commits resources :commits
resources :team_members resources :team_members
resources :issues resources :issues do
collection do
post :sort
end
end
resources :notes, :only => [:create, :destroy] resources :notes, :only => [:create, :destroy]
end end
root :to => "projects#index" root :to => "projects#index"
......
class AddPositionToIssues < ActiveRecord::Migration
def change
add_column :issues, :position, :integer, :default => 0
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20111009111204) do ActiveRecord::Schema.define(:version => 20111015154310) do
create_table "issues", :force => true do |t| create_table "issues", :force => true do |t|
t.string "title" t.string "title"
...@@ -22,6 +22,7 @@ ActiveRecord::Schema.define(:version => 20111009111204) do ...@@ -22,6 +22,7 @@ ActiveRecord::Schema.define(:version => 20111009111204) do
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.boolean "closed", :default => false, :null => false t.boolean "closed", :default => false, :null => false
t.integer "position", :default => 0
end end
create_table "keys", :force => true do |t| create_table "keys", :force => true do |t|
......
...@@ -88,7 +88,7 @@ describe "Admin::Projects" do ...@@ -88,7 +88,7 @@ describe "Admin::Projects" do
visit new_admin_project_path visit new_admin_project_path
fill_in 'Name', :with => 'NewProject' fill_in 'Name', :with => 'NewProject'
fill_in 'Code', :with => 'NPR' fill_in 'Code', :with => 'NPR'
fill_in 'Path', :with => '/tmp/legit_test/legit' fill_in 'Path', :with => 'legit_1'
expect { click_button "Save" }.to change { Project.count }.by(1) expect { click_button "Save" }.to change { Project.count }.by(1)
@project = Project.last @project = Project.last
end end
......
...@@ -39,7 +39,7 @@ describe "Projects" do ...@@ -39,7 +39,7 @@ describe "Projects" do
visit new_project_path visit new_project_path
fill_in 'Name', :with => 'NewProject' fill_in 'Name', :with => 'NewProject'
fill_in 'Code', :with => 'NPR' fill_in 'Code', :with => 'NPR'
fill_in 'Path', :with => '/tmp/legit_test/legit' fill_in 'Path', :with => 'newproject'
expect { click_button "Create Project" }.to change { Project.count }.by(1) expect { click_button "Create Project" }.to change { Project.count }.by(1)
@project = Project.last @project = Project.last
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment