From 6f55352d8c8d05f1e3b5149920fe99f945d2b532 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 18 Feb 2014 20:43:52 +0800 Subject: [PATCH 1/3] module and template site registration completed --- .../admin/module_store_controller.rb | 10 ++- .../admin/site_registration_controller.rb | 12 +++ .../admin/template_store_controller.rb | 12 ++- app/controllers/application_controller.rb | 6 +- app/models/site.rb | 4 +- app/views/admin/module_store/index.html.erb | 5 +- .../_site_registration.html.erb | 86 +++++++++++++++++++ .../admin/site_registration/index.html.erb | 1 + app/views/admin/sites/register_site.html.erb | 1 + config/routes.rb | 6 ++ lib/store.rb | 4 +- 11 files changed, 134 insertions(+), 13 deletions(-) create mode 100644 app/controllers/admin/site_registration_controller.rb create mode 100644 app/views/admin/site_registration/_site_registration.html.erb create mode 100644 app/views/admin/site_registration/index.html.erb create mode 100644 app/views/admin/sites/register_site.html.erb diff --git a/app/controllers/admin/module_store_controller.rb b/app/controllers/admin/module_store_controller.rb index 38a1354..86ab188 100644 --- a/app/controllers/admin/module_store_controller.rb +++ b/app/controllers/admin/module_store_controller.rb @@ -1,9 +1,13 @@ class Admin::ModuleStoreController < OrbitBackendController - before_filter :check_central_server_connection def index - @extensions = get_extensions - @downloaded_extensions = get_downloaded_extension + if get_site.site_token? + @extensions = get_extensions + @downloaded_extensions = get_downloaded_extension + else + @extensions = [] + @downloaded_extensions = get_downloaded_extension + end end def show diff --git a/app/controllers/admin/site_registration_controller.rb b/app/controllers/admin/site_registration_controller.rb new file mode 100644 index 0000000..098d633 --- /dev/null +++ b/app/controllers/admin/site_registration_controller.rb @@ -0,0 +1,12 @@ +class Admin::SiteRegistrationController < OrbitBackendController + def index + @site = Site.first + render :layout => false + end + + def register + @site = Site.find(params[:site][:id]) + response = @site.register_site(params[:site][:url],params[:site][:university],params[:site][:department],params[:site][:email],params[:site][:country]) + render :json => response.to_json + end +end \ No newline at end of file diff --git a/app/controllers/admin/template_store_controller.rb b/app/controllers/admin/template_store_controller.rb index 7e07067..5bc8d93 100644 --- a/app/controllers/admin/template_store_controller.rb +++ b/app/controllers/admin/template_store_controller.rb @@ -3,13 +3,17 @@ require 'uri' require 'fileutils' require 'zip/zip' class Admin::TemplateStoreController < OrbitBackendController - before_filter :check_central_server_connection before_filter :set_store def index - @design_ids = Design.all.map{|d| d.template_store_id} - @templates = get_templates.parsed_response - render :layout => false + @site = Site.first + if @site.site_token? + @design_ids = Design.all.map{|d| d.template_store_id} + @templates = get_templates.parsed_response + render :layout => false + else + render :partial => "admin/site_registration/site_registration" + end end def show diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4f4549f..2f9882a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -483,11 +483,15 @@ class ApplicationController < ActionController::Base if @site.site_token? flash[:notice]="Connected to the Store" else - redirect_to admin_sites_register_site_path + redirect_to admin_site_registration_path flash[:notice]="To Access the Store Please Connect It" end end + def site_token_present? + @site.site_token? + end + def store_session api_key = STORE_CONFIG[:store_settings]["api_key"] @store = Store.new(@site.id.to_s,@site.site_token,api_key) if @site.site_token diff --git a/app/models/site.rb b/app/models/site.rb index 3ea5251..794d843 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -104,11 +104,11 @@ class Site end end - def register_site + def register_site(url,university,department,email,country) api_key = STORE_CONFIG[:store_settings]["api_key"] self.generate_site_token store = Store.new(self.id.to_s,self.site_token,api_key) - store.post_client(self.id.to_s,self.site_token,self.title) + store.post_client(self.id.to_s,self.site_token,self.title,url,university,department,email,country) end end diff --git a/app/views/admin/module_store/index.html.erb b/app/views/admin/module_store/index.html.erb index d9d10eb..15ced10 100644 --- a/app/views/admin/module_store/index.html.erb +++ b/app/views/admin/module_store/index.html.erb @@ -184,6 +184,9 @@
<%= t(:module_store) %>
+ <% if @extensions.empty? %> + <%= render :partial => "admin/site_registration/site_registration" %> + <% else %> @@ -215,7 +218,7 @@ <% end %>
- + <% end %>
diff --git a/app/views/admin/site_registration/_site_registration.html.erb b/app/views/admin/site_registration/_site_registration.html.erb new file mode 100644 index 0000000..2e38a00 --- /dev/null +++ b/app/views/admin/site_registration/_site_registration.html.erb @@ -0,0 +1,86 @@ +
+ +
+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+ + \ No newline at end of file diff --git a/app/views/admin/site_registration/index.html.erb b/app/views/admin/site_registration/index.html.erb new file mode 100644 index 0000000..cf4ebeb --- /dev/null +++ b/app/views/admin/site_registration/index.html.erb @@ -0,0 +1 @@ +<%= render :partial=> "site_registration" %> \ No newline at end of file diff --git a/app/views/admin/sites/register_site.html.erb b/app/views/admin/sites/register_site.html.erb new file mode 100644 index 0000000..2515229 --- /dev/null +++ b/app/views/admin/sites/register_site.html.erb @@ -0,0 +1 @@ +This is index \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index af22d24..8631269 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -263,6 +263,12 @@ Orbit::Application.routes.draw do end end + match 'site_registration/register' => 'site_registration#register' + resources :site_registration do + end + + + match 'module_store' => 'module_store#index' match 'module_store/show' => 'module_store#show' match 'module_store/download' => 'module_store#download' diff --git a/lib/store.rb b/lib/store.rb index 3d8e400..0dde702 100644 --- a/lib/store.rb +++ b/lib/store.rb @@ -45,8 +45,8 @@ class Store self.class.get("/extensions/#{id}", options) end - def post_client(site_id,site_token,site_name) - options = @options_for_client.merge({ :body => {:site_name => site_name, :site_id => site_id, :site_token => site_token}.to_json }) + def post_client(site_id,site_token,site_name,url,university,department,email,country) + options = @options_for_client.merge({ :body => {:site_name => site_name, :site_id => site_id,:url => url, :university => university, :department => department, :email => email, :country => country, :site_token => site_token}.to_json }) self.class.post('/clients', options ) end end \ No newline at end of file From 090af47b7b6cedb52200905bb007f89a303e358e Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Wed, 19 Feb 2014 16:02:59 +0800 Subject: [PATCH 2/3] Change register url from domain to host --- app/views/admin/site_registration/_site_registration.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/admin/site_registration/_site_registration.html.erb b/app/views/admin/site_registration/_site_registration.html.erb index 2e38a00..224713d 100644 --- a/app/views/admin/site_registration/_site_registration.html.erb +++ b/app/views/admin/site_registration/_site_registration.html.erb @@ -20,9 +20,9 @@
- +
- +
From 2f87ce09a40a90f9a4a964894399f8d7d951b05e Mon Sep 17 00:00:00 2001 From: Manson Wang Date: Fri, 21 Feb 2014 15:13:25 +0800 Subject: [PATCH 3/3] Widget enable column_title by default --- lib/orbit_app/module/widget.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/orbit_app/module/widget.rb b/lib/orbit_app/module/widget.rb index 1ca4cac..ca5fd56 100644 --- a/lib/orbit_app/module/widget.rb +++ b/lib/orbit_app/module/widget.rb @@ -26,8 +26,6 @@ module OrbitApp def initialize(name,key,&block) @widgets = [] @default_widget = nil - @widget_title_enabled = true - @column_title_enabled = false @categories_query = '' @tags_query = '' block.arity < 1 ? instance_eval(&block) : block.call(self) if block_given? @@ -103,8 +101,8 @@ module OrbitApp def initialize(&block) @query = nil - @widget_title_enabled = true - @column_title_enabled = false + @widget_title_enabled = false + @column_title_enabled = true @image = nil @more_link = {} @fields = []