Skip to content

Commit

Permalink
Upgrade poetry packages
Browse files Browse the repository at this point in the history
- Fix migrations issues
  • Loading branch information
thenav56 committed Mar 26, 2024
1 parent 89b9d22 commit c1fa0e6
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 70 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,22 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- uses: actions/setup-python@master
- uses: pre-commit/action@master
- uses: actions/checkout@main
- name: Install poetry
run: pipx install poetry
- uses: actions/setup-python@main
with:
cache: 'poetry'
- run: poetry install
- uses: pre-commit/action@main

test:
name: 🚴 Test 🚴
runs-on: ubuntu-latest
needs: pre_commit_checks

steps:
- uses: actions/checkout@mastj
- uses: actions/checkout@main

- name: 🐳 Prepare Docker
id: prep
Expand Down
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ target/
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
Expand Down Expand Up @@ -131,4 +128,4 @@ dmypy.json
.azure

# editors
.idea/
.idea/
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.11
8 changes: 4 additions & 4 deletions apps/cap_feed/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class Migration(migrations.Migration):
('event_code', models.CharField(blank=True, default=None, null=True)),
('effective', models.DateTimeField(blank=True, default=django.utils.timezone.now)),
('onset', models.DateTimeField(blank=True, null=True)),
('expires', models.DateTimeField(blank=True, default=apps.cap_feed.models.AlertInfo.default_expire, null=True)),
('expires', models.DateTimeField(blank=True, default=apps.cap_feed.models.alert_info_default_expire, null=True)),
('sender_name', models.CharField(blank=True, default=None, null=True)),
('headline', models.CharField(blank=True, default=None, null=True)),
('description', models.TextField(blank=True, default=None, null=True)),
Expand Down Expand Up @@ -175,12 +175,12 @@ class Migration(migrations.Migration):
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('url', models.CharField(unique=True)),
('format', models.CharField(choices=[('atom', 'atom'), ('rss', 'rss'), ('nws_us', 'nws_us')])),
('format', models.CharField(choices=[('atom', 'ATOM'), ('rss', 'RSS'), ('nws_us', 'NWS_US')])),
('polling_interval', models.IntegerField(choices=[(5, '5 seconds'), (10, '10 seconds'), (15, '15 seconds'), (20, '20 seconds'), (25, '25 seconds'), (30, '30 seconds'), (35, '35 seconds'), (40, '40 seconds'), (45, '45 seconds'), (50, '50 seconds'), (55, '55 seconds'), (60, '60 seconds')])),
('enable_polling', models.BooleanField(default=False)),
('enable_rebroadcast', models.BooleanField(default=False)),
('official', models.BooleanField(default=False)),
('status', models.CharField(choices=[('active', 'active'), ('testing', 'testing'), ('inactive', 'inactive'), ('unusable', 'unusable')], default='active')),
('status', models.CharField(choices=[('active', 'Active'), ('testing', 'Testing'), ('inactive', 'Inactive'), ('unusable', 'Unusable')], default='active')),
('author_name', models.CharField(default='')),
('author_email', models.CharField(default='')),
('notes', models.TextField(blank=True, default='')),
Expand Down Expand Up @@ -221,7 +221,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('url', models.CharField(unique=True)),
('expires', models.DateTimeField(default=apps.cap_feed.models.ProcessedAlert.default_expire)),
('expires', models.DateTimeField(default=apps.cap_feed.models.processed_alert_default_expire)),
('feed', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='cap_feed.feed')),
],
),
Expand Down
25 changes: 12 additions & 13 deletions apps/cap_feed/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
from django.db.models.fields.related_descriptors import ManyRelatedManager


# To dynamically set default expire time
def alert_info_default_expire():
return timezone.now() + timedelta(days=1)


def processed_alert_default_expire():
return timezone.now() + timedelta(weeks=1)


class Continent(models.Model):
name = models.CharField()

Expand Down Expand Up @@ -125,7 +134,7 @@ class PoolingInterval(models.IntegerChoices):
I_60 = 60, '60 seconds'

class Format(models.TextChoices):
ATOM = ['atom', 'ATOM']
ATOM = 'atom', 'ATOM'
RSS = 'rss', 'RSS'
NWS_US = 'nws_us', 'NWS_US'

Expand Down Expand Up @@ -170,14 +179,9 @@ def save(self, force_insert=False, force_update=False, *args, **kwargs):


class ProcessedAlert(models.Model):
# Set expire time to 1 week
@staticmethod
def default_expire():
return timezone.now() + timedelta(weeks=1)

url = models.CharField(unique=True)
feed = models.ForeignKey(Feed, on_delete=models.CASCADE)
expires = models.DateTimeField(default=default_expire)
expires = models.DateTimeField(default=processed_alert_default_expire)

def __str__(self):
return self.url
Expand Down Expand Up @@ -254,11 +258,6 @@ class AlertAdmin1(models.Model):


class AlertInfo(models.Model):
# To dynamically set default expire time
@staticmethod
def default_expire():
return timezone.now() + timedelta(days=1)

class Category(models.TextChoices):
GEO = 'Geo', 'Geo'
MET = 'Met', 'Met'
Expand Down Expand Up @@ -319,7 +318,7 @@ class Certainty(models.TextChoices):
# effective = models.DateTimeField(default=Alert.objects.get(pk=alert).sent)
effective = models.DateTimeField(blank=True, default=timezone.now)
onset = models.DateTimeField(blank=True, null=True)
expires = models.DateTimeField(blank=True, null=True, default=default_expire)
expires = models.DateTimeField(blank=True, null=True, default=alert_info_default_expire)
sender_name = models.CharField(blank=True, null=True, default=None)
headline = models.CharField(blank=True, null=True, default=None)
description = models.TextField(blank=True, null=True, default=None)
Expand Down
6 changes: 2 additions & 4 deletions gh-docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ services:
tty: true
extra_hosts:
- 'host.docker.internal:host-gateway'
env_file:
- .env
environment:
CI: true
CI: "true"
DJANGO_APP_ENVIRONMENT: development
DJANGO_APP_TYPE: web
DJANGO_DEBUG: true
DJANGO_DEBUG: "true"
DJANGO_SECRET_KEY: INSECURE_DJANGO_SECRET_KEY
# -- Domain configurations
DJANGO_ALLOWED_HOSTS: "*"
Expand Down
31 changes: 16 additions & 15 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ django-redis = "^5.3.0"
django-storages = "^1.13.2"
iso639-lang = "^2.1.0"
graphene-django = "*"
psycopg2-binary = "^2.9.6"
shapely = "^2.0.1"
psycopg2-binary = "^2.9.9"
shapely = "^2.0.3"
pytz = "*"
colorlog = "*"
requests = "*"
Expand Down
23 changes: 0 additions & 23 deletions requirements.txt

This file was deleted.

2 changes: 1 addition & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -478,4 +478,4 @@ type UserMeType {
phoneNumber: String
country: String
city: String
}
}

0 comments on commit c1fa0e6

Please sign in to comment.