adminpanel 1.2.6 → 1.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -4,6 +4,7 @@
4
4
  /coverage/
5
5
  /Gemfile.lock
6
6
  /spec/reports/
7
+ /spec/dummy/log/
7
8
  /spec/dummy/public/uploads/
8
9
  /InstalledFiles
9
10
  /pkg/
@@ -26,7 +26,7 @@
26
26
 
27
27
  <br/>
28
28
 
29
- <table class="table table-striped table-bordered">
29
+ <table id="<%= model %>-table" class="table table-striped table-bordered">
30
30
  <tr>
31
31
  <th><%= t("category.name") %></th>
32
32
  <th><%= t("actions") %></th>
@@ -1,4 +1,3 @@
1
-
2
1
  <%= custom_form_for(resource, :remote => true, :html => {:class => "form-horizontal", :id => "new_resource"}) do |f| -%>
3
2
  <div class="row-fluid">
4
3
  <div class="modal-body">
@@ -8,7 +7,7 @@
8
7
  </div>
9
8
  </div>
10
9
  <div class="modal-footer">
11
- <button class="btn" data-dismiss="modal" aria-hidden="true"><%= I18n.t('action.close') %></button>
10
+ <button id="modal-button" class="btn" data-dismiss="modal" aria-hidden="true"><%= I18n.t('action.close') %></button>
12
11
  <%= f.submit t("action.add") + " " + @model.display_name, :disable_with => t("action.submitting"), :id =>"new-resource-button" %>
13
12
  </div>
14
13
  <% end -%>
@@ -0,0 +1,6 @@
1
+ $("#modal-button").trigger("click");
2
+ row = "<tr><td><%= escape_javascript link_to resource.name, category_path(resource) %></td>";
3
+ row = row + "<td><%= escape_javascript link_to content_tag(:i, nil, :class => 'icon-pencil'), edit_category_path(category), :title => 'Editar' %> ";
4
+ row = row + "<%= escape_javascript link_to content_tag(:i, nil, :class => 'icon-remove'),[category], :title => 'Editar', :method => :delete %></td>";
5
+ row = row + "</tr>";
6
+ $("#<%= resource.model %>-table").append(row);
@@ -1,3 +1,3 @@
1
1
  module Adminpanel
2
- VERSION = "1.2.6"
2
+ VERSION = "1.2.7"
3
3
  end
@@ -6,14 +6,6 @@ class CreateAdminpanelTables < ActiveRecord::Migration
6
6
  if Rails.env.development?
7
7
  Adminpanel::User.new(:email => 'admin@admin.com', :name => "Admin", :password => 'password', :password_confirmation => 'password').save
8
8
  puts "The password for admin@admin.com is: password"
9
- else
10
- characters = ("a".."z").to_a << ("A".."Z").to_a << (0..9).to_a <<(["!","@","#","$","%","^","&","*","(",")", "_", "-","+", "="])
11
- password = ""
12
- 8.times do
13
- password = password + "#{characters.sample}"
14
- end
15
- puts "The password for admin@admin.com is: #{password}"
16
- Adminpanel::User.new(:email => "admin@admin.com", :name => "Admin", :password => password, :password_confirmation => password).save
17
9
  end
18
10
  end
19
11
  end
@@ -250,7 +250,7 @@ module Adminpanel
250
250
  end
251
251
 
252
252
  def generate_gallery
253
- Rails::Generators.invoke("adminpanel:gallery", [@attr_field, lower_name])
253
+ Rails::Generators.invoke("adminpanel:gallery", lower_name)
254
254
  end
255
255
 
256
256
  end
@@ -25,14 +25,60 @@ namespace :adminpanel do
25
25
  s.save
26
26
  end
27
27
 
28
- task :dump => :dump_sections
28
+ task :user => :environment do |t|
29
+ characters = []
30
+ characters.concat(("a".."z").to_a)
31
+ characters.concat(("A".."Z").to_a)
32
+ characters.concat((0..9).to_a)
33
+ characters.concat(%w[! @ \# $ % ^ & * , _ - + =])
34
+ password = ""
35
+ 8.times do
36
+ password = password + "#{characters.sample}"
37
+ end
38
+ puts "Creating/overwriting admin@codn.com with password #{password}"
39
+ user = Adminpanel::User.find_by_email('admin@codn.com')
40
+ if !user.nil?
41
+ user.delete
42
+ end
43
+
44
+ Adminpanel::User.new(
45
+ :email => 'admin@codn.com',
46
+ :name => 'CoDN',
47
+ :password => password,
48
+ :password_confirmation => password
49
+ ).save
50
+ end
51
+
52
+ task :dump => :environment do |t|
53
+ puts "Dumping adminpanel_sections and adminpanel_categories into db/seeds.rb"
54
+ File.open("db/seeds.rb", "w") do |f|
55
+ f << "Adminpanel::Section.delete_all\n"
56
+ f << "Adminpanel::Category.delete_all\n"
57
+ Adminpanel::Section.all.each do |section|
58
+ f << "#{creation_command_section(section)}"
59
+ end
60
+ Adminpanel::Category.all.each do |category|
61
+ f << "#{creation_command_category(category)}"
62
+ end
63
+ end
64
+ end
29
65
 
30
66
  task :dump_sections => :environment do |t|
31
67
  puts "Dumping adminpanel_sections table into db/seeds.rb"
32
68
  File.open("db/seeds.rb", "w") do |f|
33
69
  f << "Adminpanel::Section.delete_all\n"
34
70
  Adminpanel::Section.all.each do |section|
35
- f << "#{creation_command(section)}"
71
+ f << "#{creation_command_section(section)}"
72
+ end
73
+ end
74
+ end
75
+
76
+ task :dump_categories => :environment do |t|
77
+ puts "Dumping adminpanel_categories table into db/seeds.rb"
78
+ File.open("db/seeds.rb", "w") do |f|
79
+ f << "Adminpanel::Section.delete_all\n"
80
+ Adminpanel::Section.all.each do |section|
81
+ f << "#{creation_command_categories(section)}"
36
82
  end
37
83
  end
38
84
  end
@@ -91,7 +137,7 @@ namespace :adminpanel do
91
137
  end
92
138
  end
93
139
 
94
- instance.save
140
+ instance.save(:validate => false)
95
141
 
96
142
  change_dates(instance)
97
143
 
@@ -106,16 +152,22 @@ end
106
152
 
107
153
  private
108
154
 
109
- def creation_command(section)
155
+ def creation_command_section(section)
110
156
  "Adminpanel::Section.new(\n" +
111
- ":name => \"#{section.name}\",\n" +
157
+ "\t:name => \"#{section.name}\",\n" +
112
158
  "\t:has_description => #{section.has_description},\n" +
113
159
  "\t:description => \"#{section.description}\",\n" +
114
160
  "\t:key => \"#{section.key}\",\n" +
115
161
  "\t:page => \"#{section.page}\",\n" +
116
162
  "\t:has_image => #{section.has_image}\n" +
117
163
  ").save\n"
164
+ end
118
165
 
166
+ def creation_command_category(category)
167
+ "Adminpanel::Category.new(\n" +
168
+ "\t:name => \"#{category.name}\",\n" +
169
+ "\t:model => \"#{category.model}\"\n" +
170
+ ").save\n"
119
171
  end
120
172
 
121
173
  def create_image_of(model_id)
@@ -45,4 +45,13 @@ describe "adminpanel rake task" do
45
45
  )
46
46
  end
47
47
  end
48
+
49
+ describe 'adminpanel:user' do
50
+ before do
51
+ Rake.application.invoke_task "adminpanel:user"
52
+ end
53
+ it 'should create admin@codn user' do
54
+ Adminpanel::User.last.email.should eq('admin@codn.com')
55
+ end
56
+ end
48
57
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adminpanel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 6
10
- version: 1.2.6
9
+ - 7
10
+ version: 1.2.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jose Ramon Camacho
@@ -436,6 +436,7 @@ files:
436
436
  - app/views/adminpanel/.DS_Store
437
437
  - app/views/adminpanel/categories/_categories_table.html.erb
438
438
  - app/views/adminpanel/categories/_category_form.html.erb
439
+ - app/views/adminpanel/categories/create.js.erb
439
440
  - app/views/adminpanel/categories/index.html.erb
440
441
  - app/views/adminpanel/categories/new.js.erb
441
442
  - app/views/adminpanel/galleries/_galleries_table.html.erb