| 
									
										
										
										
											2011-04-13 10:19:51 +00:00
										 |  |  | class Site | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   include Mongoid::Document | 
					
						
							| 
									
										
										
										
											2011-03-08 09:25:46 +00:00
										 |  |  |   include Mongoid::Timestamps | 
					
						
							| 
									
										
										
										
											2011-04-13 10:19:51 +00:00
										 |  |  |    | 
					
						
							|  |  |  |   field :in_use_locales, :type => Array | 
					
						
							|  |  |  |   field :valid_locales, :type => Array | 
					
						
							|  |  |  |    | 
					
						
							| 
									
										
										
										
											2011-08-18 05:43:33 +00:00
										 |  |  |   field :roaming_id | 
					
						
							|  |  |  |   field :private_key, :type => Binary | 
					
						
							|  |  |  |   field :public_key, :type => Binary | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   field :school | 
					
						
							|  |  |  |   field :department | 
					
						
							| 
									
										
										
										
											2012-03-21 10:30:12 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   has_many :site_metas, :autosave => true, :dependent => :destroy | 
					
						
							| 
									
										
										
										
											2011-08-18 05:43:33 +00:00
										 |  |  |    | 
					
						
							|  |  |  |   def generate_keys | 
					
						
							|  |  |  |     private_key = OpenSSL::PKey::RSA.generate(2048) | 
					
						
							|  |  |  |     self.public_key = private_key.public_key.to_s | 
					
						
							|  |  |  |     self.private_key = private_key.to_s | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							|  |  |  |   def registered? | 
					
						
							|  |  |  |     !self.roaming_id.blank? | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							| 
									
										
										
										
											2011-08-23 11:40:49 +00:00
										 |  |  |   def up_to_date? | 
					
						
							|  |  |  |     p res = %x(git remote show origin) | 
					
						
							| 
									
										
										
										
											2011-08-25 00:30:09 +00:00
										 |  |  |     res = res.split('rails_3_1').pop.gsub('(', '').gsub(')','').strip rescue nil | 
					
						
							| 
									
										
										
										
											2011-08-23 11:40:49 +00:00
										 |  |  |     res.eql?('local out of date') ? false : true | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  |    | 
					
						
							| 
									
										
										
										
											2011-04-13 10:19:51 +00:00
										 |  |  | end |