Ejemplo n.º 1
0
Archivo: admin.py Proyecto: simone/upy
 def formfield_for_foreignkey(self, db_field, request, **kwargs):
     if db_field.name == "publication":
         if Publication.get_default():
             kwargs['initial'] = Publication.get_default().pk
     if db_field.name == "language":
         if Language.get_default():
             kwargs['initial'] = Language.get_default().pk
     return super(G11nAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
Ejemplo n.º 2
0
 def handle(self, *args, **options):
     projname = nameproj()
     self.stdout.write("Creating instances...")
     
     if settings.USE_UPY_G11N:
         try:
             publication = Publication.objects.get(default=True)
             self.stdout.write("Default Publication already exists!")
             return
         except:
             self.stdout.write("Creating language")
             try:
                 language = Language.objects.get(name=getattr(settings,'LANGUAGE_DEFAULT_PARAM','italian'),
                                 code=getattr(settings,'LANGUAGE_CODE','it-it'),
                                 alias=getattr(settings,'LANGUAGE_DEFAULT_ALIAS','IT'))
             except:
                 
                 language = Language(name=getattr(settings,'LANGUAGE_DEFAULT_PARAM','italian'),
                                 code=getattr(settings,'LANGUAGE_CODE','it-it'),
                                 alias=getattr(settings,'LANGUAGE_DEFAULT_ALIAS','IT'))
                 language.save()
             self.stdout.write("Creating publication")
             publication = Publication(name=projname,
                                       url="127.0.0.1:8080",
                                       default_language=language,
                                       )
             publication.save()
             publication.languages.add(language)
             self.stdout.write("Creating publication g11n")
             pub_g11n = PublicationG11n(title = projname,
                                        language=language,
                                        publication=publication)
             pub_g11n.save()
             
             if settings.USE_UPY_TREE:
                 self.stdout.write("Creating root node")
                 root = Node(name='root')
                 root.save()
                 self.stdout.write("Creating tree structure")
                 treestruct = TreeStructure(name='base',tree_root=root)
                 treestruct.save()
                 self.stdout.write("Creating publication extended")
                 pub_ext = PublicationExtended(tree_structure=treestruct,publication=publication)
                 pub_ext.save()
     
     if settings.USE_CUSTOM_ADMIN:
         try:
             customadmin = CustomAdmin.objects.get(default=True)
             self.stdout.write("Default CustomAdmin already exists!")
             return
         except:
             self.stdout.write("Creating customadmin")
             customadmin = CustomAdmin(branding=projname,default=True,
                                       view_mode='use_app_and_model_icons')
             customadmin.save()
     self.stdout.write("Done!")
Ejemplo n.º 3
0
Archivo: admin.py Proyecto: simone/upy
 def formfield_for_foreignkey(self, db_field, request, **kwargs):
     if db_field.name == "publication":
         if Publication.get_default():
             kwargs['initial'] = Publication.get_default().pk
     if db_field.name == "language":
         if Language.get_default():
             kwargs['initial'] = Language.get_default().pk
     return super(G11nAdmin,
                  self).formfield_for_foreignkey(db_field, request,
                                                 **kwargs)