query_months_filters.patch

Andrew Chaika, 2009-12-29 09:48

Download (3.8 KB)

View differences:

app/models/query.rb (working copy)
97 97
                  "t+"  => :label_in,
98 98
                  "t"   => :label_today,
99 99
                  "w"   => :label_this_week,
100
                  "m-"  => :label_prev_month,
101
                  "m"   => :label_this_month,
102
                  "m+"  => :label_next_month,
100 103
                  ">t-" => :label_less_than_ago,
101 104
                  "<t-" => :label_more_than_ago,
102 105
                  "t-"  => :label_ago,
......
109 112
                                 :list_status => [ "o", "=", "!", "c", "*" ],
110 113
                                 :list_optional => [ "=", "!", "!*", "*" ],
111 114
                                 :list_subprojects => [ "*", "!*", "=" ],
112
                                 :date => [ "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-" ],
113
                                 :date_past => [ ">t-", "<t-", "t-", "t", "w" ],
115
                                 :date => [ "<t+", ">t+", "t+", "t", "w", ">t-", "<t-", "t-", "m-", "m", "m+" ],
116
                                 :date_past => [ ">t-", "<t-", "t-", "t", "w", "m-", "m" ],
114 117
                                 :string => [ "=", "~", "!", "!~" ],
115 118
                                 :text => [  "~", "!~" ],
116 119
                                 :integer => [ "=", ">=", "<=", "!*", "*" ] }
......
520 523
      sql = "LOWER(#{db_table}.#{db_field}) LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'"
521 524
    when "!~"
522 525
      sql = "LOWER(#{db_table}.#{db_field}) NOT LIKE '%#{connection.quote_string(value.first.to_s.downcase)}%'"
526
    when "m", "m+", "m-"
527
      date = Time.now
528
      date = date.last_month if operator.at(1) == "-"
529
      date = date.next_month if operator.at(1) == "+"
530

  
531
      from = date.at_beginning_of_month
532
      to = date.at_end_of_month
533
      sql = "#{db_table}.#{db_field} BETWEEN '%s' AND '%s'" % [connection.quoted_date(from), connection.quoted_date(to)]
534
    else
535
      sql = "1 = 1"
523 536
    end
524 537
    
525 538
    return sql
app/views/queries/_filters.rhtml (working copy)
35 35
    case "*":
36 36
    case "t":
37 37
    case "w":
38
    case "m-":
39
    case "m":
40
    case "m+":
38 41
    case "o":
39 42
    case "c":
40 43
      Element.hide("div_values_" + field);
config/locales/en.yml (working copy)
567 567
  label_last_week: last week
568 568
  label_last_n_days: "last {{count}} days"
569 569
  label_this_month: this month
570
  label_prev_month: previous month
571
  label_next_month: next month
570 572
  label_last_month: last month
571 573
  label_this_year: this year
572 574
  label_date_range: Date range
config/locales/ru.yml (working copy)
575 575
  label_news_view_all: Посмотреть все новости
576 576
  label_news: Новости
577 577
  label_next: Следующий
578
  label_next_month: следующий месяц
578 579
  label_nobody: никто
579 580
  label_no_change_option: (Нет изменений)
580 581
  label_no_data: Нет данных для отображения
......
600 601
  label_precedes: предшествует
601 602
  label_preferences: Предпочтения
602 603
  label_preview: Предварительный просмотр
604
  label_prev_month: предыдущий месяц
603 605
  label_previous: Предыдущий
604 606
  label_project: проект
605 607
  label_project_all: Все проекты