Commits

Lukasz Balcerzak committed c44fa7d

Fixes #32 - introduced PROJECTOR_HG_PUSH_SSL setting

  • Participants
  • Parent commits e951150

Comments (0)

Files changed (5)

docs/configuration.rst

 
 Email address used as sender for all mails send by projector.
 
+.. setting:: PROJECTOR_HG_PUSH_SSL
+
+PROJECTOR_HG_PUSH_SSL
+---------------------
+
+Default: ``False``.
+
+If set to ``True``, underlying mercurial engine would transmit data using
+encryption. This setting has precedence over vcs specific configuration.
+
 .. setting:: PROJECTOR_HIDDEN_EMAIL_SUBSTITUTION
 
 PROJECTOR_HIDDEN_EMAIL_SUBSTITUTION

example_project/settings.py

 abspath = lambda *p: os.path.abspath(os.path.join(*p))
 
 DEBUG = True
+PROJECTOR_HG_PUSH_SSL = False
 
 PROJECT_ROOT = abspath(os.path.dirname(__file__))
 PROJECTOR_MODULE_PATH = abspath(PROJECT_ROOT, '..')

example_project/settings_test.py

 
 PROJECTOR_DEFAULT_PROJECT_WORKFLOW = 'projector.tests.workflow.TestWorkflow'
 PROJECTOR_PROJECTS_HOMEDIR_GETTER = 'projector.tests.base.get_homedir'
+PROJECTOR_HG_PUSH_SSL = False
 
 # Hide logging messages
 DJALOG_LEVEL = 50

projector/settings.py

 
 from django.conf import settings
 
+from vcs.web.simplevcs import settings as vcs_settings
+
 abspath = lambda *p: os.path.abspath(os.path.join(*p))
 
 ALWAYS_SEND_MAILS_TO_MEMBERS = getattr(settings,
 ENABLED_VCS_BACKENDS = getattr(settings,
     'PROJECTOR_ENABLED_VCS_BACKENDS', ['hg', 'git'])
 
-FROM_EMAIL_ADDRESS = settings.DEFAULT_FROM_EMAIL
-
 FORK_EXTERNAL_ENABLED = getattr(settings,
     'PROJECTOR_FORK_EXTERNAL_ENABLED', False)
 
     }
 )
 
+FROM_EMAIL_ADDRESS = settings.DEFAULT_FROM_EMAIL
+
+HG_PUSH_SSL = getattr(settings, 'PROJECTOR_HG_PUSH_SSL',
+        getattr(vcs_settings, 'PUSH_SSL', False))
+
 HIDDEN_EMAIL_SUBSTITUTION = getattr(settings,
     'PROJECTOR_HIDDEN_EMAIL_SUBSTITUTION', u'email')
 
     'FORK_EXTERNAL_ENABLED': FORK_EXTERNAL_ENABLED,
     'FORK_EXTERNAL_MAP': FORK_EXTERNAL_MAP,
     'FROM_EMAIL_ADDRESS': settings.DEFAULT_FROM_EMAIL,
+    'HG_PUSH_SSL': HG_PUSH_SSL,
+    'HIDDEN_EMAIL_SUBSTITUTION': HIDDEN_EMAIL_SUBSTITUTION,
     'MAX_PROJECTS_PER_USER': MAX_PROJECTS_PER_USER,
     'MILESTONE_DEADLINE_DELTA': MILESTONE_DEADLINE_DELTA,
     'MILIS_BETWEEN_PROJECT_CREATION': MILIS_BETWEEN_PROJECT_CREATION,

projector/views/project.py

 from projector.settings import get_config_value
 from projector.signals import setup_project
 
-from vcs.web.simplevcs import settings as simplevcs_settings
 from vcs.web.simplevcs.utils import get_mercurial_response, is_mercurial
 from vcs.web.simplevcs.utils import log_error, basic_auth, ask_basic_auth
 from vcs.web.simplevcs.exceptions import NotMercurialRequest
     if request.method not in ('GET', 'POST'):
         raise NotMercurialRequest("Only GET/POST methods are allowed, got %s"
             % request.method)
+    PUSH_SSL = get_config_value('HG_PUSH_SSL') and 'true' or 'false'
     # Allow to read from public projects
     if project.is_public() and request.method == 'GET':
         mercurial_info = {
             'repo_path': project._get_repo_path(),
-            'push_ssl': simplevcs_settings.PUSH_SSL,
+            'push_ssl': PUSH_SSL,
         }
         return get_mercurial_response(request, **mercurial_info)
 
 
     mercurial_info = {
         'repo_path': project._get_repo_path(),
-        'push_ssl': simplevcs_settings.PUSH_SSL,
+        'push_ssl': PUSH_SSL,
     }
 
     if request.user and request.user.is_active: