Skip to content

Commit

Permalink
Merge branch 'release/20210324-1'
Browse files Browse the repository at this point in the history
  • Loading branch information
blijblijblij committed Mar 24, 2021
2 parents 6e5b753 + 80857d2 commit 59ec88b
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

- name: Install gem files
run: |
gem install bundler -v '2.2.5'
gem install bundler -v '2.2.15'
bundle install
- name: Run ruby code linter (Rubocop)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ end

group :development do
gem 'annotate'
gem 'listen', '~> 3.3'
gem 'listen', '~> 3.5'
gem 'pry-rails'
gem 'rails-erd'
gem 'spring' # Spring speeds up development by keeping your application running in the background.
Expand Down
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ GEM
aws-eventstream (~> 1, >= 1.0.2)
bcrypt (3.1.16)
bindex (0.8.1)
bootsnap (1.7.2)
bootsnap (1.7.3)
msgpack (~> 1.0)
brakeman (5.0.0)
builder (3.2.4)
Expand Down Expand Up @@ -125,7 +125,7 @@ GEM
railties (>= 5.0.0)
faker (2.17.0)
i18n (>= 1.6, < 2)
ffi (1.14.2)
ffi (1.15.0)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
Expand All @@ -152,7 +152,7 @@ GEM
activesupport (>= 5.0.0)
jmespath (1.4.0)
json (2.5.1)
listen (3.4.1)
listen (3.5.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.9.0)
Expand All @@ -163,7 +163,7 @@ GEM
marcel (0.3.3)
mimemagic (~> 0.3.2)
method_source (1.0.0)
mimemagic (0.3.5)
mimemagic (0.3.6)
mini_magick (4.11.0)
mini_mime (1.0.2)
mini_portile2 (2.5.0)
Expand Down Expand Up @@ -383,7 +383,7 @@ DEPENDENCIES
friendly_id
image_processing
jbuilder (~> 2.11)
listen (~> 3.3)
listen (~> 3.5)
pg
pry-rails
puma (~> 5.2)
Expand Down Expand Up @@ -423,4 +423,4 @@ RUBY VERSION
ruby 2.7.2p137

BUNDLED WITH
2.2.5
2.2.15
1 change: 0 additions & 1 deletion app/controllers/mailings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ def send_mailing
end
@mailing.sender = current_user.id
@mailing.send_at = Time.zone.now
@mailing.mailing_send = true
@mailing.save!
end
redirect_to @mailing, notice: "Nieuwsbrief #{@mailing.slug} is verzonden"
Expand Down
7 changes: 4 additions & 3 deletions app/models/mailing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#
# id :bigint not null, primary key
# description :string not null
# mailing_send :boolean default(FALSE)
# published_at :datetime
# send_at :datetime
# sender :string
Expand All @@ -22,7 +21,6 @@
#
class Mailing < ApplicationRecord
has_one_attached :attachment
has_one_attached :image
has_rich_text :content

self.implicit_order_column = :published_at
Expand All @@ -32,7 +30,10 @@ class Mailing < ApplicationRecord

validates :content, presence: true
validates :description, presence: true
validates :image, presence: true
validates :title, presence: true, length: { minimum: 5 }, uniqueness: true
validates :slug, presence: true, uniqueness: true

def mailing_send
!send_at.nil?
end
end
15 changes: 0 additions & 15 deletions app/views/mailings/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,6 @@
<% end %>
</div>

<div class="field">
<%= form.label :image %>
<%= form.file_field :image %>
</div>

<div>
<% if @mailing.image.attached? == false %>
<p>No image attached</p>
<% elsif @mailing.image.previewable? %>
<%= image_tag(@mailing.image.preview(resize: "480x640")) %>
<% else @mailing.image.variable? %>
<%= image_tag(@mailing.image.variant(resize: "480x640")) %>
<% end %>
</div>

<div class="actions">
<%= form.submit %>
</div>
Expand Down
7 changes: 2 additions & 5 deletions app/views/mailings/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
<h1><%= @mailing.title %></h1>
<section class="section typeset">
<% if current_user.admin? %>
<%= link_to 'Bewerken', edit_mailing_path(@mailing), class: 'button btn btn-primary', style: "background: #FBB901" %>
<% if @mailing.mailing_send == false %>
<%= link_to 'Bewerken', edit_mailing_path(@mailing), class: 'button btn btn-primary', style: "background: #FBB901" %>
<%= link_to "/mailings/#{@mailing.slug}/verzenden", class: 'button btn btn-primary', style: "background: #9A6836" do %>
<span class="glyphicon glyphicon-pencil"></span>
Vesturen
<% end %>
<%= link_to 'Verwijderen', @mailing, class: 'button btn btn-primary', style: "background: #FF8000", method: :delete, data: { confirm: 'Weet je het zeker?' } %>
<% end %>
<%= link_to 'Verwijderen', @mailing, class: 'button btn btn-primary', style: "background: #FF8000", method: :delete, data: { confirm: 'Weet je het zeker?' } %>
<% end %>
</section>
<small class="small post-meta">
Expand All @@ -38,9 +38,6 @@
<%= link_to "Download #{@mailing.attachment.blob.filename}", rails_blob_path(@mailing.attachment, disposition: "attachment") %>
<% end %>
</p>
<p>
<%= image_tag url_for(@mailing.image) %>
</p>
<%= render partial: '/common/share' %>
</article>
</div>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20210324142938_remove_mailing_send_from_mailing.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class RemoveMailingSendFromMailing < ActiveRecord::Migration[6.1]
def change
remove_column :mailings, :mailing_send, :boolean
end
end
3 changes: 1 addition & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2021_02_19_143933) do
ActiveRecord::Schema.define(version: 2021_03_24_142938) do

# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
Expand Down Expand Up @@ -74,7 +74,6 @@
t.datetime "updated_at", precision: 6, null: false
t.string "slug", null: false
t.datetime "send_at"
t.boolean "mailing_send", default: false
t.string "sender"
t.index ["slug"], name: "index_mailings_on_slug", unique: true
t.index ["title"], name: "index_mailings_on_title", unique: true
Expand Down
Binary file modified erd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion spec/factories/mailing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
factory :mailing do
id { Faker::Number.number }
description { Faker::Lorem.words(number: rand(2..10)) }
mailing_send { [true, false].sample }
published_at { Time.zone.now }
send_at { [Time.zone.now, nil].sample }
sender { Faker::Number.number }
Expand Down
2 changes: 0 additions & 2 deletions spec/models/mailing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#
# id :bigint not null, primary key
# description :string not null
# mailing_send :boolean default(FALSE)
# published_at :datetime
# send_at :datetime
# sender :string
Expand All @@ -29,7 +28,6 @@
end

it { is_expected.to have_db_column(:description).of_type(:string).with_options(null: false) }
it { is_expected.to have_db_column(:mailing_send).of_type(:boolean) }
it { is_expected.to have_db_column(:published_at).of_type(:datetime) }
it { is_expected.to have_db_column(:send_at).of_type(:datetime) }
it { is_expected.to have_db_column(:sender).of_type(:string) }
Expand Down

0 comments on commit 59ec88b

Please sign in to comment.