Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release Candidate - Huff and Puff #757

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
docker:
# specify the version you desire here
# use `-browsers` prefix for selenium tests, e.g. `3.6.1-browsers`
- image: circleci/python:3.8
- image: circleci/python:3.9

# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
Expand Down Expand Up @@ -149,7 +149,7 @@ jobs:

format_and_secrets_checks:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
working_directory: ~/market-access-api
steps:
- checkout
Expand All @@ -168,7 +168,7 @@ jobs:

pep8:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9

working_directory: ~/market-access-api
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/recreate-poetry-requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: '3.8.x'
python-version: '3.9.x'

- name: Install Poetry
uses: snok/install-poetry@v1
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ To list all available commands with help text type `make help` in terminal and h

Dependencies:

- Python 3.8
- Python 3.9
- PostgreSQL 10
- redis 3.2

Expand All @@ -62,14 +62,14 @@ Dependencies:
cd market-access-api
```

2. Install Python 3.8
2. Install Python 3.9

[See this guide](https://docs.python-guide.org/starting/installation/) for detailed instructions for different platforms.

3. Create and activate the virtualenv:

```shell
python3.8 -m venv env
python3.9 -m venv env
source env/bin/activate
pip install -U pip
```
Expand Down
25 changes: 25 additions & 0 deletions api/barriers/migrations/0160_alter_barrier_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 4.2.10 on 2024-03-22 13:43

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
("barriers", "0159_backfill_barrier_changed_since_published"),
]

operations = [
migrations.AlterModelOptions(
name="barrier",
options={
"ordering": ["-reported_on"],
"permissions": [
(
"change_barrier_public_eligibility",
"Can change barrier public eligibility",
)
],
},
),
]
1 change: 0 additions & 1 deletion api/barriers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,6 @@ class Meta:
"change_barrier_public_eligibility",
"Can change barrier public eligibility",
),
("download_barriers", "Can download barriers"),
]

@classmethod
Expand Down
46 changes: 46 additions & 0 deletions api/user/migrations/0035_delete_download_approval_permission.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from django.db import migrations


def delete_download_approval_permission_and_group(apps, schema_editor):
Group = apps.get_model("auth", "Group")
Group.objects.filter(name="Download approved user").delete()

# remove "download_barriers" Permission
Permission = apps.get_model("auth", "Permission")
permission = Permission.objects.get(codename="download_barriers")
permission.delete()


# Re-add the permission and group. Users will have to be re-added to group
def undo_download_approval_deletion(apps, schema_editor):
Group = apps.get_model("auth", "Group")
Group.objects.create(name="Download approved user")

# create a "download_barrier" Permission and add it to the group
Permission = apps.get_model("auth", "Permission")
ContentType = apps.get_model("contenttypes", "ContentType")
Barrier = apps.get_model("barriers", "Barrier")
barrier_content_type = ContentType.objects.get_for_model(Barrier)
download_barriers_permission, created = Permission.objects.get_or_create(
codename="download_barriers",
defaults={
"name": "Can download barriers",
"content_type": barrier_content_type,
},
)
group = Group.objects.get(name="Download approved user")
group.permissions.add(download_barriers_permission)


class Migration(migrations.Migration):

dependencies = [
("user", "0034_related_barrier_feature_flag"),
]

operations = [
migrations.RunPython(
delete_download_approval_permission_and_group,
undo_download_approval_deletion,
),
]
7 changes: 0 additions & 7 deletions api/user/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from logging import getLogger

from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group, Permission
from django.db.models import Q
Expand Down Expand Up @@ -28,7 +27,6 @@ class WhoAmISerializer(serializers.ModelSerializer):
user_profile = serializers.SerializerMethodField()
permitted_applications = serializers.SerializerMethodField()
permissions = serializers.SerializerMethodField()
has_approved_digital_trade_email = serializers.SerializerMethodField()

class Meta:
model = UserModel
Expand All @@ -43,7 +41,6 @@ class Meta:
"internal",
"user_profile",
"permitted_applications",
"has_approved_digital_trade_email",
"permissions",
"is_active",
"is_superuser",
Expand Down Expand Up @@ -109,10 +106,6 @@ def get_permitted_applications(self, obj):
return sso_me.get("permitted_applications", None)
return None

def get_has_approved_digital_trade_email(self, obj):
email_domain = obj.email.split("@")[-1].lower()
return email_domain in settings.APPROVED_DIGITAL_TRADE_EMAIL_DOMAINS

def get_permissions(self, obj):
return (
Permission.objects.filter(Q(user=obj) | Q(group__user=obj))
Expand Down
4 changes: 0 additions & 4 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,6 @@

DEFAULT_EXPORT_DATE_FORMAT = "%Y-%m-%d"

APPROVED_DIGITAL_TRADE_EMAIL_DOMAINS = env.list(
"APPROVED_DIGITAL_TRADE_EMAIL_DOMAINS", default=[]
)

SEARCH_DOWNLOAD_APPROVAL_REQUEST_EMAILS = env.list(
"SEARCH_DOWNLOAD_APPROVAL_REQUEST_EMAILS", default=[]
)
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.local-template.env
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ COMTRADE_DB_USER=not-set
COMTRADE_DB_PWORD=not-set
COMTRADE_DB_OPTIONS=not-set

APPROVED_DIGITAL_TRADE_EMAIL_DOMAINS=example.org,example.com

# Sentry
# ========================
SENTRY_DSN=<<CHECK_VAULT>>
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ services:
- .:/usr/src/app:delegated
env_file: docker-compose.env
# Running the main service directly within the contain is helpful
command: python3.8 ./manage.py runserver 0:8000
command: python3.9 ./manage.py runserver 0:8000
ports:
- "8880:8000"
- "8882:22"
Expand Down
2 changes: 1 addition & 1 deletion docker/local/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.8
FROM python:3.9

RUN apt-get -y update \
&& apt-get -y install \
Expand Down
Loading