From 234208dd93936da1160c740c2cc1c49cf61b9949 Mon Sep 17 00:00:00 2001 From: Sidharth Bansal Date: Thu, 26 Apr 2018 23:40:31 +0530 Subject: [PATCH] Added validation errors (#2639) --- app/models/node.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/models/node.rb b/app/models/node.rb index 0e10714a15..8708b4216d 100644 --- a/app/models/node.rb +++ b/app/models/node.rb @@ -42,7 +42,7 @@ def self.search(query, order = :default) self.where(nid: nids + tnids) .order(orderParam) end - else + else nodes = Node.limit(limit) .where('title LIKE ?', '%' + input + '%') .order(orderParam) @@ -163,12 +163,12 @@ def self.weekly_tallies(type = 'note', span = 52, time = Time.now) weeks end - def self.contribution_graph_making(type = 'note', span = 52, time = Time.now) + def self.contribution_graph_making(type = 'note', span = 52, time = Time.now) weeks = {} week = span count = 0; while week >= 1 - #initialising month variable with the month of the starting day + #initialising month variable with the month of the starting day #of the week month = (time - (week*7 - 1).days).strftime('%m') #loop for finding the maximum occurence of a month name in that week @@ -851,6 +851,8 @@ def can_tag(tagname, user, errors = false) errors ? I18n.t('node.only_admins_can_lock') : false elsif tagname.split(':')[0] == 'redirect' && Node.where(slug: tagname.split(':')[1]).length <= 0 errors ? I18n.t('node.page_does_not_exist') : false + elsif ["facebook", "github", "google", "twitter"].include? tagname.split(':')[0] + errors ? "Only Oauth can create such tags" : false else true end