Skip to content

Commit

Permalink
Added validation errors (publiclab#2639)
Browse files Browse the repository at this point in the history
  • Loading branch information
SidharthBansal authored and jywarren committed Apr 26, 2018
1 parent 756841f commit cce79bf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cce79bf

Please sign in to comment.