| 
									
										
										
										
											2018-03-29 00:43:38 +05:30
										 |  |  | from django.core.management.base import BaseCommand | 
					
						
							|  |  |  | from datacenterlight.cms_models import CMSIntegration | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Command(BaseCommand): | 
					
						
							|  |  |  |     help = '''Creates cms integration objects for datacenterlight''' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def handle(self, *args, **options): | 
					
						
							| 
									
										
										
										
											2018-04-03 22:41:29 +05:30
										 |  |  |         self.create_cms_integration() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def create_cms_integration(self, site=None): | 
					
						
							|  |  |  |         obj, created = CMSIntegration.objects.get_or_create( | 
					
						
							|  |  |  |             name='default', domain=site | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         domain_name = site.domain if site else 'All Sites' | 
					
						
							| 
									
										
										
										
											2018-03-29 00:43:38 +05:30
										 |  |  |         if created: | 
					
						
							| 
									
										
										
										
											2018-04-03 22:41:29 +05:30
										 |  |  |             print('created the default CMSIntegration object for', domain_name) | 
					
						
							| 
									
										
										
										
											2018-03-29 00:43:38 +05:30
										 |  |  |         else: | 
					
						
							| 
									
										
										
										
											2018-04-03 22:41:29 +05:30
										 |  |  |             print( | 
					
						
							|  |  |  |                 'default CMSIntegration object already exists for', domain_name | 
					
						
							|  |  |  |             ) |