rmails 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +7 -1
  3. data/Gemfile +17 -0
  4. data/Gemfile.lock +67 -7
  5. data/app/assets/javascripts/controls/aliases.coffee.erb +38 -9
  6. data/app/assets/javascripts/controls/users.coffee.erb +40 -11
  7. data/app/assets/javascripts/models/alias.coffee.erb +7 -4
  8. data/app/assets/javascripts/models/user.coffee.erb +7 -5
  9. data/app/assets/stylesheets/application.sass +7 -2
  10. data/app/controllers/admin_users_controller.rb +2 -2
  11. data/app/controllers/aliases_controller.rb +11 -3
  12. data/app/controllers/application_controller.rb +1 -1
  13. data/app/controllers/domains_controller.rb +2 -2
  14. data/app/controllers/server_controller.rb +1 -1
  15. data/app/controllers/users_controller.rb +9 -3
  16. data/app/models/admin_user.rb +7 -5
  17. data/app/models/virtual_user.rb +5 -9
  18. data/app/views/admin_users/first.html.haml +1 -1
  19. data/app/views/aliases/_form.html.haml +1 -1
  20. data/app/views/domains/index.html.haml +3 -0
  21. data/app/views/users/_form.html.haml +1 -1
  22. data/config/initializers/devise_encryptable.rb +7 -7
  23. data/config/locales/cz.yml +28 -0
  24. data/config/locales/en.yml +1 -4
  25. data/config/locales/views/aliases/cz.yml +1 -0
  26. data/config/locales/views/users/cz.yml +1 -0
  27. data/lib/rmails/version.rb +2 -2
  28. data/public/assets/{application-63a99166ab81ea7342d72c2c0a8d1182.css → application-7b6b5d175d26fb23a5584728dc35220f.css} +1 -1
  29. data/public/assets/application-7b6b5d175d26fb23a5584728dc35220f.css.gz +0 -0
  30. data/public/assets/{application-766444004d753128032ed7064f6c9126.js → application-83367ef0d1b7ecb80fbc1ba279811151.js} +1 -1
  31. data/public/assets/{application-766444004d753128032ed7064f6c9126.js.gz → application-83367ef0d1b7ecb80fbc1ba279811151.js.gz} +0 -0
  32. data/public/assets/application.css +1 -1
  33. data/public/assets/application.css.gz +0 -0
  34. data/public/assets/application.js +1 -1
  35. data/public/assets/application.js.gz +0 -0
  36. data/public/assets/manifest.yml +28 -28
  37. data/system/dist/rmails/Gemfile.2 +1 -0
  38. data/system/recipes/02_setup_database.rb +1 -1
  39. metadata +6 -6
  40. data/public/assets/application-63a99166ab81ea7342d72c2c0a8d1182.css.gz +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08a72a2314c87bc4826cad68bd25ee09437ee948
4
- data.tar.gz: 6cfd3a107228ee47b84ff16d9d31ff62f63fbddf
3
+ metadata.gz: 722089a297589f3b84c92117564200adf61dece2
4
+ data.tar.gz: ec16435e608b9048f3734515a211a05ede2ae13b
5
5
  SHA512:
6
- metadata.gz: 6ff0f20c67f7f8f2a9c2f7d490dac3e482783b38ecd365d9c0ea26d34048dbe3ac75eb42d24c5c9c2bd4a3903360b45ba75eadb376e6a56b0986f7a938c83525
7
- data.tar.gz: 722bb29634c60373c36ea78524803cf06cfd392a959ec1f76d24dae5beefac9de553c196cfd0b1775a31f4a5e1b7894e769611d9d0fcd326c67b96a2dc497ef4
6
+ metadata.gz: fd2906efb59ddb99d0a2ec8e2f19cc834d3b91b66a519bfe945a77e6a1982d6ea0f70ec33424494a0afa0e5781a29a6ea5c54755979e1dc310be2c1e1dcf480f
7
+ data.tar.gz: 8e0ac9b713f62e2c020fd508940c4bbf27c94db6e52974cf31538e2bcdfcef8b244dae5b641f932f24757cf181cb3e804c8ac08ee8e4dc83737347dd8168aff2
data/.gitignore CHANGED
@@ -35,4 +35,10 @@ bin/sprockets
35
35
  bin/thor
36
36
  bin/tilt
37
37
  bin/tt
38
- vendor/gems/automateit
38
+ bin/haml
39
+ bin/sass
40
+ bin/sass-convert
41
+ bin/scss
42
+ bin/thin
43
+ Gemfile
44
+ Gemfile.lock
data/Gemfile CHANGED
@@ -4,5 +4,22 @@ gem 'hoe'
4
4
  gem 'open4'
5
5
  gem 'rails', '~> 3.2'
6
6
  gem 'devise'
7
+ gem 'devise-encryptable'
8
+ gem 'thin'
9
+ gem 'pg'
7
10
 
8
11
  gem 'automate-it', :require => 'automateit'
12
+
13
+ gem 'simple_form'
14
+ gem 'paper_trail'
15
+
16
+ ['haml', 'jquery', 'chosen'].each do |g|
17
+ gem "#{g}-rails"
18
+ end
19
+
20
+ #group :assets do
21
+ gem 'sass-rails', '~> 3.2.3'
22
+ gem 'coffee-rails', '~> 3.2.1'
23
+ gem 'therubyracer', :platforms => :ruby
24
+ gem 'uglifier', '>= 1.0.3'
25
+ #end
data/Gemfile.lock CHANGED
@@ -1,9 +1,3 @@
1
- GIT
2
- remote: git://github.com/fanda/automateit.git
3
- revision: 959e23be77c9054e712e670110632883d1a92c61
4
- specs:
5
- automateit (0.0.0)
6
-
7
1
  GEM
8
2
  remote: https://rubygems.org/
9
3
  specs:
@@ -35,20 +29,51 @@ GEM
35
29
  i18n (= 0.6.1)
36
30
  multi_json (~> 1.0)
37
31
  arel (3.0.2)
32
+ automate-it (0.9.0)
33
+ hoe
34
+ open4
38
35
  bcrypt-ruby (3.0.1)
39
36
  builder (3.0.4)
37
+ chosen-rails (0.9.12)
38
+ coffee-rails (>= 3.2)
39
+ railties (>= 3.0)
40
+ sass-rails (>= 3.2)
41
+ coffee-rails (3.2.2)
42
+ coffee-script (>= 2.2.0)
43
+ railties (~> 3.2.0)
44
+ coffee-script (2.2.0)
45
+ coffee-script-source
46
+ execjs
47
+ coffee-script-source (1.6.1)
48
+ daemons (1.1.9)
40
49
  devise (2.2.4)
41
50
  bcrypt-ruby (~> 3.0)
42
51
  orm_adapter (~> 0.1)
43
52
  railties (~> 3.1)
44
53
  warden (~> 1.2.1)
54
+ devise-encryptable (0.1.2)
55
+ devise (>= 2.1.0)
45
56
  erubis (2.7.0)
57
+ eventmachine (1.0.3)
58
+ execjs (1.4.0)
59
+ multi_json (~> 1.0)
60
+ haml (4.0.0)
61
+ tilt
62
+ haml-rails (0.4)
63
+ actionpack (>= 3.1, < 4.1)
64
+ activesupport (>= 3.1, < 4.1)
65
+ haml (>= 3.1, < 4.1)
66
+ railties (>= 3.1, < 4.1)
46
67
  hike (1.2.2)
47
68
  hoe (3.6.1)
48
69
  rake (>= 0.8, < 11.0)
49
70
  i18n (0.6.1)
50
71
  journey (1.0.4)
72
+ jquery-rails (2.2.1)
73
+ railties (>= 3.0, < 5.0)
74
+ thor (>= 0.14, < 2.0)
51
75
  json (1.8.0)
76
+ libv8 (3.11.8.13)
52
77
  mail (2.5.4)
53
78
  mime-types (~> 1.16)
54
79
  treetop (~> 1.4.8)
@@ -56,6 +81,10 @@ GEM
56
81
  multi_json (1.7.3)
57
82
  open4 (1.3.0)
58
83
  orm_adapter (0.4.0)
84
+ paper_trail (2.7.1)
85
+ activerecord (~> 3.0)
86
+ railties (~> 3.0)
87
+ pg (0.14.1)
59
88
  polyglot (0.3.3)
60
89
  rack (1.4.5)
61
90
  rack-cache (1.2)
@@ -82,17 +111,36 @@ GEM
82
111
  rake (10.0.4)
83
112
  rdoc (3.12.2)
84
113
  json (~> 1.4)
114
+ ref (1.0.2)
115
+ sass (3.2.7)
116
+ sass-rails (3.2.6)
117
+ railties (~> 3.2.0)
118
+ sass (>= 3.1.10)
119
+ tilt (~> 1.3)
120
+ simple_form (2.1.0)
121
+ actionpack (~> 3.0)
122
+ activemodel (~> 3.0)
85
123
  sprockets (2.2.2)
86
124
  hike (~> 1.2)
87
125
  multi_json (~> 1.0)
88
126
  rack (~> 1.0)
89
127
  tilt (~> 1.1, != 1.3.0)
128
+ therubyracer (0.11.4)
129
+ libv8 (~> 3.11.8.12)
130
+ ref
131
+ thin (1.5.0)
132
+ daemons (>= 1.0.9)
133
+ eventmachine (>= 0.12.6)
134
+ rack (>= 1.0.0)
90
135
  thor (0.18.1)
91
136
  tilt (1.4.1)
92
137
  treetop (1.4.12)
93
138
  polyglot
94
139
  polyglot (>= 0.3.1)
95
140
  tzinfo (0.3.37)
141
+ uglifier (1.3.0)
142
+ execjs (>= 0.3.0)
143
+ multi_json (~> 1.0, >= 1.0.2)
96
144
  warden (1.2.1)
97
145
  rack (>= 1.0)
98
146
 
@@ -100,8 +148,20 @@ PLATFORMS
100
148
  ruby
101
149
 
102
150
  DEPENDENCIES
103
- automateit (= 0.0.0)!
151
+ automate-it
152
+ chosen-rails
153
+ coffee-rails (~> 3.2.1)
104
154
  devise
155
+ devise-encryptable
156
+ haml-rails
105
157
  hoe
158
+ jquery-rails
106
159
  open4
160
+ paper_trail
161
+ pg
107
162
  rails (~> 3.2)
163
+ sass-rails (~> 3.2.3)
164
+ simple_form
165
+ therubyracer
166
+ thin
167
+ uglifier (>= 1.0.3)
@@ -18,6 +18,12 @@ window.Aliases = can.Control({
18
18
  domain_name: @dname
19
19
  } ) )
20
20
 
21
+ show_errors: (form, errors) ->
22
+ $.each(errors, (k, a) ->
23
+ el = form.find('.virtual_alias_'+k).addClass('error')
24
+ el.find('.controls').append('<span class="help-block">'+a[0]+'</span>')
25
+ )
26
+
21
27
  "form reset": (el, ev) ->
22
28
  @refresh()
23
29
  @show_title('')
@@ -41,16 +47,23 @@ window.Aliases = can.Control({
41
47
 
42
48
  ".edit_alias submit": (el, ev) ->
43
49
  ev.preventDefault()
50
+ el.find('.error .help-block').remove()
51
+ el.find('.error').removeClass('error')
44
52
  values = el.formParams()
45
- id = el.parents('tr').attr('id').replace('alias_', '')
46
- item = @model[id]
47
- item.attr(values['virtual_alias'])
53
+ index = el.parents('tr').attr('id').replace('alias_', '')
54
+ item = new Alias(values["virtual_alias"])
48
55
  if item.errors()
49
56
  item.alert()
50
57
  return
51
- Alias.update(values, item, el.attr('action'))
52
- @show_title('')
53
- @refresh()
58
+ self = this
59
+ Alias.update(values, el.attr('action')+'/'+@model[index].id, (json) ->
60
+ if json["errors"]
61
+ self.show_errors(el, json["errors"])
62
+ else
63
+ self.model[index].attr(values['virtual_alias'])
64
+ self.show_title('')
65
+ self.refresh()
66
+ )
54
67
  return false
55
68
 
56
69
 
@@ -78,14 +91,30 @@ window.Aliases = can.Control({
78
91
  if item.errors()
79
92
  item.alert()
80
93
  return
81
- Alias.create(values, @di, (json) ->
94
+ Alias.create(values, self.di, (json) ->
82
95
  if json["errors"]
83
- alert(json["errors"])
96
+ self.show_errors(el, json["errors"])
84
97
  else
85
- li.removeClass('new').attr('id', 'alias_'+json.id)
98
+ item.attr('id', json.id)
99
+ item.attr('virtual_domain_id', self.di)
86
100
  self.model.unshift(item)
87
101
  self.show_title('')
88
102
  self.refresh()
89
103
  )
90
104
 
105
+ ".rm-alias click": (el, ev) ->
106
+ ev.preventDefault()
107
+ if not confirm('Are You sure?')
108
+ return false
109
+ id = el.parents('tr').attr('id').replace('alias_', '')
110
+ self = this
111
+ Alias.destroy(@model[id], (json) ->
112
+ if json["errors"]
113
+ alert(json["errors"])
114
+ else
115
+ self.model.splice(id, 1)
116
+ self.refresh()
117
+ )
118
+ return false
119
+
91
120
  })
@@ -5,7 +5,6 @@ window.Users = can.Control({
5
5
  @di = opts.domain_id
6
6
  @dname = opts.domain_name
7
7
  @model = opts.items
8
- @dname = opts.domain_name
9
8
  @refresh()
10
9
 
11
10
  show_title: (type) ->
@@ -13,12 +12,19 @@ window.Users = can.Control({
13
12
  type = (if type.length then '_' else '') + type
14
13
  $(@el).find('h4 .title' + type).show()
15
14
 
16
- refresh: () ->
15
+ refresh: () -> # render fresh list of users
17
16
  $(@el).find('table').html( can.view( 'vusers_each_EJS', {
18
17
  items: @model
19
18
  domain_name: @dname
20
19
  } ) )
21
20
 
21
+ show_errors: (form, errors) ->
22
+ $.each(errors, (k, a) ->
23
+ el = form.find('.virtual_user_'+k).addClass('error')
24
+ el.find('.controls').append('<span class="help-block">'+a[0]+'</span>')
25
+ )
26
+
27
+
22
28
  "form reset": (el, ev) ->
23
29
  @refresh()
24
30
  @show_title('')
@@ -44,16 +50,23 @@ window.Users = can.Control({
44
50
 
45
51
  ".edit_user submit": (el, ev) ->
46
52
  ev.preventDefault()
53
+ el.find('.error .help-block').remove()
54
+ el.find('.error').removeClass('error')
47
55
  values = el.formParams()
48
- id = el.parents('tr').attr('id').replace('user_', '')
49
- item = @model[id]
50
- item.attr(values['virtual_user'])
56
+ index = el.parents('tr').attr('id').replace('user_', '')
57
+ item = new User(values["virtual_user"])
51
58
  if item.errors()
52
59
  item.alert()
53
60
  return
54
- User.update(values, item, el.attr('action'))
55
- @show_title('')
56
- @refresh()
61
+ self = this
62
+ User.update(values, el.attr('action')+'/'+@model[index].id, (json) ->
63
+ if json["errors"]
64
+ self.show_errors(el, json["errors"])
65
+ else
66
+ self.model[index].attr(values['virtual_user'])
67
+ self.show_title('')
68
+ self.refresh()
69
+ )
57
70
  return false
58
71
 
59
72
 
@@ -81,14 +94,30 @@ window.Users = can.Control({
81
94
  if item.errors()
82
95
  item.alert()
83
96
  return
84
- User.create(values, @di, (json) ->
97
+ User.create(values, self.di, (json) ->
85
98
  if json["errors"]
86
- alert(json["errors"])
99
+ self.show_errors(el, json["errors"])
87
100
  else
88
- li.removeClass('new').attr('id', 'user_'+json.id)
101
+ item.attr('id', json.id)
102
+ item.attr('virtual_domain_id', self.di)
89
103
  self.model.unshift(item)
90
104
  self.show_title('')
91
105
  self.refresh()
92
106
  )
93
107
 
108
+ ".rm-user click": (el, ev) ->
109
+ ev.preventDefault()
110
+ if not confirm('Are You sure?')
111
+ return false
112
+ id = el.parents('tr').attr('id').replace('user_', '')
113
+ self = this
114
+ User.destroy(@model[id], (json) ->
115
+ if json["errors"]
116
+ alert(json["errors"])
117
+ else
118
+ self.model.splice(id, 1)
119
+ self.refresh()
120
+ )
121
+ return false
122
+
94
123
  })
@@ -7,17 +7,20 @@ window.Alias = can.Model({
7
7
  url = unescape('<%= Rails.application.routes.url_helpers.domain_aliases_path("{domain_id}") %>').replace("{domain_id}", domain_id)
8
8
  return $.post(url, attrs, callback, "json")
9
9
 
10
- update : (attrs, alias, url) ->
11
- alias.attr(attrs['virtual_alias'])
10
+ update : (attrs, url, callback) ->
12
11
  attrs["_method"] = "PUT"
13
12
  return $.ajax({
14
- url: url + '/' + alias.id
13
+ url: url
15
14
  type: 'POST'
16
15
  data: attrs
17
16
  dataType: 'json'
17
+ success: callback
18
18
  })
19
19
 
20
- destroy : ('DELETE ' + unescape('<%= Rails.application.routes.url_helpers.domain_alias_path('{domain_id}', '{id}') %>'))
20
+ destroy : (item, callback) ->
21
+ url = unescape('<%= Rails.application.routes.url_helpers.domain_alias_path('{domain_id}', '{id}') %>').replace("{domain_id}", item.virtual_domain_id).replace("{id}", item.id)
22
+ return $.post(url, {"_method":"DELETE"}, callback, "json")
23
+
21
24
 
22
25
  init: () ->
23
26
  @validatePresenceOf ['source', 'destination']
@@ -7,18 +7,20 @@ window.User = can.Model({
7
7
  url = unescape('<%= Rails.application.routes.url_helpers.domain_users_path("{domain_id}") %>').replace("{domain_id}", domain_id)
8
8
  return $.post(url, attrs, callback, "json")
9
9
 
10
- update : (attrs, user, url ) ->
10
+ update : (attrs, url, callback) ->
11
11
  attrs["_method"] = "PUT"
12
12
  return $.ajax({
13
- url: url + '/' + user.id
13
+ url: url
14
14
  type: 'POST'
15
15
  data: attrs
16
16
  dataType: 'json'
17
- success: (json) ->
18
- dbg(json)
17
+ success: callback
19
18
  })
20
19
 
21
- destroy : ('DELETE ' + unescape('<%= Rails.application.routes.url_helpers.domain_user_path('{domain_id}', '{id}') %>'))
20
+ destroy : (item, callback) ->
21
+ url = unescape('<%= Rails.application.routes.url_helpers.domain_user_path('{domain_id}', '{id}') %>').replace("{domain_id}", item.virtual_domain_id).replace("{id}", item.id)
22
+ return $.post(url, {"_method":"DELETE"}, callback, "json")
23
+
22
24
 
23
25
  init: () ->
24
26
  @validatePresenceOf ['email']
@@ -102,8 +102,11 @@ header
102
102
 
103
103
  #rmails
104
104
  .list .table
105
- tr td *
106
- display: inline-block
105
+ tr td
106
+ *
107
+ display: inline-block
108
+ .help-block
109
+ display: block !important
107
110
 
108
111
  .label
109
112
  display: inline !important
@@ -121,6 +124,8 @@ header
121
124
  .actions
122
125
  clear: both
123
126
  width: 100%
127
+ .control-group
128
+ vertical-align: top
124
129
 
125
130
  .aliases
126
131
  .control-group
@@ -23,7 +23,7 @@ class AdminUsersController < ApplicationController
23
23
  end
24
24
  else
25
25
  respond_to do |format|
26
- format.json { render :json => {:errors => @admin.errors.to_json } }
26
+ format.json { render :json => {:errors => @admin.errors } }
27
27
  format.html {
28
28
  flash[:error] = t('first_admin_user_error')
29
29
  render :action => 'first'
@@ -38,7 +38,7 @@ class AdminUsersController < ApplicationController
38
38
  if @admin.change_data params
39
39
  render :json => {:id => @admin.id}
40
40
  else
41
- render :json => {:errors => @admin.errors.to_json}
41
+ render :json => {:errors => @admin.errors}
42
42
  end
43
43
  else
44
44
  render :json => {:errors => t('not_authorized')}
@@ -1,12 +1,12 @@
1
1
  class AliasesController < ApplicationController
2
2
 
3
- before_filter :find_alias, :only => [:update]
3
+ before_filter :find_alias, :only => [:update, :destroy]
4
4
 
5
5
  def update
6
6
  if @alias.update_attributes(params[:virtual_alias])
7
7
  render :json => {:id => @alias.id}
8
8
  else
9
- render :json => {:errors => @alias.errors.to_json}
9
+ render :json => {:errors => @alias.errors}
10
10
  end
11
11
  rescue
12
12
  render :json => {:errors => t('unknown_error')}
@@ -18,12 +18,20 @@ class AliasesController < ApplicationController
18
18
  if @alias.save
19
19
  render :json => {:id => @alias.id}
20
20
  else
21
- render :json => {:errors => @alias.errors.to_json}
21
+ render :json => {:errors => @alias.errors}
22
22
  end
23
23
  rescue
24
24
  render :json => {:errors => t('unknown_error')}
25
25
  end
26
26
 
27
+ def destroy
28
+ @alias.destroy
29
+ render :json => {:id => nil}
30
+ rescue
31
+ render :json => {:errors => t('unknown_error')}
32
+ end
33
+
34
+
27
35
 
28
36
  protected
29
37