Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhiltri committed Dec 10, 2019
2 parents d3cec6d + d4f9ce7 commit 8f1a6e4
Show file tree
Hide file tree
Showing 53 changed files with 957 additions and 1,230 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.0-beta53
6.0-beta54
12 changes: 12 additions & 0 deletions app/Http/Controllers/Forms/EmailSubscriptionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Http\Controllers\Forms;

use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Str;

use App\Http\Requests\Form\EmailSubscriptionsRequest;

Expand Down Expand Up @@ -257,6 +258,17 @@ public function store(EmailSubscriptionsRequest $request)

if (array_key_exists('unsubscribe', $validated) && $validated['unsubscribe']) {
$response = $exactTarget->unsubscribe();
if ($response !== true) {
// If the user doesn't exist in our email list, ET will throw an
// error. It's ok if the user doesn't exist, because that's
// ultimately what we want. So idenfity if this is the case and
// provide a message to the user. The full expected error is
// 'Concurrency violation: the DeleteCommand affected 0 of the
// expected 1 records.' [WEB-1427]
if (Str::startsWith(($response->results[0]->ErrorMessage ?? ''), 'Concurrency violation')) {
return redirect(route('forms.email-subscriptions'))->withErrors(['email' => 'This email address does not exist in our email list. Please check the address and try again.']);
}
}
}
else {
$response = $exactTarget->subscribe();
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/GenericPagesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public function show($slug)
"title" => $page->title,
"breadcrumb" => $crumbs,
"blocks" => null,
'featuredRelated' => $page->featuredRelated,
'page' => $page,
]);
}
Expand Down
17 changes: 0 additions & 17 deletions app/Http/Controllers/StaticsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,11 +304,6 @@ public function exhibition() {
$article->push('blocks', $this->generateBlocks(6));
$article->push('intro', $this->faker->paragraph(6, false));
$article->push('sponsors', $this->generateBlocks(2));
$article->push('futherSupport', array(
'logo' => $this->getImage(),
'title' => "Further support has been provided by",
'text' => $this->faker->paragraph(5),
));
// $article->push('relatedEventsByDay', $this->makeEventsByDates(1));
$article->push('relatedExhibitions', $this->getExhibitions(4));
$article->push('featuredRelated', array(
Expand Down Expand Up @@ -375,7 +370,6 @@ public function event_past_minimal() {
$article->push('type', null);
$article->push('speakers', null);
$article->push('sponsors', null);
$article->push('futherSupport', null);
// now push to a view
return view('statics/article', [
'contrastHeader' => ($article->headerType === 'feature' || $article->headerType === 'hero' || $article->headerType === 'super-hero'),
Expand All @@ -398,7 +392,6 @@ public function event_past_no_contant() {
$article->push('type', null);
$article->push('speakers', null);
$article->push('sponsors', null);
$article->push('futherSupport', null);
$article->push('intro', null);
$article->push('title', "Lorem");
// now push to a view
Expand Down Expand Up @@ -458,11 +451,6 @@ public function editorial() {
$article->push('blocks', $blocks);
$article->push('intro', $this->faker->paragraph(6, false));
$article->push('sponsors', $this->generateBlocks(2));
$article->push('futherSupport', array(
'logo' => $this->getImage(),
'title' => "Further support has been provided by",
'text' => $this->faker->paragraph(5),
));
$article->push('relatedArticles', $this->getArticles(4));
$article->push('featuredRelated', array(
'type' => 'event',
Expand Down Expand Up @@ -4199,11 +4187,6 @@ function getEventPageContents($headerType = null) {
)
);
$article->push('sponsors', $this->generateBlocks(2));
$article->push('futherSupport', array(
'logo' => $this->getImage(),
'title' => "<p>Further support has been provided by</p>",
'text' => $this->faker->paragraph(5),
));
$article->push('ticketLink', '#');
$article->push('ticketPrices', '<p>$10 students</p><p>$20 members</p><p>$30 non-members</p>');
$article->push('nav', $nav);
Expand Down
71 changes: 6 additions & 65 deletions app/Models/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@

use A17\Twill\Models\Behaviors\HasRevisions;
use A17\Twill\Models\Behaviors\HasSlug;
use App\Models\Behaviors\HasApiRelations;
use App\Models\Behaviors\HasBlocks;
use App\Models\Behaviors\HasMedias;
use App\Models\Behaviors\HasMediasEloquent;
use App\Models\Behaviors\HasRelated;
use App\Models\Behaviors\HasApiRelations;
use App\Models\Behaviors\HasFeaturedRelated;
use Illuminate\Support\Str;
use Spatie\Feed\Feedable;
use Spatie\Feed\FeedItem;

class Article extends AbstractModel implements Feedable
{
use HasSlug, HasRevisions, HasMedias, HasMediasEloquent, HasApiRelations, HasBlocks, Transformable, HasRelated;
use HasSlug, HasRevisions, HasMedias, HasMediasEloquent, HasBlocks, Transformable, HasRelated, HasApiRelations, HasFeaturedRelated;

protected $presenter = 'App\Presenters\Admin\ArticlePresenter';
protected $presenterAdmin = 'App\Presenters\Admin\ArticlePresenter';

protected $selectedFeaturedRelated = null;

protected $dispatchesEvents = [
'saved' => \App\Events\UpdateArticle::class,
'deleted' => \App\Events\UpdateArticle::class,
Expand Down Expand Up @@ -160,72 +159,14 @@ public function scopeByCategory($query, $category = null)
});
}

public function selections()
{
return $this->belongsToMany('App\Models\Selection')->withPivot('position')->orderBy('position');
}

/**
* TODO: Drop table! Made obsolete via MigrateArticleBrowsers (WEB-1183)
*/
public function articles()
{
return $this->belongsToMany('App\Models\Article', 'article_article', 'article_id', 'related_article_id')->withPivot('position')->orderBy('position');
}

public function sidebarExhibitions()
{
return $this->apiElements()->where('relation', 'sidebarExhibitions');
}

public function sidebarEvent()
{
return $this->belongsToMany('App\Models\Event', 'article_event_sidebar')->withPivot('position')->orderBy('position');
}

public function sidebarArticle()
{
return $this->belongsToMany('App\Models\Article', 'article_article_sidebar', 'article_id', 'related_article_id')->withPivot('position')->orderBy('position');
}

public function videos()
{
return $this->belongsToMany('App\Models\Video')->withPivot('position')->orderBy('position');
}

public function getFeaturedRelatedAttribute()
{
// Select a random element from those relationships below and return one per request
if ($this->selectedFeaturedRelated) {
return $this->selectedFeaturedRelated;
}

$types = collect(['sidebarArticle', 'videos', 'sidebarExhibitions', 'sidebarEvent'])->shuffle();
foreach ($types as $type) {
if ($item = $this->$type()->first()) {
switch ($type) {
case 'sidebarArticle':
$type = 'article';
break;
case 'videos':
$type = 'medias';
break;
case 'sidebarEvent':
$type = 'event';
break;
case 'sidebarExhibitions':
$item = $this->apiModels('sidebarExhibitions', 'Exhibition')->first();
$type = 'exhibition';
break;
}

$this->selectedFeaturedRelated = [
'type' => Str::singular($type),
'items' => [$item],
];
return $this->selectedFeaturedRelated;
}
}
}


public static function getAllFeedItems()
{
return \App\Models\Article::query()->published()->orderBy('date', 'desc')->get();
Expand Down
71 changes: 4 additions & 67 deletions app/Models/Artwork.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
namespace App\Models;

use App\Models\Behaviors\HasApiModel;
use App\Models\Behaviors\HasRelated;
use App\Models\Behaviors\HasApiRelations;
use App\Models\Behaviors\HasFeaturedRelated;

use Illuminate\Support\Str;

class Artwork extends AbstractModel
{
use HasApiModel, HasApiRelations;

protected $selectedFeaturedRelated = null;
use HasApiModel, HasRelated, HasApiRelations, HasFeaturedRelated;

protected $apiModel = 'App\Models\Api\Artwork';

Expand All @@ -26,74 +26,11 @@ public function getFullTitleAttribute()
return $this->title;
}

public function sidebarExhibitions()
{
return $this->apiElements()->where('relation', 'sidebarExhibitions');
}

public function sidebarEvent()
{
return $this->belongsToMany('App\Models\Event', 'artwork_event')->withPivot('position')->orderBy('position');
}

public function sidebarArticle()
{
return $this->belongsToMany('App\Models\Article', 'article_artwork')->withPivot('position')->orderBy('position');
}

public function sidebarExperiences()
{
return $this->belongsToMany('App\Models\Experience', 'artwork_experience')->withPivot('position')->orderBy('position');
}

public function getTrackingSlugAttribute()
public function getTrackingSlugAttribute()
{
return $this->title;
}

public function videos()
{
return $this->belongsToMany('App\Models\Video')->withPivot('position')->orderBy('position');
}

public function getFeaturedRelatedAttribute()
{
// Select a random element from those relationships below and return one per request
if ($this->selectedFeaturedRelated) {
return $this->selectedFeaturedRelated;
}

$types = collect(['sidebarArticle', 'videos', 'sidebarExhibitions', 'sidebarEvent', 'sidebarExperiences'])->shuffle();
foreach ($types as $type) {
if ($item = $this->$type()->first()) {
switch ($type) {
case 'sidebarArticle':
$type = 'article';
break;
case 'videos':
$type = 'medias';
break;
case 'sidebarEvent':
$type = 'event';
break;
case 'sidebarExhibitions':
$item = $this->apiModels('sidebarExhibitions', 'Exhibition')->first();
$type = 'exhibition';
break;
case 'sidebarExperiences':
$type = 'experience';
break;
}

$this->selectedFeaturedRelated = [
'type' => Str::singular($type),
'items' => [$item],
];
return $this->selectedFeaturedRelated;
}
}
}

public function getSlugAttribute()
{
return ['en' => getUtf8Slug($this->title)];
Expand Down
3 changes: 3 additions & 0 deletions app/Models/Behaviors/HasApiRelations.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

namespace App\Models\Behaviors;

/**
* TODO: Requires HasRelations. Shouldn't this just extend HasRelations, then?
*/
trait HasApiRelations
{
public function apiElements()
Expand Down
Loading

0 comments on commit 8f1a6e4

Please sign in to comment.