pattana 0.1.16 → 0.1.17

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23f0498e9dae32310ed005c0d28049d0e4c08080
4
- data.tar.gz: 35f26c8cb3b77755e39e9b1e88a9d27614749a07
3
+ metadata.gz: 8e0055c765ddac1e9e3977e5008ad323f045249a
4
+ data.tar.gz: 2230c9c2844a8e14966a0b7e8add341875f3692f
5
5
  SHA512:
6
- metadata.gz: ef25b43c62b71683414e29898b6b26eaf046f40a04ed29880c6cc234dbba78038fee61835c8e9d729e592c9588ffa83866c0e57efdc47c5064645c729a8abb2c
7
- data.tar.gz: 5189be80a84d2b997396fd7b028979de02703a5c768c2fe297120d764105d964884505f34ba7e0a0bb62e9fa527f79863026d9a70c70d93bddff5ea766a41f0b
6
+ metadata.gz: e03ff18b5c8029240516f13c27a6f536248c71d9c17ace3428856715b8c44def3afdc8000529559028ce0b993a11c52120f66d83bd0c4fd6b0f09a6931085be6
7
+ data.tar.gz: 2c4b457f52c573226d973a26506da4413c380e90a1d5e2cc3547f19c5ea2d064ff633cfa004090d27c52e9c2a9289ce843327c424bae380d1b22c4d48bc928be
@@ -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-9 col-sm-6 col-xs-12" style="border-right:1px solid #f1f1f1;">
6
-
7
- <div class="visible-sm visible-xs mt-50"></div>
8
-
9
- <%= theme_panel_heading(@country.name) %>
10
-
11
- <%= theme_panel_sub_heading("ID: #{@country.id}", "#") %><br>
12
-
13
- <% if @country.show_in_api? %>
14
- <div class="label label-success">Show In API</div>
15
- <% else %>
16
- <div class="label label-danger">Hide In API</div>
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-3 col-sm-6 col-xs-12">
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
- <% edit_link = edit_country_path(id: @country.id) %>
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>
@@ -1,3 +1,3 @@
1
1
  module Pattana
2
- VERSION = '0.1.16'
2
+ VERSION = '0.1.17'
3
3
  end
Binary file
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :flag_image, :class => Image::FlagImage do
3
+ image { Rack::Test::UploadedFile.new('spec/dummy/spec/factories/flag.png', 'image/jpg') }
4
+ association :imageable, :factory => :country
5
+ end
6
+ end
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.16
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-08 00:00:00.000000000 Z
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.20
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.20
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: