Skip to content

Commit

Permalink
Добавлен твиттер на главную и индек в протокол
Browse files Browse the repository at this point in the history
  • Loading branch information
oshlykov committed Mar 10, 2012
1 parent f21f1f9 commit 00188c4
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 11 deletions.
17 changes: 16 additions & 1 deletion app/assets/stylesheets/application.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ body{
// padding-top: 90px;
}

h1,h2,h3,h4 {
padding-top: 0.5em;
}

.container {
padding: 0 25px;
}
Expand Down Expand Up @@ -96,4 +100,15 @@ a.brand:hover { text-decoration: underline }

//form .clearfix:before, form .clearfix:after {
// display: inline;
//}
//}

// Twitter embeded

div.twtr-widget div.twtr-tweet-wrap {
padding-left: 0px;
}

img.twtr-profile-img,.twtr-ft a img, .twtr-widget h3, .twtr-ft div, div.twtr-hd {
display:none;
}

2 changes: 1 addition & 1 deletion app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ def index
@checked_count_2 = Protocol.where('priority = 1 and commission_id >= 200000').size
@unchecked_count_2 = Protocol.where('priority > 1 and commission_id >= 200000').size
# @protocols_new = Protocol.joins('INNER JOIN commissions c ON c.id = Protocols.commission_id').where("priority = 1 and commission_id >=200000").limit(40).all(:order => "created_at")
@protocols_new = Protocol.includes(:commission).where("priority = 1 and commission_id >=200000").limit(20).all(:order => "created_at")
@protocols_new = Protocol.includes(:commission).where("priority = 1 and commission_id >=200000").limit(18).all(:order => "created_at")

@users_count = User.count
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/commission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def self.voting_table(commission)
p.save
commission.state ||= Hash.new
commission.state[:uik] = p.votings
return commission.save if karik = commission.protocols.find_by_priority(1)
return commission.save unless karik = commission.protocols.find_by_priority(1)
#Обновление кэша
conflict = false
karik.votings.each_with_index do |v,i|
Expand Down
31 changes: 25 additions & 6 deletions app/views/commissions/_commissions_region.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,46 @@
.span9
%div.navigation-holder
%a.show-navigation{:href=>"#"}
= @commission.name
Содержание
-#@commission.name
%div.tree-navigation
%br
- @commission.subtree.where(:is_uik => false).all.each do |c|
- if c = @commission
%div.tree-node-holder{"id" => c.id, "class" => "depth-#{c.depth}"}
%div.node-name
%div.name
%h3{"id"=>c.id,"data-depth"=>c.depth}
- if c.uik_holder
%a.load-new.ajax{ :href => "##{c.id}" }
=raw "#{c.name} "
%sup
%small{:title => "собрано протоколов / всего протоколов"}
- if (c_size = c.descendants.where('votes_taken=true').size) > 0
= "#{c_size}/#{c.descendants.size} "
- else
=raw "#{c.name} "
%sup
%small= link_to('цик', c.url)
- if c.uik_holder
%div.votings{"data-id"=>c.id, "data-loaded"=>"false", "data-url"=>"/uik/#{c.id}"}
%div.loading
= image_tag('ajax-loader.gif')
- @commission.descendants.where(:is_uik => false).all.each do |c|
-# if c.depth != @commission.depth
%div.tree-node-holder{"id" => c.id, "class" => "depth-#{c.depth}"}
%div.node-name
%div.name
%h3{"id"=>c.id,"data-depth"=>c.depth}
- if c.uik_holder
%a.load-new.ajax{ :href => "##{c.id}" }
= c.name
=raw "#{c.name} "
%sup
%small{:title => "собрано протоколов / всего протоколов"}
- if (c_size = c.descendants.where('votes_taken=true').size) > 0
= "#{c_size}/#{c.descendants.size}"
- else
= c.name
=raw "#{c.name} "
%sup
%small= link_to('цик', c.url)
.clearfix
- if c.uik_holder
%div.votings{"data-id"=>c.id, "data-loaded"=>"false", "data-url"=>"/uik/#{c.id}"}
%div.loading
Expand Down
35 changes: 34 additions & 1 deletion app/views/home/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,40 @@
%sup
%small.green{:title => "В ожидании проверки"}= "(#{@unchecked_count_2})"
.span4
%h2 Живая лента
- if !social_enable
%h2
%a{:href=>'http://twitter.com/kariksu'} Твиттер
%div{:style => "height: 161px"}
%script{:charset=>"utf-8", :src=>"http://widgets.twimg.com/j/2/widget.js"}
%script(type="text/javascript")
:plain
new TWTR.Widget({
version: 2,
type: 'profile',
rpp: 6,
interval: 30000,
width: 300,
height: 100,
theme: {
shell: {
background: '#ffffff',
color: '#000000'
},
tweets: {
background: '#ffffff',
color: '#4a404a',
links: '#1f3885'
}
},
features: {
scrollbar: true,
loop: false,
live: false,
behavior: "all"
}
}).render().setUser("KarikSu").start();

%h2 Новые протоколы
%table.voting-table.table
%tr
%th{:width => "100px"}
Expand Down
25 changes: 24 additions & 1 deletion console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,30 @@
end
end


# загрузка структуры уиков
Commission.roots.each do |c|
Commission.get_children(c)
end

#стягивание всех данных по голосованиям с сайта ЦИК
cs = Commission.where("voting_table_url IS NOT NULL and election_id=2").size
Parallel.each(cs, :in_threads => 8){ |c| Commission.voting_table(c) }

#особое обновление, кеширования - разовый случай
Commission.where("election_id=2 and voting_table_url IS NOT NULL and state NOT LIKE '%:uik%'").each do |commission|
if commission.voting_table_url and uik = commission.protocols.find_by_priority(0)
commission.state ||= Hash.new
commission.state[:uik] = uik.votings
if karik = commission.protocols.find_by_priority(1)
#Обновление кэша
conflict = false
karik.votings.each_with_index do |v,i|
# karik.size-1 так как неучитываем последгний столбец с кол заявлений
conflict = true if commission.state[:checked][i] != commission.state[:uik][i] and i != karik.size-1
end
commission.conflict = conflict
commission.votes_taken = true
end
commission.save
end
end
5 changes: 5 additions & 0 deletions db/migrate/20120310063911_add_commission_index_to_protocol.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCommissionIndexToProtocol < ActiveRecord::Migration
def change
add_index :protocols, :commission_id
end
end

0 comments on commit 00188c4

Please sign in to comment.