Revision 1297:0a574315af3e .svn/pristine/60

View differences:

.svn/pristine/60/601c8061fde68e664933b8501bc10404cecb108d.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
class VersionsController < ApplicationController
19
  menu_item :roadmap
20
  model_object Version
21
  before_filter :find_model_object, :except => [:index, :new, :create, :close_completed]
22
  before_filter :find_project_from_association, :except => [:index, :new, :create, :close_completed]
23
  before_filter :find_project_by_project_id, :only => [:index, :new, :create, :close_completed]
24
  before_filter :authorize
25

  
26
  accept_api_auth :index, :show, :create, :update, :destroy
27

  
28
  helper :custom_fields
29
  helper :projects
30

  
31
  def index
32
    respond_to do |format|
33
      format.html {
34
        @trackers = @project.trackers.find(:all, :order => 'position')
35
        retrieve_selected_tracker_ids(@trackers, @trackers.select {|t| t.is_in_roadmap?})
36
        @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
37
        project_ids = @with_subprojects ? @project.self_and_descendants.collect(&:id) : [@project.id]
38

  
39
        @versions = @project.shared_versions || []
40
        @versions += @project.rolled_up_versions.visible if @with_subprojects
41
        @versions = @versions.uniq.sort
42
        unless params[:completed]
43
          @completed_versions = @versions.select {|version| version.closed? || version.completed? }
44
          @versions -= @completed_versions
45
        end
46

  
47
        @issues_by_version = {}
48
        if @selected_tracker_ids.any? && @versions.any?
49
          issues = Issue.visible.all(
50
            :include => [:project, :status, :tracker, :priority, :fixed_version],
51
            :conditions => {:tracker_id => @selected_tracker_ids, :project_id => project_ids, :fixed_version_id => @versions.map(&:id)},
52
            :order => "#{Project.table_name}.lft, #{Tracker.table_name}.position, #{Issue.table_name}.id"
53
          )
54
          @issues_by_version = issues.group_by(&:fixed_version)
55
        end
56
        @versions.reject! {|version| !project_ids.include?(version.project_id) && @issues_by_version[version].blank?}
57
      }
58
      format.api {
59
        @versions = @project.shared_versions.all
60
      }
61
    end
62
  end
63

  
64
  def show
65
    respond_to do |format|
66
      format.html {
67
        @issues = @version.fixed_issues.visible.find(:all,
68
          :include => [:status, :tracker, :priority],
69
          :order => "#{Tracker.table_name}.position, #{Issue.table_name}.id")
70
      }
71
      format.api
72
    end
73
  end
74

  
75
  def new
76
    @version = @project.versions.build
77
    @version.safe_attributes = params[:version]
78

  
79
    respond_to do |format|
80
      format.html
81
      format.js
82
    end
83
  end
84

  
85
  def create
86
    @version = @project.versions.build
87
    if params[:version]
88
      attributes = params[:version].dup
89
      attributes.delete('sharing') unless attributes.nil? || @version.allowed_sharings.include?(attributes['sharing'])
90
      @version.safe_attributes = attributes
91
    end
92

  
93
    if request.post?
94
      if @version.save
95
        respond_to do |format|
96
          format.html do
97
            flash[:notice] = l(:notice_successful_create)
98
            redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
99
          end
100
          format.js
101
          format.api do
102
            render :action => 'show', :status => :created, :location => version_url(@version)
103
          end
104
        end
105
      else
106
        respond_to do |format|
107
          format.html { render :action => 'new' }
108
          format.js   { render :action => 'new' }
109
          format.api  { render_validation_errors(@version) }
110
        end
111
      end
112
    end
113
  end
114

  
115
  def edit
116
  end
117

  
118
  def update
119
    if request.put? && params[:version]
120
      attributes = params[:version].dup
121
      attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing'])
122
      @version.safe_attributes = attributes
123
      if @version.save
124
        respond_to do |format|
125
          format.html {
126
            flash[:notice] = l(:notice_successful_update)
127
            redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
128
          }
129
          format.api  { render_api_ok }
130
        end
131
      else
132
        respond_to do |format|
133
          format.html { render :action => 'edit' }
134
          format.api  { render_validation_errors(@version) }
135
        end
136
      end
137
    end
138
  end
139

  
140
  def close_completed
141
    if request.put?
142
      @project.close_completed_versions
143
    end
144
    redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
145
  end
146

  
147
  def destroy
148
    if @version.fixed_issues.empty?
149
      @version.destroy
150
      respond_to do |format|
151
        format.html { redirect_back_or_default :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project }
152
        format.api  { render_api_ok }
153
      end
154
    else
155
      respond_to do |format|
156
        format.html {
157
          flash[:error] = l(:notice_unable_delete_version)
158
          redirect_to :controller => 'projects', :action => 'settings', :tab => 'versions', :id => @project
159
        }
160
        format.api  { head :unprocessable_entity }
161
      end
162
    end
163
  end
164

  
165
  def status_by
166
    respond_to do |format|
167
      format.html { render :action => 'show' }
168
      format.js
169
    end
170
  end
171

  
172
  private
173

  
174
  def retrieve_selected_tracker_ids(selectable_trackers, default_trackers=nil)
175
    if ids = params[:tracker_ids]
176
      @selected_tracker_ids = (ids.is_a? Array) ? ids.collect { |id| id.to_i.to_s } : ids.split('/').collect { |id| id.to_i.to_s }
177
    else
178
      @selected_tracker_ids = (default_trackers || selectable_trackers).collect {|t| t.id.to_s }
179
    end
180
  end
181
end
.svn/pristine/60/601d33dccdf30ba38c014396716e9dc8b972f697.svn-base
1
<div class="contextual">
2
<%= link_to l(:label_profile), user_path(@user), :class => 'icon icon-user' %>
3
<%= change_status_link(@user) %>
4
<%= delete_link user_path(@user) if User.current != @user %>
5
</div>
6

  
7
<h2><%= link_to l(:label_user_plural), users_path %> &#187; <%=h @user.login %></h2>
8

  
9
<%= render_tabs user_settings_tabs %>
10

  
11
<% html_title(l(:label_user), @user.login, l(:label_administration)) -%>
.svn/pristine/60/602582a67380edca2a94de437729bbfdfa35ddce.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
class PreviewsController < ApplicationController
19
  before_filter :find_project
20

  
21
  def issue
22
    @issue = @project.issues.find_by_id(params[:id]) unless params[:id].blank?
23
    if @issue
24
      @attachements = @issue.attachments
25
      @description = params[:issue] && params[:issue][:description]
26
      if @description && @description.gsub(/(\r?\n|\n\r?)/, "\n") == @issue.description.to_s.gsub(/(\r?\n|\n\r?)/, "\n")
27
        @description = nil
28
      end
29
      # params[:notes] is useful for preview of notes in issue history
30
      @notes = params[:notes] || (params[:issue] ? params[:issue][:notes] : nil)
31
    else
32
      @description = (params[:issue] ? params[:issue][:description] : nil)
33
    end
34
    render :layout => false
35
  end
36

  
37
  def news
38
    if params[:id].present? && news = News.visible.find_by_id(params[:id])
39
      @previewed = news
40
      @attachments = news.attachments
41
    end
42
    @text = (params[:news] ? params[:news][:description] : nil)
43
    render :partial => 'common/preview'
44
  end
45

  
46
  private
47

  
48
  def find_project
49
    project_id = (params[:issue] && params[:issue][:project_id]) || params[:project_id]
50
    @project = Project.find(project_id)
51
  rescue ActiveRecord::RecordNotFound
52
    render_404
53
  end
54

  
55
end
.svn/pristine/60/6027c3218372a9d0758c543764a8cc792f5f727e.svn-base
1
#context-menu { position: absolute; z-index: 40; font-size: 0.9em;}
2

  
3
#context-menu ul, #context-menu li, #context-menu a {
4
  display:block;
5
  margin:0;
6
  padding:0;
7
  border:0;
8
}
9

  
10
#context-menu ul {
11
  width:150px;
12
  border: 1px solid #ccc;
13
  background:white;
14
  list-style:none;
15
  padding:2px;
16
  border-radius:2px;
17
}
18

  
19
#context-menu li {
20
  position:relative;
21
  padding:1px;
22
  z-index:39;
23
  border:1px solid white;
24
}
25
#context-menu li.folder ul { position:absolute; left:168px; /* IE6 */ top:-2px; max-height:300px; overflow:hidden; overflow-y: auto; }
26
#context-menu li.folder>ul { left:148px; }
27

  
28
#context-menu.reverse-y li.folder>ul { top:auto; bottom:0; }
29
#context-menu.reverse-x li.folder ul { left:auto; right:168px; /* IE6 */ }
30
#context-menu.reverse-x li.folder>ul { right:148px; }
31

  
32
#context-menu a {
33
  text-decoration:none !important;
34
  background-repeat: no-repeat;
35
  background-position: 1px 50%;
36
  padding: 2px 0px 2px 20px;
37
  width:100%; /* IE */
38
}
39
#context-menu li>a { width:auto; } /* others */
40
#context-menu a.disabled, #context-menu a.disabled:hover {color: #aaa;}
41
#context-menu li a.submenu { padding-right:16px; background:url("../images/bullet_arrow_right.png") right no-repeat; }
42
#context-menu li:hover { border:1px solid #628db6; background-color:#eef5fd; border-radius:3px; }
43
#context-menu a:hover {color:#2A5685;}
44
#context-menu li.folder:hover { z-index:40; }
45
#context-menu ul ul, #context-menu  li:hover ul ul { display:none; }
46
#context-menu li:hover ul, #context-menu li:hover li:hover ul { display:block; }
47
#context-menu a.icon-checked {background: url(../images/toggle_check.png) no-repeat 3px 40%;}
48

  
49
/* selected element */
50
.context-menu-selection { background-color:#507AAA !important; color:#f8f8f8 !important; }
51
.context-menu-selection a, .context-menu-selection a:hover { color:#f8f8f8 !important; }
52
.context-menu-selection:hover { background-color:#507AAA !important; color:#f8f8f8  !important; }
.svn/pristine/60/6078dc0e2b2b4a50e4f4a1933cc7de20b96803b2.svn-base
1
require 'digest/md5'
2
require 'cgi'
3

  
4
module GravatarHelper
5

  
6
  # These are the options that control the default behavior of the public
7
  # methods. They can be overridden during the actual call to the helper,
8
  # or you can set them in your environment.rb as such:
9
  #
10
  #   # Allow racier gravatars
11
  #   GravatarHelper::DEFAULT_OPTIONS[:rating] = 'R'
12
  #
13
  DEFAULT_OPTIONS = {
14
    # The URL of a default image to display if the given email address does
15
    # not have a gravatar.
16
    :default => nil,
17
    
18
    # The default size in pixels for the gravatar image (they're square).
19
    :size => 50,
20
    
21
    # The maximum allowed MPAA rating for gravatars. This allows you to 
22
    # exclude gravatars that may be out of character for your site.
23
    :rating => 'PG',
24
    
25
    # The alt text to use in the img tag for the gravatar.  Since it's a
26
    # decorational picture, the alt text should be empty according to the
27
    # XHTML specs.
28
    :alt => '',
29

  
30
    # The title text to use for the img tag for the gravatar.
31
    :title => '',
32
    
33
    # The class to assign to the img tag for the gravatar.
34
    :class => 'gravatar',
35
    
36
    # Whether or not to display the gravatars using HTTPS instead of HTTP
37
    :ssl => false,
38
  }
39
  
40
  # The methods that will be made available to your views.
41
  module PublicMethods
42
  
43
    # Return the HTML img tag for the given user's gravatar. Presumes that 
44
    # the given user object will respond_to "email", and return the user's
45
    # email address.
46
    def gravatar_for(user, options={})
47
      gravatar(user.email, options)
48
    end
49

  
50
    # Return the HTML img tag for the given email address's gravatar.
51
    def gravatar(email, options={})
52
      src = h(gravatar_url(email, options))
53
      options = DEFAULT_OPTIONS.merge(options)
54
      [:class, :alt, :title].each { |opt| options[opt] = h(options[opt]) }
55
      image_tag src, options
56
    end
57
    
58
    # Returns the base Gravatar URL for the given email hash. If ssl evaluates to true,
59
    # a secure URL will be used instead. This is required when the gravatar is to be 
60
    # displayed on a HTTPS site.
61
    def gravatar_api_url(hash, ssl=false)
62
      if ssl
63
        "https://secure.gravatar.com/avatar/#{hash}"
64
      else
65
        "http://www.gravatar.com/avatar/#{hash}"
66
      end
67
    end
68

  
69
    # Return the gravatar URL for the given email address.
70
    def gravatar_url(email, options={})
71
      email_hash = Digest::MD5.hexdigest(email)
72
      options = DEFAULT_OPTIONS.merge(options)
73
      options[:default] = CGI::escape(options[:default]) unless options[:default].nil?
74
      gravatar_api_url(email_hash, options.delete(:ssl)).tap do |url|
75
        opts = []
76
        [:rating, :size, :default].each do |opt|
77
          unless options[opt].nil?
78
            value = h(options[opt])
79
            opts << [opt, value].join('=')
80
          end
81
        end
82
        url << "?#{opts.join('&')}" unless opts.empty?
83
      end
84
    end
85

  
86
  end
87
  
88
end
.svn/pristine/60/6079e66851bdfba1d7f0959e8f4654ca6ee38eb3.svn-base
1
# Redmine - project management software
2
# Copyright (C) 2006-2012  Jean-Philippe Lang
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

  
18
class Change < ActiveRecord::Base
19
  belongs_to :changeset
20

  
21
  validates_presence_of :changeset_id, :action, :path
22
  before_save :init_path
23
  before_validation :replace_invalid_utf8_of_path
24

  
25
  def relative_path
26
    changeset.repository.relative_path(path)
27
  end
28

  
29
  def replace_invalid_utf8_of_path
30
    self.path      = Redmine::CodesetUtil.replace_invalid_utf8(self.path)
31
    self.from_path = Redmine::CodesetUtil.replace_invalid_utf8(self.from_path)
32
  end
33

  
34
  def init_path
35
    self.path ||= ""
36
  end
37
end
.svn/pristine/60/609d041538026c7f954921e9a7987b7b6dc1a1be.svn-base
1
require File.dirname(__FILE__) + '/lib/awesome_nested_set'
.svn/pristine/60/60e7e7c93af41f6b9ef4acb4efb6235273e97558.svn-base
1
# encoding: utf-8
2
#
3
# Redmine - project management software
4
# Copyright (C) 2006-2012  Jean-Philippe Lang
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19

  
20
module AuthSourcesHelper
21
  def auth_source_partial_name(auth_source)
22
    "form_#{auth_source.class.name.underscore}"
23
  end
24
end

Also available in: Unified diff