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 @@