Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/upstream/master' into event_CRU…
Browse files Browse the repository at this point in the history
…D_2.0

# Conflicts:
#	tests/test_calendar.py
  • Loading branch information
dzhuang committed May 6, 2018
2 parents f5a81c6 + 7fae9c0 commit 473438d
Show file tree
Hide file tree
Showing 154 changed files with 40,626 additions and 4,167 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ local_settings.py
*.py[co]
.sw[opn]
doc/_build
components
bower_components
node_modules

setuptools-[0-9]*
virtualenv-[0-9]*
Expand All @@ -28,3 +27,4 @@ git-roots
.mypy_cache

/.idea
/.env
11 changes: 10 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,19 @@ Python 3.6:
variables:
CODECOV_TOKEN: "895e3bf2-cfd0-45f8-9a14-4b7bd148f76d"

Python 3.6 CLI Tool:
script:
- "PY_EXE=python3.6 bash ./test-command-line-tool.sh python3.6"
tags:
- python3.6
- linux
except:
- tags

Documentation:
script:
- curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/build-docs.sh
- export RELATE_LOCAL_TEST_SETTINGS=`pwd`/local_settings.example.py
- export RELATE_LOCAL_TEST_SETTINGS=`pwd`/local_settings_example.py
- ". ./build-docs.sh"
tags:
- python3.5
Expand Down
17 changes: 13 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,21 @@ install: true
matrix:
include:
- python: "2.7"
env: PY=true PY_EXE=python2.7
env: RL_TRAVIS_TEST=test PY_EXE=python2.7
- python: "3.5"
env: PY=true PY_EXE=python3.5
env: RL_TRAVIS_TEST=test PY_EXE=python3.5
- python: "3.6"
env: RL_TRAVIS_TEST=test PY_EXE=python3.6
- python: "3.6"
env: RL_TRAVIS_TEST=test_expensive PY_EXE=python3.6
- python: "3.6"
env: RL_TRAVIS_TEST=test_postgres PY_EXE=python3.6

- python: "3.6"
env: RL_TRAVIS_TEST=cmdline PY_EXE=python3.6
- python: "3.5"
env: Flake8=true PY_EXE=python3.5
env: RL_TRAVIS_TEST=flake8 PY_EXE=python3.5
- python: "3.6"
env: Mypy=true PY_EXE=python3.6
env: RL_TRAVIS_TEST=mypy PY_EXE=python3.6
script:
- bash ./run-travis-ci.sh
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ features:
* Simple, text-based format for reusable course content
* Based on standard `YAML <https://en.wikipedia.org/wiki/YAML>`_,
`Markdown <https://en.wikipedia.org/wiki/Markdown>`_
* Instructors can implement custom question/page types in Python.

See `example content <https://github.com/inducer/relate-sample>`_.

Expand Down
62 changes: 27 additions & 35 deletions accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class Meta:

def get_full_name(self, allow_blank=True, force_verbose_blank=False):
if (not allow_blank
and not self.first_name or not self.last_name):
and (not self.first_name or not self.last_name)):
return None

def verbose_blank(s):
Expand All @@ -150,11 +150,10 @@ def default_fullname(first_name, last_name):
return '%s %s' % (
verbose_blank(first_name), verbose_blank(last_name))

from django.conf import settings
format_method = getattr(
settings,
"RELATE_USER_FULL_NAME_FORMAT_METHOD",
default_fullname)
from accounts.utils import relate_user_method_settings
format_method = relate_user_method_settings.custom_full_name_method
if format_method is None:
format_method = default_fullname

try:
full_name = format_method(
Expand All @@ -173,51 +172,44 @@ def get_masked_profile(self):
def default_mask_method(user):
return "%s%s" % (_("User"), str(user.pk))

from django.conf import settings
mask_method = getattr(
settings,
"RELATE_USER_PROFILE_MASK_METHOD",
default_mask_method)

return str(mask_method(self)).strip()
from accounts.utils import relate_user_method_settings
mask_method = relate_user_method_settings.custom_profile_mask_method
if mask_method is None:
mask_method = default_mask_method

# Intentionally don't fallback if it failed -- let user see the exception.
result = mask_method(self)
if not result:
raise RuntimeError("get_masked_profile should not None.")
else:
result = str(result).strip()
if not result:
raise RuntimeError("get_masked_profile should not return "
"an empty string.")
return result

def get_short_name(self):
"Returns the short name for the user."
return self.first_name

def get_email_appellation(self):
"Return the appellation of the receiver in email."
from django.conf import settings

# import the user defined priority list
customized_priority_list = getattr(
settings,
"RELATE_EMAIL_APPELATION_PRIORITY_LIST", [])

priority_list = []

# filter out not allowd appellations in customized list
for e in customized_priority_list:
if e in ["first_name", "email", "username", "full_name"]:
priority_list.append(e)

# make sure the default appellations are included in case
# user defined appellations are not available.
for e in ["first_name", "email", "username"]:
if e not in priority_list:
priority_list.append(e)
from accounts.utils import relate_user_method_settings
priority_list = (
relate_user_method_settings.email_appellation_priority_list)

for attr in priority_list:
if attr == "full_name":
appellation = self.get_full_name(allow_blank=True)
appellation = self.get_full_name(allow_blank=False)
else:
appellation = getattr(self, attr)

if appellation:
return appellation
else:
if not appellation:
continue

return appellation

return _("user")

def clean(self):
Expand Down
Loading

0 comments on commit 473438d

Please sign in to comment.