Skip to content

Commit

Permalink
Merge pull request #127 from ebridges/chore/update-dependencies
Browse files Browse the repository at this point in the history
chore: upgrade dependencies
  • Loading branch information
ebridges committed May 27, 2024
2 parents 6671380 + 954dd8e commit ad23186
Show file tree
Hide file tree
Showing 21 changed files with 2,399 additions and 1,656 deletions.
59 changes: 39 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,51 @@ on:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

test:
runs-on: ubuntu-latest

env:
OPERATING_ENV: ci
GITHUB_OAUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

strategy:
max-parallel: 4
matrix:
python-version: [3.7, 3.8]
python-version: ['3.12']

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install toml
etc/bin/poetry2pip.py --file poetry.lock --dev-deps > requirements.txt
pip install -r requirements.txt
- name: Run Tests
run: |
cd application
python manage.py test
- name: Check out the code
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Cache Poetry dependencies
uses: actions/cache@v3
with:
path: |
~/.cache/pypoetry
~/.local/share/pypoetry/virtualenvs
key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }}-${{ matrix.python-version }}
restore-keys: |
${{ runner.os }}-poetry-
- name: Install dependencies
run: poetry install

- name: Run linter
run: |
poetry run black --check .
- name: Run Tests
run: |
cd application
poetry run python manage.py test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ requirements.txt
.doit.db
deploy-tmp/
build-tmp/
*.code-workspace
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.7.7
3.12
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ The `elektrum` application is a multi-tier system for hosting images and other m

## Platform Information

* Python 3.7
* Django 3.0
* lgw 1.0.*
* Python 3.12
* Django 4.0
* lgw 1.2.*
* PostgreSQL 11
* Ansible 2.8.2
* Ansible 9

## Installation & Deployment

Expand Down
1 change: 1 addition & 0 deletions application/elektrum/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from base.views.utils import DEFAULT_THUMBNAIL_W, DEFAULT_THUMBNAIL_H


# noinspection PyUnusedLocal
def selected_settings(request):
# return the version value as a dictionary
Expand Down
2 changes: 1 addition & 1 deletion application/elektrum/env_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


def locate_env_file(start_dir=os.getcwd()):
logger.debug('Begin looking for environment in: %s' % start_dir)
logger.info('Begin looking for environment in: %s' % start_dir)

# check in current directory for `.env`
location = os.path.join(start_dir, '.env')
Expand Down
1 change: 1 addition & 0 deletions application/elektrum/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

loggers = {}


# https://stackoverflow.com/a/7175288/87408
def getLogger(name):
global loggers
Expand Down
28 changes: 24 additions & 4 deletions application/elektrum/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
from dotenv import load_dotenv
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
from logging import info

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

info(f'BASE_DIR: {BASE_DIR}')
env_file = locate_env_file(BASE_DIR)
load_dotenv(env_file)
OPERATING_ENV = os.environ['ENVIRONMENT']
Expand Down Expand Up @@ -87,6 +88,7 @@
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.sites.middleware.CurrentSiteMiddleware',
'allauth.account.middleware.AccountMiddleware',
]

ROOT_URLCONF = 'elektrum.urls'
Expand Down Expand Up @@ -167,15 +169,32 @@

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]

STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'

# ** Default Storage
# The "default" storage option is used for handling uploaded media
# files. This is where Django will store files that users upload
# through your application, such as images, documents, and other media.
#
# ** Staticfiles Storage
# The "staticfiles" storage option is used for serving static files.
# Static files are assets like CSS, JavaScript, and images that are
# part of your application's codebase and do not change frequently.
# These files are typically collected and served by a web server or a CDN.
STORAGES = {
'default': {
'BACKEND': 'django.core.files.storage.FileSystemStorage',
},
'staticfiles': {
'BACKEND': 'storages.backends.s3boto3.S3Boto3Storage',
},
}

AWS_STORAGE_BUCKET_NAME = os.getenv('STATIC_FILES_BUCKET_NAME')
AWS_S3_CUSTOM_DOMAIN = os.environ.get('STATIC_DOMAIN_NAME')
STATIC_URL = 'https//%s/' % AWS_S3_CUSTOM_DOMAIN
Expand All @@ -192,6 +211,7 @@
'allauth.account.auth_backends.AuthenticationBackend',
)
ACCOUNT_FORMS = {'signup': 'users.forms.CustomUserCreationForm'}
SIGNUP_FORM_CLASS = 'users.forms.CustomUserCreationForm'

SITE_ID = 2

Expand Down
1 change: 1 addition & 0 deletions application/elektrum/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""

from django.contrib import admin
from django.urls import path, include
from allauth.account.adapter import DefaultAccountAdapter
Expand Down
2 changes: 1 addition & 1 deletion application/emailer/views/send_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def send_email(

cnt = 0
addrs = mail_info['to']
for (email, email_id) in addrs.items():
for email, email_id in addrs.items():
mail_info['email_id'] = email_id
text_message = renderer(body_text_tmpl, mail_info)

Expand Down
2 changes: 1 addition & 1 deletion application/media_items/tests/test_media_item_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
)
@pytest.mark.django_db
def test_sign_upload_request_success(authenticated_client, img, env):
with (env['remote_path']):
with env['remote_path']:
c, u = authenticated_client

image_key = upload_request(c, img)
Expand Down
2 changes: 1 addition & 1 deletion application/sharing/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def describe(self):

class Share(BaseModel):
def save(self, *args, **kwargs):
''' On save, update timestamps '''
'''On save, update timestamps'''
if not self.id:
self.created = timezone.now()
self.modified = timezone.now()
Expand Down
65 changes: 27 additions & 38 deletions application/sharing/templates/sharing/share_items.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,40 @@

{% block nav_block %}
<h2 class='subtitle'>
<a href="{% url 'collections-view' user.id %}"><span class="nav-home-icon">&#x2302;</span></a>
<a href="{% url 'collections-view' user.id %}"><span class="nav-home-icon">&#x2302;</span></a>
</h2>
{% endblock %}

{% block content %}
<form action="{% url 'share-items' share_id %}" method="POST">
{% csrf_token %}
<datalist id="default-emails">
{% for email in default_emails %} <option value="{{ email }}">
{% for email in default_emails %}
<option value="{{ email }}">
{% endfor %}</datalist>
<table class="metadata-table">
{{ form }}
<tfoot>
<tr>
<th>
&nbsp;
</th>
<td>
<div id="media_items" class="media_items">
{% for info in objects %}
<div class="media_item">
<a class="media_item_link" href="#">
<figure>
<div class="media_item_thumbnail"><img src="{{ info.thumbnail_url }}" width="{{ THUMBNAIL_WIDTH }}" height="{{ THUMBNAIL_HEIGHT }}"></div>
<figcaption>
&nbsp;&nbsp;<input type="hidden" name="items-to-share" value="{{ info.item_id }}"/>&nbsp;{{ info.title }}
</figcaption>
</figure>
</a>
</div>
{% endfor %}
</div>
</td>
</tr>
<tr>
<th>
&nbsp;
</th>
<td>
<button type="submit" name="action" value="share">Share Images</button>
<button type="submit" name="action" value="draft">Save as Draft</button>
<button type="submit" name="action" value="cancel">Cancel</button><br>
</td>
</tr>
</tfoot>
</table>
<div class="metadata-form">
<div class="form-row">
{{ form }}
</div>
</div>
<div id="media_items" class="media_items">
{% for info in objects %}
<div class="media_item">
<a class="media_item_link" href="#">
<figure>
<div class="media_item_thumbnail"><img src="{{ info.thumbnail_url }}" width="{{ THUMBNAIL_WIDTH }}" height="{{ THUMBNAIL_HEIGHT }}"></div>
<figcaption>
&nbsp;&nbsp;<input type="hidden" name="items-to-share" value="{{ info.item_id }}"/>&nbsp;{{ info.title }}
</figcaption>
</figure>
</a>
</div>
{% endfor %}
</div>
<div class="form-actions">
<button type="submit" name="action" value="share">Share Images</button>
<button type="submit" name="action" value="draft">Save as Draft</button>
<button type="submit" name="action" value="cancel">Cancel</button><br>
</div>
</form>
{% endblock %}
8 changes: 8 additions & 0 deletions application/sharing/tests/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ class Meta:
class ShareFactory(DjangoModelFactory):
class Meta:
model = Share
# DeprecationWarning: ShareFactory._after_postgeneration
# will stop saving the instance after postgeneration hooks
# in the next major release.
# - If the save call is extraneous, set
# `skip_postgeneration_save=True`` in the ShareFactory.Meta.
# - To keep saving the instance, move the save call to your
# postgeneration hooks or override _after_postgeneration.
skip_postgeneration_save = True

id = LazyFunction(uuid4)
subject = FuzzyText(prefix='subject.')
Expand Down
Loading

0 comments on commit ad23186

Please sign in to comment.