Skip to content

Commit

Permalink
Update trunk, fix templates.
Browse files Browse the repository at this point in the history
  • Loading branch information
fsargent committed Feb 13, 2024
1 parent b077080 commit 97713a1
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 102 deletions.
34 changes: 17 additions & 17 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile"
}
"name": "Existing Dockerfile",
"build": {
// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerfile": "../Dockerfile"
}

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "cat /etc/os-release",

// Configure tool-specific properties.
// "customizations": {},
// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "devcontainer"
}
26 changes: 13 additions & 13 deletions .sourcery.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@

# This file was auto-generated by Sourcery on 2023-01-24 at 13:59.

version: '1' # The schema version of this config file
version: "1" # The schema version of this config file

ignore: # A list of paths or files which Sourcery will ignore.
- .git
- venv
- .venv
- env
- .env
- .tox
- .git
- venv
- .venv
- env
- .env
- .tox

rule_settings:
enable:
- default
disable: [] # A list of rule IDs Sourcery will never suggest.
- default
disable: [] # A list of rule IDs Sourcery will never suggest.
rule_types:
- refactoring
- suggestion
- comment
python_version: '2.7' # A string specifying the lowest Python version your project supports. Sourcery will not suggest refactorings requiring a higher Python version.
- refactoring
- suggestion
- comment
python_version: "2.7" # A string specifying the lowest Python version your project supports. Sourcery will not suggest refactorings requiring a higher Python version.

# rules: # A list of custom rules Sourcery will include in its analysis.
# - id: no-print-statements
Expand Down
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
language: python
python:
- "2.7"
- "2.7"
git:
depth: 3
install:
- "pip install -r requirements.txt"
- "pip install flake8"
depth: 3
install:
- "pip install -r requirements.txt"
- "pip install flake8"
script:
- python manage.py test
- flake8 --config=setup.cfg approval_*
- python manage.py test
- flake8 --config=setup.cfg approval_*
7 changes: 7 additions & 0 deletions .trunk/configs/.shellcheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enable=all
source-path=SCRIPTDIR
disable=SC2154

# If you're having issues with shellcheck following source, disable the errors via:
# disable=SC1090
# disable=SC1091
21 changes: 14 additions & 7 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,31 @@ plugins:
ref: v1.4.2
uri: https://github.com/trunk-io/plugins
lint:
ignore:
- linters: [prettier]
paths:
- approval_polls/templates
enabled:
- [email protected]
- [email protected]
- [email protected]
- [email protected]
- [email protected].2
- [email protected].20
- [email protected]
- [email protected]
- trivy@0.48.3
- trufflehog@3.66.2
- trivy@0.49.1
- trufflehog@3.67.5
- [email protected]
- [email protected]
- ruff@0.1.15
- yamllint@1.33.0
- ruff@0.2.1
- yamllint@1.34.0
- [email protected]
- [email protected]
- [email protected]
- git-diff-check
- [email protected].1
- [email protected].2
- [email protected]
- black@24.1.1
- black@24.2.0
- [email protected]
- [email protected]
- [email protected]
Expand Down
8 changes: 7 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ ENV PYTHONUNBUFFERED=1
# Set the working directory in the container
WORKDIR /code

# Create a non-root user and switch to it
RUN adduser -D appuser
USER appuser

# Install Poetry
# Note: Consider locking the Poetry version for consistent builds
ENV POETRY_VERSION=1.7
Expand All @@ -29,5 +33,7 @@ RUN poetry install --no-dev --no-root
# Copy the rest of the project files into the working directory
COPY . /code/

HEALTHCHECK CMD curl --fail http://localhost:8000/ || exit 1

# Use a script as the entrypoint
ENTRYPOINT ["/code/entrypoint.sh"]
ENTRYPOINT ["/code/entrypoint.sh"]
47 changes: 23 additions & 24 deletions approval_polls/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ChoiceInline(admin.TabularInline):
Defines the layout of 'Choice's in the
admin panel.
"""

model = Choice
extra = 3

Expand All @@ -21,55 +22,53 @@ class PollAdmin(admin.ModelAdmin):
Defines the layout of a 'Poll' in the
admin panel.
"""

fieldsets = [
(None, {'fields': ['question']}),
('Date information', {'fields': ['pub_date'], 'classes':['collapse']}),
(None, {"fields": ["question"]}),
("Date information", {"fields": ["pub_date"], "classes": ["collapse"]}),
]
inlines = [ChoiceInline]
list_display = ('id', 'question', 'pub_date')
list_filter = ['pub_date']
search_fields = ['question']
list_display = ("id", "question", "pub_date")
list_filter = ["pub_date"]
search_fields = ["question"]
actions = ["export_voters_as_csv"]

@admin.display(
description='Export poll with opt-in voter emails.'
)
@admin.display(description="Export poll with opt-in voter emails.")
def export_voters_as_csv(self, queryset):
poll_field_names = [
'id', 'question', 'pub_date', 'user', 'vtype', 'show_email_opt_in',
"id",
"question",
"pub_date",
"user",
"vtype",
"show_email_opt_in",
]

response = HttpResponse(content_type='text/csv')
response['Content-Disposition'] = (
'attachment; filename=voter_emails.csv'
)
response = HttpResponse(content_type="text/csv")
response["Content-Disposition"] = "attachment; filename=voter_emails.csv"
writer = csv.writer(response)

for poll in queryset:
writer.writerow([])
writer.writerow(poll_field_names)
writer.writerow(
[getattr(poll, field) for field in poll_field_names]
)
writer.writerow([getattr(poll, field) for field in poll_field_names])
writer.writerow([])
ballot_field_names = [
'username', 'first_name', 'last_name', 'email'
]
ballot_field_names = ["username", "first_name", "last_name", "email"]
writer.writerow(ballot_field_names)

for ballot in poll.ballot_set.all():
if ballot.permit_email:
if ballot.user:
writer.writerow(
[getattr(
ballot.user, field
) for field in ballot_field_names]
[
getattr(ballot.user, field)
for field in ballot_field_names
]
)
else:
writer.writerow(['', '', '', ballot.email])
writer.writerow(["", "", "", ballot.email])

return response



admin.site.register(Ballot)
14 changes: 6 additions & 8 deletions approval_polls/templates/403.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{% extends 'base.html' %}

{% block content %}
<div class='row-fluid top-buffer'>
<div class='col-md-12'>
<legend>Access denied</legend>
Sorry, but you are not authorized to view this page (Error: 403)
<div class='row-fluid top-buffer'>
<div class='col-md-12'>
<legend>Access denied</legend>
Sorry, but you are not authorized to view this page (Error: 403)
</div>
</div>
</div>
{% endblock content %}

{% block login %}{% endblock %}
{% block login %}{% endblock %}
16 changes: 7 additions & 9 deletions approval_polls/templates/404.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{% extends 'base.html' %}

{% block content %}
<div class='row-fluid top-buffer'>
<div class='col-md-12'>
<legend>Page not found</legend>
Sorry, the requested page does not exist. The link
may be broken or the page may have been moved.
<div class='row-fluid top-buffer'>
<div class='col-md-12'>
<legend>Page not found</legend>
Sorry, the requested page does not exist. The link
may be broken or the page may have been moved.
</div>
</div>
</div>
{% endblock content %}

{% block login %}{% endblock %}
{% block login %}{% endblock %}
12 changes: 6 additions & 6 deletions approval_polls/templates/account/signup_closed.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{% extends "account/base.html.html" %}
{% extends "base.html" %}
{% load i18n %}
{% load allauth %}
{% block head_title %}
{% block head_title
%}
{% trans "Sign Up Closed" %}
{% endblock head_title %}
{% block content %}
{% element h1 %}
{% trans "Sign Up Closed" %}
{% endelement %}
<p>{% trans "We are sorry, but the sign up is currently closed." %}</p>
{%
element h1 %} {% trans "Sign Up Closed" %} {% endelement %}
<p>{% trans "We are sorry, but the sign up is currently closed." %}</p>
{% endblock content %}
22 changes: 13 additions & 9 deletions approval_polls/templates/account/verification_sent.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{% extends "account/base.html.html" %}
{% extends "base.html" %}
{% load i18n %}
{% load allauth %}
{% block head_title %}
{% block head_title
%}
{% trans "Verify Your Email Address" %}
{% endblock head_title %}
{% block content %}
{% element h1 %}
{% trans "Verify Your Email Address" %}
{% endelement %}
<p>
{% blocktrans %}We have sent an email to you for verification. Follow the link provided to finalize the signup process. If you do not see the verification email in your main inbox, check your spam folder. Please contact us if you do not receive the verification email within a few minutes.{% endblocktrans %}
</p>
{% block
content %}
{% element h1 %} {% trans "Verify Your Email Address" %} {%
endelement %}
<p>
{% blocktrans %}We have sent an email to you for verification. Follow the link
provided to finalize the signup process. If you do not see the verification
email in your main inbox, check your spam folder. Please contact us if you do
not receive the verification email within a few minutes.{% endblocktrans %}
</p>
{% endblock content %}
1 change: 1 addition & 0 deletions approval_polls/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os

from django.core.wsgi import get_wsgi_application
from whitenoise import WhiteNoise

Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ set -e
# Run Django migrations
echo "Running migrations"
python manage.py migrate --noinput
python manage.py collectstatic --noinput
python manage.py collectstatic --noinput

# Start Gunicorn server
echo "Starting server"
Expand Down

0 comments on commit 97713a1

Please sign in to comment.