Skip to content

Commit

Permalink
#46 restrict
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Oct 3, 2019
1 parent 7398a56 commit 038fa7a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion objects/tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@ def postpone(id, seconds)
@pgsql.transaction do |t|
t.exec('DELETE FROM task WHERE id = $1', [id])
s = (Time.now + seconds).strftime('%d-%m-%Y')
Rsk::Plans.new(@pgsql, row['project'].to_i).get(row['id'].to_i, row['part'].to_i).schedule = s
plan = Rsk::Plans.new(@pgsql, row['project'].to_i).get(row['id'].to_i, row['part'].to_i)
raise Rsk::Urror, "Can't postpone plan ##{row['id']}" if /^[a-z]+$/.match?(plan.schedule)
plan.schedule = s
end
end

Expand Down
13 changes: 8 additions & 5 deletions views/tasks.haml
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,14 @@
%span.item<
&= t[:schedule]
%a.item{href: iri.cut('/tasks/done').add(id: t[:id])} Done
%span.item
Later:
%a.item{href: iri.cut('/tasks/later').add(id: t[:id], period: 'week')} week
%a.item{href: iri.cut('/tasks/later').add(id: t[:id], period: 'month')} month
%a.item{href: iri.cut('/tasks/later').add(id: t[:id], period: 'quarter')} quarter
- unless /^[a-z]+$/.match?(t[:schedule])
%span.item
Later:
%a{href: iri.cut('/tasks/later').add(id: t[:id], period: 'week')} week
= '|'
%a{href: iri.cut('/tasks/later').add(id: t[:id], period: 'month')} month
= '|'
%a{href: iri.cut('/tasks/later').add(id: t[:id], period: 'quarter')} quarter
= Haml::Engine.new(File.read('views/_paging.haml')).render(self, locals.merge(count: tasks.count))

%p
Expand Down

0 comments on commit 038fa7a

Please sign in to comment.