Commits

Viorel Stirbu committed 25b6c2b

use dbsettings to configure Ancora server address

  • Participants
  • Parent commits 072d1b0

Comments (0)

Files changed (7)

atexpc/atex_web/models.py

 from django.template.defaultfilters import slugify
 from sorl.thumbnail import ImageField
 from dropbox import rest, session, client
+import dbsettings
 
 from atexpc.ancora_api.api import Ancora, AncoraAdapter
 
 logger = logging.getLogger(__name__)
 
 
+class SiteOptions(dbsettings.Group):
+    ancora_server = dbsettings.StringValue('Ancora server address (or IP)',
+                                           default='ancora.atexpc.ro')
+options = SiteOptions()
+
+
 class AncoraMixin(object):
     def __init__(self, *args, **kwargs):
         super(AncoraMixin, self).__init__(*args, **kwargs)
-        self._ancora = Ancora(adapter=AncoraAdapter(settings.ANCORA_URI))
+        ancora_server = options.ancora_server
+        ancora_url = "http://%s:8765/ancoraerp/jis.serv?database=atex" % ancora_server
+        self._ancora = Ancora(adapter=AncoraAdapter(ancora_url))
+
 
 class Categories(AncoraMixin):
     def get_all(self):

atexpc/config/dev.py

 #    'storages',
     'sorl.thumbnail',
     'debug_toolbar',
+    'dbsettings',
     'atexpc.atex_web',
 )
 

atexpc/config/production.py

     'south',
     'storages',
     'sorl.thumbnail',
+    'dbsettings',
     'atexpc.atex_web',
 )
 

atexpc/config/staging.py

     'storages',
     'sorl.thumbnail',
     'debug_toolbar',
+    'dbsettings',
     'atexpc.atex_web',
 )
 

atexpc/settings.py

 
 PROJECT_ROOT = os.path.dirname(os.path.realpath(__file__))
 
-ANCORA_URI = os.environ.get('ANCORA_URI')
-
 DROPBOX_APP_KEY = os.environ.get('DROPBOX_APP_KEY')
 DROPBOX_APP_SECRET = os.environ.get('DROPBOX_APP_SECRET')
 DROPBOX_ACCESS_TYPE = os.environ.get('DROPBOX_ACCESS_TYPE', 'dropbox')
 
     # Uncomment the next line to enable the admin:
     url(r'^admin/', include(admin.site.urls)),
+
+    # dbsettings
+    url(r'^settings/', include('dbsettings.urls')),
 )
 
 handler404 = ErrorView.as_view(error_code=404)

requirements/common.txt

 PIL==1.1.7
 dropbox==1.4.0
 django-compressor==1.2
+git+git://github.com/zlorf/django-dbsettings.git@2dae0fe7f7