From b5383307854ef4470066006ce4e85bd99216880c Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Sun, 21 May 2017 21:51:44 +1200 Subject: [PATCH] Form to delete your own account --- app/helpers/application_helper.rb | 1 + app/views/comments/_single.html.haml | 5 ++++- app/views/devise/registrations/_delete.html.haml | 2 +- app/views/members/_avatar.html.haml | 9 +++++---- app/views/posts/_single.html.haml | 5 ++++- app/views/posts/show.html.haml | 2 +- db/schema.rb | 11 ----------- 7 files changed, 16 insertions(+), 19 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c0206f90b..2fde0fcf8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -55,6 +55,7 @@ module ApplicationHelper # Falls back to Gravatar # def avatar_uri(member, size = 150) + return unless member if member.preferred_avatar_uri.present? # Some avatars support different sizes # http://graph.facebook.com/12345678/picture?width=150&height=150 diff --git a/app/views/comments/_single.html.haml b/app/views/comments/_single.html.haml index d27300067..9c8e37609 100644 --- a/app/views/comments/_single.html.haml +++ b/app/views/comments/_single.html.haml @@ -6,7 +6,10 @@ .col-md-11 .comment-meta Posted by - = link_to comment.author.login_name, member_path(comment.author) + - if comment.author + = link_to comment.author.login_name, member_path(comment.author) + - else + Deleted on = comment.created_at - if comment.updated_at > comment.created_at diff --git a/app/views/devise/registrations/_delete.html.haml b/app/views/devise/registrations/_delete.html.haml index 703502948..4dbbf18b8 100644 --- a/app/views/devise/registrations/_delete.html.haml +++ b/app/views/devise/registrations/_delete.html.haml @@ -5,7 +5,7 @@ .form-group = f.label :current_password, "Password required to delete", class: 'control-label col-md-2' .col-md-4 - = f.password_field :current_password, :class => 'form-control', id: 'current_pw_for_delete' + = f.password_field :current_password, class: 'form-control', id: 'current_pw_for_delete' .form-group .form-actions.col-md-offset-2.col-md-8 diff --git a/app/views/members/_avatar.html.haml b/app/views/members/_avatar.html.haml index 8570c4227..421424256 100644 --- a/app/views/members/_avatar.html.haml +++ b/app/views/members/_avatar.html.haml @@ -1,4 +1,5 @@ -= link_to image_tag(avatar_uri(member, 150), - alt: '', - class: 'img img-responsive avatar'), - member_path(member) +- if member + = link_to image_tag(avatar_uri(member, 150), + alt: '', + class: 'img img-responsive avatar'), + member_path(member) diff --git a/app/views/posts/_single.html.haml b/app/views/posts/_single.html.haml index 8b84160f5..ec735eca0 100644 --- a/app/views/posts/_single.html.haml +++ b/app/views/posts/_single.html.haml @@ -10,7 +10,10 @@ .post-meta %p Posted by - = link_to post.author.login_name, member_path(post.author) + - if post.author + = link_to post.author.login_name, member_path(post.author) + - else + Deleted - if post.forum in = link_to post.forum, post.forum diff --git a/app/views/posts/show.html.haml b/app/views/posts/show.html.haml index 4c1fe9380..3a50106a5 100644 --- a/app/views/posts/show.html.haml +++ b/app/views/posts/show.html.haml @@ -7,7 +7,7 @@ = tag("meta", property: "og:url", content: request.original_url) = tag("meta", property: "og:site_name", content: ENV['GROWSTUFF_SITE_NAME']) -- unless current_member +- if @post.author && !current_member .alert.alert-info = link_to @post.author.login_name, member_path(@post.author) is using diff --git a/db/schema.rb b/db/schema.rb index 6e8716e92..601d38e7f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -239,8 +239,6 @@ ActiveRecord::Schema.define(version: 20170520060252) do t.float "longitude" t.decimal "area" t.string "area_unit" - t.integer "width" - t.integer "length" end add_index "gardens", ["owner_id"], name: "index_gardens_on_owner_id", using: :btree @@ -490,14 +488,5 @@ ActiveRecord::Schema.define(version: 20170520060252) do add_index "seeds", ["slug"], name: "index_seeds_on_slug", unique: true, using: :btree - create_table "squares", force: :cascade do |t| - t.integer "garden_id" - t.integer "x" - t.integer "y" - t.integer "planting_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - add_foreign_key "harvests", "plantings" end