Skip to content

Commit

Permalink
Merge pull request #72 from cfpb/code-of-conduct
Browse files Browse the repository at this point in the history
Add code of conduct
  • Loading branch information
willbarton committed Oct 2, 2020
2 parents b6a58fc + 554999a commit 3cec01d
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 21 deletions.
116 changes: 116 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
# CFPB Open Source Code of Conduct

## Introduction

The [Consumer Financial Protection Bureau](https://www.consumerfinance.gov) (CFPB) is committed to
building a safe, welcoming, harassment-free culture for everyone. We do not merely want an
environment that is free from hostility, we want one that is actively welcoming and inclusive. We
want our team, our workplace culture, and our open source community to reflect and celebrate the
diversity of the people we serve.

This Code of Conduct summarizes federal anti-harassment law and CFPB policy.

## Scope

We expect everyone on the CFPB team, and those contributing to our open source community, to exhibit
these behaviors and abide by applicable federal laws and CFPB policies. In addition, we expect
everyone within CFPB spaces to exhibit these behaviors and refrain from behavior prohibited by
anti-harassment laws and federal policies on harassment. These spaces include:

- CFPB’s physical offices
- CFPB events and meetings
- All of CFPB’s online forums and virtual collaboration tools, including code repositories


## What we strive for

At the CFPB, we strive to create a welcoming and inclusive culture that empowers people to best protect
the financial interests of all consumers. That kind of atmosphere requires an open exchange of ideas
balanced by thoughtful guidelines. Examples of behavior that contributes to a positive environment
for our open source community include:

- Demonstrating empathy and kindness toward other people
- Being respectful of differing opinions, viewpoints, and experiences
- Giving and gracefully accepting constructive feedback
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
- Focusing on what is best not just for us as individuals, but for the overall community and public

## Unacceptable behavior

To help understand the kinds of behaviors that are illegal or run counter to the culture we seek to
foster, we've listed some actions below that violate federal law and CFPB policy. We've also included
steps to take if you encounter behavior that runs contrary to this policy.

The CFPB Policy Statement on Equal Employment Opportunity and Workplace Harassment forbids
discrimination or harassment based on:

- Race
- Color
- Religion
- Sex (including pregnancy, sexual orientation, transgender status, gender identity or expression, gender non-conformity, or sex stereotyping of any kind)
- National origin
- Disability
- Age (40 years or older)
- Genetic information
- Parental status
- Political affiliation
- Marital status
- Uniformed status
- Membership in a labor organization or union activities
- Prior equal employment opportunity (EEO) or whistleblower activity
- Any other factor unrelated to your merit

The policy also forbids harassing conduct, which includes unwelcome conduct based on any (or a combination of) protected traits or characteristics. Such conduct may take the form of any of the following:

- Offensive jokes, comments, objects, or pictures
- Questions about a person’s identity (e.g., disability status, gender identity, sexual orientation, national origin, etc.)
- Undue attention
- Ridicule or mockery
- Insults or put-downs
- Touching/physical contact
- Slurs or epithets
- Threats or other forms of intimidation
- Physical or sexual assault

## Reporting violations

If you are a CFPB employee, former CFPB employee, or job applicant to CFPB and believe you have been
discriminated against or harassed on the basis of race, color, religion, sex (including pregnancy,
sexual orientation, transgender status, gender identity or expression, gender non-conformity, or sex
stereotyping of any kind), national origin, disability, age (40 years or older), genetic information,
parental status, or retaliated against for prior Equal Employment Opportunity (EEO) activity, contact the CFPB’s Office of Civil Rights.

CFPB_EEO@consumerfinance.gov

(202) 435-9EEO
(855) 233-0362
TTY: (202) 435-9742

Office of Civil Rights
Consumer Financial Protection Bureau
1700 G Street, NW
Washington, D.C. 20552

For help filing a complaint about discrimination on the basis of marital status, political
affiliation, or any other non-merit factor, or for claims of retaliation for [whistleblower activity](https://www.consumerfinance.gov/office-civil-rights/whistleblowers/), contact the [Office of Special Counsel](https://www.osc.gov/) or the [Merit Systems Protection Board](https://www.mspb.gov/).

For help filing a complaint about discrimination on the basis of uniformed status, you may contact
the [Veterans’ Employment and Training Service (VETS)](https://www.dol.gov/vets/) at the Department of Labor, the [Merit Systems Protection Board](https://www.mspb.gov/), or the [Office of Special Counsel](https://osc.gov/), depending on the circumstances.

For help filing a complaint about discrimination on the basis of membership in a labor organization,
you may contact the [Federal Labor Relations Authority](https://flra.gov/) or your union (if applicable).

### Equal employment opportunity policy

For more information about the CFPB’s equal employment opportunity (EEO) policies and procedures visit https://www.consumerfinance.gov/office-civil-rights/eeo-policy-and-reports/

## Credits

The CFPB is greatly appreciative of the multiple sources that we drew from to build this Code of Conduct, including:

- [The Technology Transformation Services (TTS) Code of Conduct](https://18f.gsa.gov/code-of-conduct/)
- [The Contributor Covenant](https://www.contributor-covenant.org/)
- [Code for America Code of Conduct](https://github.com/codeforamerica/codeofconduct)
- [Ada Initiative: HOWTO design a code of conduct for your community](https://adainitiative.org/2014/02/18/howto-design-a-code-of-conduct-for-your-community/)
- [Geek Feminism Code of Conduct](https://geekfeminismdotorg.wordpress.com/about/code-of-conduct/)

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Build Status](https://github.com/cfpb/django-flags/workflows/test/badge.svg)](https://github.com/cfpb/django-flags/actions)
[![Coverage Status](https://coveralls.io/repos/github/cfpb/django-flags/badge.svg?branch=master)](https://coveralls.io/github/cfpb/django-flags?branch=master)
[![Ethical open source](https://img.shields.io/badge/open-ethical-%234baaaa)](https://ethicalsource.dev/definition/)

Feature flags allow you to toggle functionality in both Django code and the Django templates based on configurable conditions. Flags can be useful for staging feature deployments, for A/B testing, or for any time you need an on/off switch for blocks of code. The toggle can be by date, user, URL value, or a number of [other conditions](https://cfpb.github.io/django-flags/conditions/), editable in the admin or in definable in settings.

Expand Down
11 changes: 5 additions & 6 deletions flags/conditions/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ def user_condition(username, request=None, **kwargs):

@register("anonymous", validator=validate_boolean)
def anonymous_condition(boolean_value, request=None, **kwargs):
""" request.user an anonymous user, true or false based on boolean_value
"""
"""request.user an anonymous user, true or false based on boolean_value"""
if request is None:
raise RequiredForCondition(
"request is required for condition 'anonymous'"
Expand Down Expand Up @@ -79,8 +78,8 @@ def path_condition(pattern, request=None, **kwargs):

@register("after date", validator=validate_date)
def after_date_condition(date_or_str, **kwargs):
""" Is the the current date after the given date?
date_or_str is either a date object or an ISO 8601 string """
"""Is the the current date after the given date?
date_or_str is either a date object or an ISO 8601 string"""
try:
date = dateparse.parse_datetime(date_or_str)
except TypeError:
Expand All @@ -103,8 +102,8 @@ def after_date_condition(date_or_str, **kwargs):

@register("before date", validator=validate_date)
def before_date_condition(date_or_str, **kwargs):
""" Is the current date before the given date?
date_or_str is either a date object or an ISO 8601 string """
"""Is the current date before the given date?
date_or_str is either a date object or an ISO 8601 string"""
try:
date = dateparse.parse_datetime(date_or_str)
except TypeError:
Expand Down
4 changes: 2 additions & 2 deletions flags/conditions/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class DuplicateCondition(ValueError):


def register(condition_name, fn=None, validator=None):
""" Register a condition to test for flag state.
"""Register a condition to test for flag state.
This function can be used as a decorator or the condition callable can be
passed as `fn`.
Expand All @@ -20,7 +20,7 @@ def register(condition_name, fn=None, validator=None):
Conditions can be any callable that takes a value and some number of
required arguments (specified in 'requires') that were passed as kwargs
when checking the flag state. """
when checking the flag state."""
global _conditions, _validators

if fn is None:
Expand Down
4 changes: 2 additions & 2 deletions flags/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@


def flag_check(flag_name, state, fallback=None, **fc_kwargs):
""" Check that a given flag has the given state.
If the state does not match, perform the fallback. """
"""Check that a given flag has the given state.
If the state does not match, perform the fallback."""

def decorator(func):
# At decoration-time, ensure that the fallback for the decorated
Expand Down
4 changes: 3 additions & 1 deletion flags/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
]


@override_settings(ROOT_URLCONF=__name__,)
@override_settings(
ROOT_URLCONF=__name__,
)
class FlagsAdminTestCase(TestCase):
def setUp(self):
self.client = Client()
Expand Down
6 changes: 5 additions & 1 deletion flags/tests/test_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ def test_pass_if_not_set_fallback_view(self):
def fallback(request, **kwargs):
return HttpResponse("fallback")

decorator = flag_check("FLAG_ENABLED", False, fallback=fallback,)
decorator = flag_check(
"FLAG_ENABLED",
False,
fallback=fallback,
)

decorated = decorator(self.view)
response = decorated(self.request)
Expand Down
6 changes: 4 additions & 2 deletions flags/tests/test_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def test_get_flags_two_tuple(self):
source = SettingsFlagsSource()
flags = source.get_flags()
self.assertEqual(
flags, {"MY_FLAG": [Condition("boolean", True, required=False)]},
flags,
{"MY_FLAG": [Condition("boolean", True, required=False)]},
)

@override_settings(FLAGS={"MY_FLAG": [("boolean", True, True)]})
Expand Down Expand Up @@ -65,7 +66,8 @@ def test_get_flags_list_of_dicts_without_required(self):
source = SettingsFlagsSource()
flags = source.get_flags()
self.assertEqual(
flags, {"MY_FLAG": [Condition("boolean", True, required=False)]},
flags,
{"MY_FLAG": [Condition("boolean", True, required=False)]},
)


Expand Down
6 changes: 3 additions & 3 deletions flags/tests/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def fallback(request):
urlpatterns = urlpatterns + path_patterns


@override_settings(ROOT_URLCONF=__name__,)
@override_settings(ROOT_URLCONF=__name__)
class FlagCheckTestCase(TestCase):
def setUp(self):
self.flag_name = "FLAGGED_URL"
Expand Down Expand Up @@ -226,14 +226,14 @@ def test_flagged_url_false_include_fallback_none(self):
self.get_url_response("/include-fallback-include/included-url")

@override_settings(FLAGS={"FLAGGED_URL": [("boolean", True)]})
def test_flagged_url_true_include_fallback_include_nonmatching_url(self,):
def test_flagged_url_true_include_fallback_include_nonmatching_url(self):
with self.assertRaises(Http404):
self.get_url_response(
"/include-fallback-include/other-included-url"
)

@override_settings(FLAGS={"FLAGGED_URL": [("boolean", False)]})
def test_flagged_url_false_include_fallback_include_nonmatching_url(self,):
def test_flagged_url_false_include_fallback_include_nonmatching_url(self):
response = self.get_url_response(
"/include-fallback-include/other-included-url"
)
Expand Down
4 changes: 3 additions & 1 deletion flags/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def test_view_function(request, *args, **kwargs):
return HttpResponse("fallback fn")

view = TestView.as_view(
flag_name=self.flag_name, state=True, fallback=test_view_function,
flag_name=self.flag_name,
state=True,
fallback=test_view_function,
)

response = view(self.request())
Expand Down
4 changes: 2 additions & 2 deletions flags/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ def _flagged_path(

@contextmanager
def _flagged_paths(flag_name, state=True, fallback=None, Pattern=None):
""" Flag multiple URLs in the same context
Returns a url()-compatible wrapper for flagged_url() """
"""Flag multiple URLs in the same context
Returns a url()-compatible wrapper for flagged_url()"""

def flagged_url_wrapper(route, view, kwargs=None, name=None):
return _flagged_path(
Expand Down
6 changes: 5 additions & 1 deletion flags/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ def as_view(cls, **initkwargs):

view = super(FlaggedViewMixin, cls).as_view(**initkwargs)

decorator = flag_check(flag_name, state, fallback=fallback,)
decorator = flag_check(
flag_name,
state,
fallback=fallback,
)

return decorator(view)

Expand Down

0 comments on commit 3cec01d

Please sign in to comment.