profile_editor_helper.rb
3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
module ProfileEditorHelper
  AREAS_OF_STUDY = [
    N_('Agrometeorology'),
    N_('Agronomy'),
    N_('Foods'),
    N_('Anthropology'),
    N_('Architecture'),
    N_('Arts'),
    N_('Astronomy'),
    N_('Librarianship'),
    N_('Biosciences'),
    N_('Biophysics'),
    N_('Biology'),
    N_('Biotechnology'),
    N_('Botany'),
    N_('Science Politics'),
    N_('Accounting and Actuarial Science'),
    N_('Morphologic Sciences'),
    N_('Computation'),
    N_('Rural Development'),
    N_('Law'),
    N_('Ecology'),
    N_('Economy'),
    N_('Education'),
    N_('Long-distance Education'),
    N_('Physical Education'),
    N_('Professional Education'),
    N_('Nursing'),
    N_('Engineerings'),
    N_('Basic and Average education'),
    N_('Statistics'),
    N_('Stratigraphy'),
    N_('Pharmacy'),
    N_('Pharmacology'),
    N_('Philosophy'),
    N_('Physics'),
    N_('Plant Protection'),
    N_('Genetics'),
    N_('Geosciences'),
    N_('Geography'),
    N_('Geology'),
    N_('Hydrology'),
    N_('Hydromechanics'),
    N_('History'),
    N_('Horticulture'),
    N_('Informatics'),
    N_('Interdisciplinary'),
    N_('Journalism'),
    N_('Letters'),
    N_('Languages'),
    N_('Mathematics'),
    N_('Medicines'),
    N_('Medicine'),
    N_('Metallurgy'),
    N_('Microbiology'),
    N_('Mineralogy'),
    N_('Music'),
    N_('Nutrition'),
    N_('Odontology'),
    N_('Paleontology'),
    N_('Petrology'),
    N_('Production'),
    N_('Psychology'),
    N_('Psychiatry'),
    N_('Quality'),
    N_('Chemistry'),
    N_('Health'),
    N_('Remote Sensing'),
    N_('Forestry'),
    N_('Sociology'),
    N_('Ground'),
    N_('Theater'),
    N_('Transport'),
    N_('Urbanism'),
    N_('Veterinary Medicine'),
    N_('Zoology'),
    N_('Zootecnia'),
    N_('Others')
  ]
  SCHOOLING = [
    N_('Post-Doctoral'),
    N_('Ph.D.'),
    N_('Masters'),
    N_('Undergraduate'),
    N_('Graduate'),
    N_('High School'),
    N_('Elementary School')
  ]
  SCHOOLING_STATUS = [
    N_('Concluded'),
    N_('Incomplete'),
    N_('Ongoing')
  ]
  def select_area(title, object, method, options)
    labelled_form_field(title, select(object, method, [[_('[Select ...]'), nil]] + ProfileEditorHelper::AREAS_OF_STUDY.map{|s| [gettext(s), s]}, {}, options))
  end
  def country_helper
    @country_helper ||= CountriesHelper.instance
  end
  def select_country(title, object, method, options)
    labelled_form_field(title, select(object, method, [[_('[Select ...]'), nil]] + country_helper.countries, {}, options))
  end
  def select_schooling(object, method, options)
    select(object, method, [[_('[Select ...]'), nil]] + ProfileEditorHelper::SCHOOLING.map{|s| [gettext(s), s]}, {}, options)
  end
  def select_schooling_status(object, method, options)
    select(object, method, [[_('[Select ...]'), nil]] + ProfileEditorHelper::SCHOOLING_STATUS.map{|s| [gettext(s), s]}, {}, options)
  end
  def select_preferred_domain(object)
    profile = instance_variable_get("@#{object}")
    domains = []
    if profile
      if profile.preferred_domain
        # FIXME should be able to change
        return ''
      else
        domains = profile.possible_domains
      end
    else
      domains = environment.domains
    end
    labelled_form_field(__('Preferred domain name:'), select(object, :preferred_domain_id, domains.map {|item| [item.name, item.id]}, :prompt => '<' + _('Select domain') + '>'))
  end
  def control_panel(&block)
    concat(
      content_tag(
        'div',
        capture(&block) + '<br style="clear:left;"/> ',
        :class => 'control-panel'),
      block.binding)
  end
  def control_panel_button(title, icon, url)
    link_to title, url, :class => 'control-panel-%s' % icon
  end
end