Skip to content

Commit

Permalink
Merge pull request #253 from transtats/bugfix
Browse files Browse the repository at this point in the history
few more fixes
  • Loading branch information
sdp5 committed Jun 15, 2021
2 parents 27e460e + 9fb0d26 commit 2a46066
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 19 deletions.
4 changes: 2 additions & 2 deletions dashboard/jobs_framework/action_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def platform_pot_file(self, input, kwargs):
self.sandbox_path + 'platform.' + input.get('i18n_domain') + '.pot',
headers=headers
)
probable_versions = ('master', 'default', input['package'])
probable_versions = ('main', 'master', 'default', input['package'])
while_loop_counter = 0
while platform_pot_path == '404' and while_loop_counter < len(probable_versions):
url_kwargs['version'] = probable_versions[while_loop_counter]
Expand Down Expand Up @@ -510,7 +510,7 @@ def git_repository(self, input, kwargs):
task_log.update(self._log_task(
input['log_f'], task_subject, 'Cloning failed. Details: %s' % trace_back
))
raise Exception("Cloning '%s' branch failed." % kwargs.get('branch', 'master'))
raise Exception("Cloning '%s' branch failed." % kwargs.get('branch', 'main'))
else:
if vars(clone_result).get('git_dir'):
task_log.update(self._log_task(
Expand Down
5 changes: 2 additions & 3 deletions dashboard/managers/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def get_locales_from_territory_id(self, territory_id):
return territory_locales, territory_languages, ''
two_char_country_code = COUNTRY_CODE_3to2_LETTERS.get(territory_id, '')
if not two_char_country_code:
return territory_locales, ''
return territory_locales, territory_languages, ''
territory_locales = langtable.list_locales(
territoryId=two_char_country_code
)
Expand Down Expand Up @@ -773,8 +773,7 @@ def get_territory_summary(self, territory_id):
:param territory_id: three characters country code
:return: related stats: dict
"""
related_locales, related_langs, country_code = \
self.get_locales_from_territory_id(territory_id)
related_locales, _, _ = self.get_locales_from_territory_id(territory_id)
location_summary = self.get_reports(report_subject='location')

if not related_locales or not location_summary:
Expand Down
2 changes: 1 addition & 1 deletion dashboard/managers/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ def get_product_by_release(self, release_slug):
def get_relbranch_name_slug_tuple(self):
"""
Get release branch slug and name tuple
:return: (('master', 'master'), )
:return: (('main', 'main'), )
"""
release_branches = self.get_release_branches(
fields=('release_slug', 'release_name', 'track_trans_flag')
Expand Down
9 changes: 5 additions & 4 deletions dashboard/managers/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ def git_branches(self, package_name, repo_type='default', release=None):
:param release: Release Slug
:return: git branch(es)
"""
default_branch = ['master']
default_branch = ['main']
package = self.get_packages([package_name])
if not package:
return default_branch
Expand Down Expand Up @@ -1044,7 +1044,7 @@ def calculate_branch_mapping(self, branch, from_branches):
2. sort versions matching stream and then try to match version number
3. try short forms combined with version number
4. todo: fetch release dates and try matching with that
5. try finding default version: 'master' may be
5. try finding default version: 'main' may be
6. if nothing works, return blank
"""
match1 = difflib.get_close_matches(branch, from_branches)
Expand All @@ -1061,8 +1061,9 @@ def calculate_branch_mapping(self, branch, from_branches):
if status2:
return self._return_original_version(match3)

probable_branches = ['default', 'master', 'head', 'rawhide', 'devel', 'app',
'core', 'translations', 'programs', self.package_name]
probable_branches = ['default', 'main', 'master', 'head',
'rawhide', 'devel', 'app', 'core',
'translations', 'programs', self.package_name]

for version in probable_branches:
if version in from_branches:
Expand Down
2 changes: 1 addition & 1 deletion dashboard/tests/test_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ def xtest_git_branches(self):
repo_type='l10n'
)
self.assertEqual(len(scm_branch), 2)
self.assertListEqual(scm_branch, ['autoupdate-potfiles', 'master'])
self.assertListEqual(scm_branch, ['autoupdate-potfiles', 'main'])
8 changes: 3 additions & 5 deletions dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def get_success_url(self):

def get_initial(self):
initials = {}
initials.update(dict(rule_relbranch='master'))
initials.update(dict(rule_relbranch='main'))
return initials

def get_form(self, form_class=None, data=None):
Expand Down Expand Up @@ -1176,10 +1176,8 @@ def schedule_job(request):
)
try:
job_uuid = job_manager.execute_job()
except Exception as e:
error_msg = str(e) if len(str(e)) < 50 else str(e)[:50] + '...'
message = "&nbsp;&nbsp;<span class='text-danger'>Alas! Something unexpected happened.<br/>" \
"&nbsp;&nbsp;<small class='text-danger'>" + error_msg + " </small></span>"
except Exception:
message = "&nbsp;&nbsp;<span class='text-danger'>Alas! Something unexpected happened.</span>"
return HttpResponse(message, status=500)
else:
if not request.POST.dict().get('SCRATCH', '') == 'ScratchRun':
Expand Down
22 changes: 20 additions & 2 deletions transtats/settings/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@
app_config_vars, INSTALLED_APPS, AUTHENTICATION_BACKENDS
)

__all__ = [
'FAS_AUTH',
'ADMINS',
'SECURE_PROXY_SSL_HEADER',
'ADMIN_INITIAL_PASSWORD',
'INSTALLED_APPS',
'AUTHENTICATION_BACKENDS',
'OIDC_RP_CLIENT_ID',
'OIDC_RP_CLIENT_SECRET',
'OIDC_OP_AUTHORIZATION_ENDPOINT',
'OIDC_OP_TOKEN_ENDPOINT',
'OIDC_OP_USER_ENDPOINT',
'OIDC_OP_JWKS_ENDPOINT',
'OIDC_RP_SIGN_ALGO',
'LOGOUT_REDIRECT_URL',
'REST_FRAMEWORK',
'CORS_ORIGIN_ALLOW_ALL'
]

FAS_AUTH = app_config_vars('TS_AUTH_SYSTEM') == 'fedora'

ADMINS = (
Expand Down Expand Up @@ -36,5 +55,4 @@
)
}

if FAS_AUTH:
CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_ALLOW_ALL = True if FAS_AUTH else False
33 changes: 33 additions & 0 deletions transtats/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,39 @@
# Core Django imports
from django.core.exceptions import ImproperlyConfigured

__all__ = [
'BASE_DIR',
'SECRET_KEY',
'INSTALLED_APPS',
'MIDDLEWARE',
'ROOT_URLCONF',
'TEMPLATES',
'AUTHENTICATION_BACKENDS',
'SESSION_ENGINE',
'SESSION_COOKIE_SECURE',
'WSGI_APPLICATION',
'LOGIN_REDIRECT_URL',
'CELERY_BROKER_URL',
'CELERY_TASK_SERIALIZER',
'CELERY_RESULT_SERIALIZER',
'CELERY_ACCEPT_CONTENT',
'CELERY_ENABLE_UTC',
'CELERY_BEAT_SCHEDULE',
'DATABASES',
'MIGRATE_INITIAL_DATA',
'AUTH_PASSWORD_VALIDATORS',
'LANGUAGE_CODE',
'TIME_ZONE',
'USE_I18N',
'USE_L10N',
'USE_TZ',
'STATICFILES_DIRS',
'STATIC_URL',
'STATIC_ROOT',
'CRISPY_TEMPLATE_PACK',
'CACHES'
]

# Imports from your apps

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
Expand Down
1 change: 1 addition & 0 deletions transtats/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os

from .base import *
from .auth import *
Expand Down
3 changes: 2 additions & 1 deletion transtats/settings/prod.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os

from .base import *

from .auth import *

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
Expand Down
1 change: 1 addition & 0 deletions transtats/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.9/ref/settings/
"""
import os

from .base import *
from .auth import *
Expand Down

0 comments on commit 2a46066

Please sign in to comment.