This commit is contained in:
Renzo 2016-08-14 15:17:44 -05:00
parent b009bb77ad
commit 04dfa535c8
2 changed files with 9 additions and 21 deletions

View File

@ -10,21 +10,21 @@ class TagSubscriptionController extends ApplicationController
] ]
]; ];
} }
public function create() public function create()
{ {
$this->response()->headers()->setContentType('text/javascript'); $this->response()->headers()->setContentType('text/javascript');
$this->setLayout(false); $this->setLayout(false);
if ($this->request()->isPost()) { if ($this->request()->isPost()) {
if (current_user()->tag_subscriptions->size() >= CONFIG()->max_tag_subscriptions) { if (current_user()->tag_subscriptions->size() >= CONFIG()->max_tag_subscriptions) {
$this->tag_subscription = null; $this->tag_subscription = null;
} else { } else {
$this->tag_subscription = TagSubscription::create(['user_id' => current_user()->id, 'tag_query' => '']); $this->tag_subscription = TagSubscription::create(['user_id' => current_user()->id, 'tag_query' => '', 'name' => 'new tagsub']);
} }
} }
} }
public function update() public function update()
{ {
if ($this->request()->isPost()) { if ($this->request()->isPost()) {
@ -37,24 +37,24 @@ class TagSubscriptionController extends ApplicationController
} }
} }
} }
$this->notice("Tag subscriptions updated"); $this->notice("Tag subscriptions updated");
$this->redirectTo('user#edit'); $this->redirectTo('user#edit');
} }
public function index() public function index()
{ {
$this->tag_subscriptions = current_user()->tag_subscriptions; $this->tag_subscriptions = current_user()->tag_subscriptions;
} }
public function destroy() public function destroy()
{ {
$this->response()->headers()->setContentType('text/javascript'); $this->response()->headers()->setContentType('text/javascript');
$this->setLayout(false); $this->setLayout(false);
if ($this->request()->isPost()) { if ($this->request()->isPost()) {
$this->tag_subscription = TagSubscription::find($this->params()->id); $this->tag_subscription = TagSubscription::find($this->params()->id);
if (current_user()->has_permission($this->tag_subscription)) { if (current_user()->has_permission($this->tag_subscription)) {
$this->tag_subscription->destroy(); $this->tag_subscription->destroy();
} }

View File

@ -110,16 +110,4 @@ class TagSubscription extends Rails\ActiveRecord\Base
} }
} }
} }
protected function validations()
{
return [
'name' => [
'length' => ['minimum' => 1]
],
'tag_query' => [
'length' => ['minimum' => 1]
],
];
}
} }