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 +1 -0
- data/app/views/adminpanel/categories/_categories_table.html.erb +1 -1
- data/app/views/adminpanel/categories/_category_form.html.erb +1 -2
- data/app/views/adminpanel/categories/create.js.erb +6 -0
- data/lib/adminpanel/version.rb +1 -1
- data/lib/generators/adminpanel/initialize/templates/create_adminpanel_tables.rb +0 -8
- data/lib/generators/adminpanel/resource/resource_generator.rb +1 -1
- data/lib/tasks/adminpanel/adminpanel.rake +57 -5
- data/spec/tasks/adminpanel_rake_spec.rb +9 -0
- metadata +4 -3
data/.gitignore
CHANGED
@@ -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);
|
data/lib/adminpanel/version.rb
CHANGED
@@ -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
|
@@ -25,14 +25,60 @@ namespace :adminpanel do
|
|
25
25
|
s.save
|
26
26
|
end
|
27
27
|
|
28
|
-
task :
|
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 << "#{
|
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
|
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:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
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
|