pattana 0.1.16 → 0.1.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/country.rb +1 -0
- data/app/models/image/flag_image.rb +22 -0
- data/app/serializers/country_preview_serializer.rb +8 -0
- data/app/serializers/flag_image_serializer.rb +23 -0
- data/app/uploaders/flag_image_uploader.rb +23 -0
- data/app/views/pattana/countries/_index.html.erb +7 -0
- data/app/views/pattana/countries/_show.html.erb +34 -24
- data/lib/pattana/version.rb +1 -1
- data/spec/dummy/spec/factories/flag.png +0 -0
- data/spec/dummy/spec/factories/flag_image.rb +6 -0
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e0055c765ddac1e9e3977e5008ad323f045249a
|
4
|
+
data.tar.gz: 2230c9c2844a8e14966a0b7e8add341875f3692f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e03ff18b5c8029240516f13c27a6f536248c71d9c17ace3428856715b8c44def3afdc8000529559028ce0b993a11c52120f66d83bd0c4fd6b0f09a6931085be6
|
7
|
+
data.tar.gz: 2c4b457f52c573226d973a26506da4413c380e90a1d5e2cc3547f19c5ea2d064ff633cfa004090d27c52e9c2a9289ce843327c424bae380d1b22c4d48bc928be
|
data/app/models/country.rb
CHANGED
@@ -3,6 +3,7 @@ class Country < Pattana::ApplicationRecord
|
|
3
3
|
# Associations
|
4
4
|
has_many :regions
|
5
5
|
has_many :cities
|
6
|
+
has_one :flag_image, :as => :imageable, :dependent => :destroy, :class_name => "Image::FlagImage"
|
6
7
|
|
7
8
|
# Validations
|
8
9
|
validates :name, presence: true, length: {minimum: 3, maximum: 128}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Image::FlagImage < Image::Base
|
2
|
+
|
3
|
+
mount_uploader :image, FlagImageUploader
|
4
|
+
|
5
|
+
# Configuration
|
6
|
+
# -------------
|
7
|
+
def self.image_configuration
|
8
|
+
{
|
9
|
+
max_upload_limit: 1048576,
|
10
|
+
min_upload_limit: 1,
|
11
|
+
resolutions: [550, 275],
|
12
|
+
form_upload_image_label: "Upload a new Image",
|
13
|
+
form_title: "Upload an Image (Flag)",
|
14
|
+
form_sub_title: "Please read the instructions below:",
|
15
|
+
form_instructions: [
|
16
|
+
"the filename should be in .jpg / .jpeg or .png format",
|
17
|
+
"the image resolutions should be <strong>550 x 275 Pixels</strong>",
|
18
|
+
"the file size should be greater than 100 Kb and or lesser than <strong>10 MB</strong>"
|
19
|
+
]
|
20
|
+
}
|
21
|
+
end
|
22
|
+
end
|
@@ -1,4 +1,12 @@
|
|
1
1
|
class CountryPreviewSerializer < ActiveModel::Serializer
|
2
2
|
include NullAttributeReplacer
|
3
3
|
attributes :id, :name, :iso_name, :iso_alpha_2, :dialing_prefix, :priority, :operational
|
4
|
+
|
5
|
+
has_one :flag_image, class_name: "Image::FlagImage", serializer: FlagImageSerializer do
|
6
|
+
if object.flag_image
|
7
|
+
object.flag_image
|
8
|
+
else
|
9
|
+
object.build_flag_image
|
10
|
+
end
|
11
|
+
end
|
4
12
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class FlagImageSerializer < ActiveModel::Serializer
|
2
|
+
include NullAttributeReplacer
|
3
|
+
|
4
|
+
attributes :id, :created_at
|
5
|
+
attributes :image_large_path, :image_medium_path, :image_small_path, :image_tiny_path
|
6
|
+
|
7
|
+
def image_large_path
|
8
|
+
object.image_url :large
|
9
|
+
end
|
10
|
+
|
11
|
+
def image_medium_path
|
12
|
+
object.image_url :medium
|
13
|
+
end
|
14
|
+
|
15
|
+
def image_small_path
|
16
|
+
object.image_url :small
|
17
|
+
end
|
18
|
+
|
19
|
+
def image_tiny_path
|
20
|
+
object.image_url :tiny
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class FlagImageUploader < ImageUploader
|
2
|
+
|
3
|
+
def store_dir
|
4
|
+
"uploads/flag_images/#{model.id}"
|
5
|
+
end
|
6
|
+
|
7
|
+
version :large do
|
8
|
+
process :resize_to_fill => [550, 275]
|
9
|
+
end
|
10
|
+
|
11
|
+
version :medium do
|
12
|
+
process :resize_to_fill => [250, 125]
|
13
|
+
end
|
14
|
+
|
15
|
+
version :small do
|
16
|
+
process :resize_to_fill => [100, 50]
|
17
|
+
end
|
18
|
+
|
19
|
+
version :tiny do
|
20
|
+
process :resize_to_fill => [40, 20]
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
<thead>
|
4
4
|
<tr>
|
5
5
|
<th style="text-align:center;width:5%;">#</th>
|
6
|
+
<th style="text-align: center;width:100px"><i class="fa fa-photo"></i></th>
|
6
7
|
<th style="text-align:left;width:40%;">Name</th>
|
7
8
|
<th style="text-align:center;width:15%;">Show in API</th>
|
8
9
|
<th style="text-align:center;width:15%;">Operational</th>
|
@@ -19,6 +20,12 @@
|
|
19
20
|
<tr id="tr_country_<%= country.id %>">
|
20
21
|
|
21
22
|
<td class="text-align-center"><%= country.id %></td>
|
23
|
+
|
24
|
+
<td class="user-image">
|
25
|
+
<%= link_to(pattana.country_path(country), remote: true) do %>
|
26
|
+
<%= display_image(country, "flag_image.image.small.url", width: "120", height: "auto", class: "img-rectangle", alt: country.name) %>
|
27
|
+
<% end %>
|
28
|
+
</td>
|
22
29
|
|
23
30
|
<td class="text-align-left"><%= link_to country.name, pattana.country_path(country), remote: true %></td>
|
24
31
|
|
@@ -2,32 +2,40 @@
|
|
2
2
|
|
3
3
|
<div class="row">
|
4
4
|
|
5
|
-
<div class="col-md-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
<% end %>
|
18
|
-
|
19
|
-
<% if @country.operational? %>
|
20
|
-
<div class="label label-success">Operational</div>
|
21
|
-
<% else %>
|
22
|
-
<div class="label label-danger">Non Operational</div>
|
23
|
-
<% end %>
|
24
|
-
|
5
|
+
<div class="col-md-3 col-sm-12 col-xs-12" style="border-right:1px solid #f1f1f1;">
|
6
|
+
<div class="m-10">
|
7
|
+
<%# if display_edit_links? %>
|
8
|
+
<%= edit_image(@country,
|
9
|
+
"flag_image.image.large.url",
|
10
|
+
upload_image_link(@country, :flag_image, nil ),
|
11
|
+
remove_image_link(@country, :flag_image, nil ),
|
12
|
+
image_options: {assoc_name: :flag_image}) %>
|
13
|
+
<%# else %>
|
14
|
+
<%#= display_image(@country, "flag_image.image.large.url", class: "img-inline", alt: @country.display_name) %>
|
15
|
+
<%# end %>
|
16
|
+
</div>
|
25
17
|
</div>
|
26
18
|
|
27
|
-
<div class="col-md-
|
19
|
+
<div class="col-md-6 col-sm-12 col-xs-12" style="border-right:1px solid #f1f1f1;">
|
20
|
+
<%= theme_panel_heading(@country.name) %>
|
21
|
+
<%= theme_panel_sub_heading(@country.id, "#") %>
|
22
|
+
|
23
|
+
<%= clear_tag(10) %>
|
24
|
+
<% if @country.show_in_api? %>
|
25
|
+
<div class="label label-success">Show In API</div>
|
26
|
+
<% else %>
|
27
|
+
<div class="label label-danger">Hide In API</div>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
<% if @country.operational? %>
|
31
|
+
<div class="label label-success">Operational</div>
|
32
|
+
<% else %>
|
33
|
+
<div class="label label-danger">Non Operational</div>
|
34
|
+
<% end %>
|
35
|
+
<%= clear_tag(10) %>
|
36
|
+
</div>
|
28
37
|
|
29
|
-
|
30
|
-
<% delete_link = country_path(id: @country.id) %>
|
38
|
+
<div class="col-md-3 col-sm-12 col-xs-12">
|
31
39
|
|
32
40
|
<% if @country.show_in_api? %>
|
33
41
|
<!-- Hide in API -->
|
@@ -45,6 +53,9 @@
|
|
45
53
|
<%= link_to raw("<i class=\"fa fa-toggle-on mr-5\"></i> Show in API"), mark_as_operational_country_path(:id => @country.id), :remote=>true, class: "btn btn-block btn-success btn-only-hover" %>
|
46
54
|
<% end %>
|
47
55
|
|
56
|
+
<% edit_link = edit_country_path(id: @country.id) %>
|
57
|
+
<% delete_link = country_path(id: @country.id) %>
|
58
|
+
|
48
59
|
<!-- Edit -->
|
49
60
|
<%= link_to raw("<i class=\"fa fa-edit mr-5\"></i> Edit"), edit_link, :remote=>true, class: "btn btn-block btn-white btn-only-hover" %>
|
50
61
|
|
@@ -52,7 +63,6 @@
|
|
52
63
|
<%= link_to raw("<i class=\"linecons-trash mr-5\"></i> Delete"), delete_link, method: :delete, :remote=>true, data: { confirm: 'Are you sure?' }, class: "btn btn-block btn-danger btn-only-hover" %>
|
53
64
|
|
54
65
|
<div class="visible-sm visible-xs mb-50"></div>
|
55
|
-
|
56
66
|
</div>
|
57
67
|
|
58
68
|
</div>
|
data/lib/pattana/version.rb
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pattana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kpvarma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -107,7 +107,7 @@ dependencies:
|
|
107
107
|
version: '0.1'
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.1.
|
110
|
+
version: 0.1.21
|
111
111
|
type: :runtime
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -117,7 +117,7 @@ dependencies:
|
|
117
117
|
version: '0.1'
|
118
118
|
- - ">="
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version: 0.1.
|
120
|
+
version: 0.1.21
|
121
121
|
- !ruby/object:Gem::Dependency
|
122
122
|
name: bcrypt
|
123
123
|
requirement: !ruby/object:Gem::Requirement
|
@@ -383,11 +383,14 @@ files:
|
|
383
383
|
- app/mailers/pattana/application_mailer.rb
|
384
384
|
- app/models/city.rb
|
385
385
|
- app/models/country.rb
|
386
|
+
- app/models/image/flag_image.rb
|
386
387
|
- app/models/pattana/application_record.rb
|
387
388
|
- app/models/region.rb
|
388
389
|
- app/serializers/city_preview_serializer.rb
|
389
390
|
- app/serializers/country_preview_serializer.rb
|
391
|
+
- app/serializers/flag_image_serializer.rb
|
390
392
|
- app/serializers/region_preview_serializer.rb
|
393
|
+
- app/uploaders/flag_image_uploader.rb
|
391
394
|
- app/views/layouts/kuppayam/_footer.html.erb
|
392
395
|
- app/views/layouts/kuppayam/_header.html.erb
|
393
396
|
- app/views/layouts/kuppayam/_navbar.html.erb
|
@@ -459,6 +462,8 @@ files:
|
|
459
462
|
- lib/tasks/master_data.rake
|
460
463
|
- spec/dummy/spec/factories/city.rb
|
461
464
|
- spec/dummy/spec/factories/country.rb
|
465
|
+
- spec/dummy/spec/factories/flag.png
|
466
|
+
- spec/dummy/spec/factories/flag_image.rb
|
462
467
|
- spec/dummy/spec/factories/region.rb
|
463
468
|
homepage: https://github.com/right-solutions/pattana
|
464
469
|
licenses:
|