Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
UNRELEASED CHANGES:

*
* Fix a bug preventing to delete a contact

RELEASED VERSIONS:

Expand Down
16 changes: 5 additions & 11 deletions app/Http/Controllers/ContactsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Jobs\ResizeAvatars;
use App\Helpers\VCardHelper;
use Illuminate\Http\Request;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Storage;

class ContactsController extends Controller
Expand Down Expand Up @@ -336,22 +337,15 @@ public function delete(Request $request, Contact $contact)
// this because I'll add more objects related to contacts in the future
// and I don't want to have to think of deleting a row that matches a
// contact.
//
$tables = DB::select('SELECT table_name FROM information_schema.tables WHERE table_schema="monica"');
foreach ($tables as $table) {
$tableName = $table->table_name;
$tableData = DB::table($tableName)->get();

$contactIdRowExists = false;
foreach ($tableData as $data) {
foreach ($data as $columnName => $value) {
if ($columnName == 'contact_id') {
$contactIdRowExists = true;
}
}
}

if ($contactIdRowExists == true) {
try {
DB::table($tableName)->where('contact_id', $contact->id)->delete();
} catch (QueryException $e) {
continue;
}
}

Expand Down
2 changes: 1 addition & 1 deletion public/css/app.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"/js/app.js": "/js/app.js?id=f81dabb917ca43fa50e2",
"/css/app.css": "/css/app.css?id=21b01bf2176f22d67cf9",
"/css/app.css": "/css/app.css?id=f52285cef1e0853aec3f",
"/css/stripe.css": "/css/stripe.css?id=956554a2e96db30fafa3",
"/js/app.js.map": "/js/app.js.map?id=43133d85da50b75fa1b3",
"/css/app.css.map": "/css/app.css.map?id=516bf3da4d93de8e038d",
Expand Down
6 changes: 0 additions & 6 deletions resources/assets/sass/people.scss
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,6 @@
padding-bottom: 20px;
padding-top: 40px;

.delete-contact {
font-size: 12px;
margin-bottom: 30px;
text-align: center;
}

.section-title {
position: relative;

Expand Down
4 changes: 4 additions & 0 deletions resources/views/people/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
<p>
{{ trans('people.people_delete_message') }}
<a href="#" onclick="if (confirm('{{ trans('people.people_delete_confirmation') }}')) { $('#contact-delete-form').submit(); } return false;">{{ trans('people.people_delete_click_here') }}</a>.
<form method="POST" action="{{ action('ContactsController@delete', $contact) }}" id="contact-delete-form" class="hidden">
{{ method_field('DELETE') }}
{{ csrf_field() }}
</form>
</p>
</div>

Expand Down
31 changes: 31 additions & 0 deletions tests/Browser/Contacts/ContactsControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

namespace Tests\Browser\Contacts;

use App\User;
use App\Contact;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;

class ContactsControllerTest extends DuskTestCase
{
/**
* Test if the user has 2fa Enable Link in Security Page.
* @group multifa
*/
public function test_it_displays_reminder_rules()
{
$user = factory(User::class)->create();
$contact = factory(Contact::class)->create(['account_id' => $user->account->id]);

$this->browse(function (Browser $browser) use ($user, $contact) {
$browser->loginAs($user)
->visit('people')
->assertSee($contact->getCompleteName())
->visit('people/'.$contact->id)
->clickLink('click here')
->acceptDialog()
->assertDontSee($contact->getCompleteName());
});
}
}