diff --git a/app/models/site.rb b/app/models/site.rb index 11d1c768f..77571470c 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -13,6 +13,8 @@ class Site field :school field :department + field :up_to_date, :type => Boolean + def generate_keys private_key = OpenSSL::PKey::RSA.generate(2048) self.public_key = private_key.public_key.to_s diff --git a/app/views/admin/sites/_registration.html.erb b/app/views/admin/sites/_registration.html.erb new file mode 100644 index 000000000..2ed16ab72 --- /dev/null +++ b/app/views/admin/sites/_registration.html.erb @@ -0,0 +1,7 @@ +<% if @site && @site.registered? %> + <%= t('admin.registered') %> +<% else %> + <%= link_to 'register', "http://#{APP_CONFIG['store_ip']}/user/sites/register?" + + {:site => {:school => @site.school, :department => @site.department}}.to_query, + :target => '_blank' %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/sites/_update.html.erb b/app/views/admin/sites/_update.html.erb new file mode 100644 index 000000000..09bb04f3c --- /dev/null +++ b/app/views/admin/sites/_update.html.erb @@ -0,0 +1,5 @@ +<% if @site.up_to_date %> + <%= t('admin.up_to_date') %> +<% else %> + <%= link_to t(:update), site_update_path %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/sites/index.html.erb b/app/views/admin/sites/index.html.erb index 80931f912..20ab5c0be 100644 --- a/app/views/admin/sites/index.html.erb +++ b/app/views/admin/sites/index.html.erb @@ -1,7 +1,3 @@ -<% if @site && @site.registered? %> - registered -<% else %> - <%= link_to 'register', "http://#{APP_CONFIG['store_ip']}/user/sites/register?" + - {:site => {:school => @site.school, :department => @site.department}}.to_query, - :target => '_blank' %> -<% end %> \ No newline at end of file +<%= render 'registration' %> + +<%= render 'update' %> \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index edce29a50..58360b5c5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -40,6 +40,7 @@ en: data: Data delete_language: Delete language description: Description + design: Design disable_language: Disable language editing_home: Editing homepage editing_layout: Editing layout @@ -85,11 +86,14 @@ en: orig_upload_file: Original filename position: Position published?: Published? + purchase: Purchase info: Information + registered: Registered role: Role title: Title translation: Translation type: Type + up_to_date: Up-do-date update_error_link: Error when updating link. update_error_page: Error when updating page. update_success_content: Content was successfully updated. diff --git a/config/routes.rb b/config/routes.rb index 63f56bb33..ceb4aab7a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -5,6 +5,7 @@ PrototypeR4::Application.routes.draw do # routes for sinatra app match '/site/set_registered', :to => CentralServerExchangeApp match '/site/public_key', :to => CentralServerExchangeApp + match '/site/update', :to => GithubApp match '/purchase/design', :to => CentralServerExchangeApp # routes for admin diff --git a/lib/github_app.rb b/lib/github_app.rb new file mode 100644 index 000000000..c1234d124 --- /dev/null +++ b/lib/github_app.rb @@ -0,0 +1,13 @@ +class GithubApp < Sinatra::Base + + before do + @site = Site.first + end + + get '/site/update' do + updated = system('git pull') + @site.update_attribute(:up_to_date, true) if updated + redirect "admin/sites?updated=#{updated}" + end + +end \ No newline at end of file