Skip to content

Commit

Permalink
image upload fix, user permissions, watermark
Browse files Browse the repository at this point in the history
  • Loading branch information
oshlykov committed Jan 27, 2012
1 parent d664e8b commit c689a1a
Show file tree
Hide file tree
Showing 18 changed files with 215 additions and 51 deletions.
Binary file modified app/assets/images/watermark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,12 @@ header nav ul li {

.hidden{
display:none;
}

.picture{
display: inline;
}

#pictures{
display: block;
}
3 changes: 3 additions & 0 deletions app/controllers/commissions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
class CommissionsController < ApplicationController

before_filter :authenticate_user!, :except => [:index, :show]

def index
@uiks = Commission.find :all, :joins => :comments
# Commission.includes([:comments]).where(:is_uik=>true)
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/pictures_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class PicturesController < ApplicationController

before_filter :get_protocol
before_filter :authenticate_user!, :except => [:index, :show]


# def index
# @pictures = @protocol.pictures
Expand Down
20 changes: 14 additions & 6 deletions app/controllers/protocols_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class ProtocolsController < ApplicationController

before_filter :authenticate_user!, :except => [:index, :show]

def new
#@@voting_dictionary[1]
#TODO [@uik.election]
Expand All @@ -8,7 +10,7 @@ def new
#@protocol.votings = @votings
if @protocol.save
#TODO election
@@voting_dictionary[1].count.times do |i|
VOTING_DICTIONARY[1].count.times do |i|
v = @protocol.votings.new(:voting_dictionary_id => i+1)
v.save
end
Expand All @@ -21,17 +23,23 @@ def new
end

def show
@uik = Commission.find_by_id!(params[:commission_id])
@protocol = Protocol.find_by_id!(params[:id])

#@uik = Commission.find_by_id!(params[:commission_id])
#@protocol = Protocol.find_by_id!(params[:id])
redirect_to :back unless @uik = Commission.find_by_id(params[:commission_id]) and @protocol = Protocol.find_by_id(params[:id])
end

def create
#p = Protocol.new(params[:protocol])
end

def show
redirect_to :back unless @uik = Commission.find_by_id(params[:commission_id]) and @protocol = Protocol.find_by_id(params[:id])

def update
@protocol = Protocol.find_by_id!(params[:id])
@protocol.votings.each do |v|
v.votes = params[v.voting_dictionary_id.to_s]
v.save
end
redirect_to :back
end

end
11 changes: 7 additions & 4 deletions app/uploaders/picture_uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def store_dir
process :watermark => Rails.root.join("app","assets","images", "watermark.png")

version :thumb do
process :resize_to_fit => [80, 80]
process :resize_to_limit => [100,100]
end

def watermark(path_to_file)
Expand Down Expand Up @@ -56,8 +56,11 @@ def watermark(path_to_file)

# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
def filename
if original_filename
@@name ||= Digest::MD5.hexdigest(File.read(current_path))
"nk12_su-#{@@name}.#{file.extension}"
end
end

end
21 changes: 16 additions & 5 deletions app/views/commissions/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,30 @@
%table
%tr
%td
ЦИК
%a{:href=>@commission.url}
ЦИК
- @iik.votings.each do |vote|
%td{"title"=>vote.name}
= vote.votes
%tr
- if @checked_protocol
- if @checked_protocol
%tr
%td
КАРИК
%a{:href => commission_protocol_path(@commission.id, @checked_protocol.id)}
КАРИК
- @checked_protocol.votings.each do |vote|
%td{"title"=>vote.name}
= vote.votes
- if @checked_protocol
#pictures
- @checked_protocol.pictures.each do |p|
.picture[p]
%a{:href => p.image_url}
= image_tag p.image_url(:thumb) if p.image?



%a{:href => new_commission_protocol_path(@commission.id)}
Загрузить протокол
Загрузить новый протокол
%br
%br
%div#disqus_thread
Expand Down
19 changes: 18 additions & 1 deletion app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,21 @@
= content_tag :div, msg, :id => "flash_\#{name}" if msg.is_a?(String)
#main{:role => "main"}
= yield
%footer
%footer
:javascript
var reformalOptions = {
project_id: 54065,
project_host: "nk12.reformal.ru",
force_new_window: false,
tab_alignment: "right",
tab_top: "300",
tab_bg_color: "#F08200",
tab_image_url: "http://tab.reformal.ru/0J%252FRgNC10LTQu9C%252B0LbQtdC90LjRjyDQv9GA0L7QtdC60YLRgw==/FFFFFF/0bbddf01a0d75b7c53d59f57dec259ba"
};
(function() {
var script = document.createElement('script');
script.type = 'text/javascript'; script.async = true;
script.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'media.reformal.ru/widgets/v1/reformal.js';
document.getElementsByTagName('head')[0].appendChild(script);
})();
32 changes: 19 additions & 13 deletions app/views/protocols/_form.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,26 @@
-#= f.association :company, :collection => Company.active.all(:order => 'name'), :prompt => "Choose a Company"
-# = f.button :submit
%table
- @protocol.votings.each do |v|
%tr
-#/uik/:commission_id/protocols/:protocol_id/votings/:id(.:format)
-#%form{:action => commission_protocols_path(@protocol.commission.id)+'/'[email protected]_s, :method => 'post', :id => 'protocol_update'}
=form_for @protocol do |form|
%table
- @protocol.votings.each do |v|
%tr
%td
%input{ :name =>v.voting_dictionary_id, :id => v.id, :value => v.votes}
-#= link_to 'Редактировать', edit_commission_protocol_voting_path(@uik.id, @protocol.id, v.id)
-#%td
-#= v.votes
%td
= v.name
-#%td
-#= link_to 'Показать', trip
-#%td
-#= link_to 'Удалить', trip, :confirm => 'Вы уверены?', :method => :delete
%tr
%td
= link_to 'Редактировать', edit_commission_protocol_voting_path(@uik.id, @protocol.id, v.id)
%td
= v.votes
%td
= v.name
-#%td
-#= link_to 'Показать', trip
-#%td
-#= link_to 'Удалить', trip, :confirm => 'Вы уверены?', :method => :delete
= form.submit('Сохранить')

-# = simple_form_for [v] do |f|
-#= f.input :er, :label => "Единая Россия", :wrapper => :inline
5 changes: 3 additions & 2 deletions app/views/protocols/_picture.html.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.picture[picture]
= image_tag picture.image_url(:thumb) if picture.image?
= link_to "Delete", commission_protocol_picture_path(@protocol.commission_id, @protocol, picture.id), :method => :delete, :confirm => "Удалит фотографию протокола?", :remote => :true
%a{:href => picture.image_url}
= image_tag picture.image_url(:thumb) if picture.image?
= link_to "Удалить", commission_protocol_picture_path(@protocol.commission_id, @protocol, picture.id), :method => :delete, :confirm => "Удалит цифровую копию?", :remote => :true
14 changes: 8 additions & 6 deletions app/views/protocols/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
%h1
= "Протокол к #{@uik.name}(#{@uik.root.name})"
= "Протокол к "
%a{:href => commission_path(@uik.id)}
=@uik.name+'('[email protected]+')'
%h2
Загрузка цифровых копий протокола

Expand Down Expand Up @@ -36,11 +38,11 @@
#pictures
= render :partial => 'picture', :collection => @protocol.pictures

%table
%tr
- @protocol.pictures.each do |pic|
%td
= pic.id
-#%table
-#%tr
-# @protocol.pictures.each do |pic|
-#%td
-#= pic.id
%h2
Данные с копии
Expand Down
6 changes: 3 additions & 3 deletions config/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
#task :before_symlink do
before :symlink do
# public/uploads
#run "rm -drf #{release_path}/public/uploads"
#run "ln -s #{shared_path}/uploads #{release_path}/public/uploads"
run "rm -drf #{release_path}/public/uploads"
run "ln -s #{shared_path}/uploads #{release_path}/public/uploads"
run "ln -s #{shared_path}/database.yml #{release_path}/config/database.yml"
#run "rmdir #{current_release}/public/assets" # remove the folder present for development
#run "ln -s #{deploy_to}/#{shared_dir}/assets #{current_release}/public"

# vendor/radiant
#run "rm -drf #{release_path}/vendor/radiant"
#run "ln -s #{shared_path}/radiant #{release_path}/vendor/radiant"
#run "rm -f #{release_path}/config/database.yml"
#run "ln -s #{shared_path}/database.yml #{release_path}/config/database.yml"
end
end
=begin
Expand Down
2 changes: 1 addition & 1 deletion config/deploy/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# git and Auth
set :scm, :git
set :repository, "[email protected]:jesteracer/nk12.git"
set :branch, "production"
#set :branch, "production"
set :deploy_via, :remote_cache

set :user, 'nk12'
Expand Down
Loading

0 comments on commit c689a1a

Please sign in to comment.