Skip to content

Commit

Permalink
Merge pull request #4434 from magfest/schedule-updates
Browse files Browse the repository at this point in the history
Create list of schedule changes for Guidebook
  • Loading branch information
kitsuta authored Nov 28, 2024
2 parents a2fda52 + 66cf4d3 commit d3ad111
Show file tree
Hide file tree
Showing 20 changed files with 679 additions and 190 deletions.
59 changes: 59 additions & 0 deletions alembic/versions/ebf8fdbfc585_add_track_column_to_events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""Add track column to Events
Revision ID: ebf8fdbfc585
Revises: f85c05a4410e
Create Date: 2024-11-27 19:53:19.980065
"""


# revision identifiers, used by Alembic.
revision = 'ebf8fdbfc585'
down_revision = 'f85c05a4410e'
branch_labels = None
depends_on = None

from alembic import op
import sqlalchemy as sa



try:
is_sqlite = op.get_context().dialect.name == 'sqlite'
except Exception:
is_sqlite = False

if is_sqlite:
op.get_context().connection.execute('PRAGMA foreign_keys=ON;')
utcnow_server_default = "(datetime('now', 'utc'))"
else:
utcnow_server_default = "timezone('utc', current_timestamp)"

def sqlite_column_reflect_listener(inspector, table, column_info):
"""Adds parenthesis around SQLite datetime defaults for utcnow."""
if column_info['default'] == "datetime('now', 'utc')":
column_info['default'] = utcnow_server_default

sqlite_reflect_kwargs = {
'listeners': [('column_reflect', sqlite_column_reflect_listener)]
}

# ===========================================================================
# HOWTO: Handle alter statements in SQLite
#
# def upgrade():
# if is_sqlite:
# with op.batch_alter_table('table_name', reflect_kwargs=sqlite_reflect_kwargs) as batch_op:
# batch_op.alter_column('column_name', type_=sa.Unicode(), server_default='', nullable=False)
# else:
# op.alter_column('table_name', 'column_name', type_=sa.Unicode(), server_default='', nullable=False)
#
# ===========================================================================


def upgrade():
op.add_column('event', sa.Column('track', sa.Unicode(), server_default='', nullable=False))


def downgrade():
op.drop_column('event', 'track')
Binary file modified celerybeat-schedule
Binary file not shown.
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ x-uber: &uber
- uber_secret_broker_url=amqp://celery:celery@rabbitmq:5672/uber
- uber_hostname=localhost
- uber_dev_box=True
- LOG_CONFIG=true
volumes:
- .:/app/
- ${PLUGIN_DIR_SRC:-./README.md}:${PLUGIN_DIR_TARGET:-/tmp/README.md}
Expand Down
8 changes: 3 additions & 5 deletions uber/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1683,11 +1683,10 @@ def _unrepr(d):

# A list of models that have properties defined for exporting for Guidebook
c.GUIDEBOOK_MODELS = [
('GuestGroup_guest', 'Guests'),
('GuestGroup_band', 'Bands'),
('GuestGroup_guest', 'Guest'),
('GuestGroup_band', 'Band'),
('MITSGame', 'MITS'),
('IndieGame', 'MIVS'),
('Event_panels', 'Panels'),
('Group_dealer', 'Marketplace'),
]

Expand All @@ -1699,9 +1698,8 @@ def _unrepr(d):
('guidebook_subtitle', 'Sub-Title (i.e. Location, Table/Booth, or Title/Sponsorship Level)'),
('guidebook_desc', 'Description (Optional)'),
('guidebook_location', 'Location/Room'),
('guidebook_image', 'Image (Optional)'),
('guidebook_header', 'Image (Optional)'),
('guidebook_thumbnail', 'Thumbnail (Optional)'),
('guidebook_track', 'Schedule Track (Optional)'),
]


Expand Down
4 changes: 2 additions & 2 deletions uber/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ def xlsx_out(self, session, set_headers=True, **kwargs):
if set_headers:
cherrypy.response.headers['Content-Type'] = \
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
_set_response_filename(func.__name__ + datetime.now().strftime('%Y%m%d') + '.xlsx')
_set_response_filename(func.__name__ + datetime.now().strftime('%Y%m%d_%H%M') + '.xlsx')

track_report(kwargs)
return output
Expand All @@ -388,7 +388,7 @@ def csvout(self, session, set_headers=True, **kwargs):
# set headers last in case there were errors, so end user still see error page
if set_headers:
cherrypy.response.headers['Content-Type'] = 'application/csv'
_set_response_filename(func.__name__ + datetime.now().strftime('%Y%m%d') + '.csv')
_set_response_filename(func.__name__ + datetime.now().strftime('%Y%m%d_%H%M') + '.csv')

track_report(kwargs)
return output
Expand Down
9 changes: 8 additions & 1 deletion uber/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,14 @@ def _convert_relation_ids_to_instances(self):

@presave_adjustment
def update_last_updated(self):
self.last_updated = datetime.now(UTC)
if not getattr(self, 'skip_last_updated', None):
self.last_updated = datetime.now(UTC)

def last_synced_dt(self, key):
return dateparser.parse(json.loads(self.last_synced.get(key, '"1970/01/01"')))

def update_last_synced(self, key, sync_time):
self.last_synced[key] = json.dumps(str(UTC.localize(dateparser.parse(sync_time))))

@property
def session(self):
Expand Down
25 changes: 12 additions & 13 deletions uber/models/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,20 +474,19 @@ def physical_address(self):

physical_address = [address1, address2, city_region_zip, country]
return '\n'.join([s for s in physical_address if s])

@property
def guidebook_name(self):
return self.name
def guidebook_edit_link(self):
return f"../group_admin/form?id={self.id}"

@property
def guidebook_subtitle(self):
def guidebook_data(self):
category_labels = [cat for cat in self.categories_labels if 'Other' not in cat] + [self.categories_text]
return ', '.join(category_labels[:5])

@property
def guidebook_desc(self):
return self.description

@property
def guidebook_location(self):
return ''
return {
'guidebook_name': self.name,
'guidebook_subtitle': ', '.join(category_labels[:5]),
'guidebook_desc': self.description,
'guidebook_location': '',
'guidebook_header': '',
'guidebook_thumbnail': '',
}
46 changes: 28 additions & 18 deletions uber/models/guests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from collections import defaultdict
from datetime import datetime, timedelta

from pockets import uniquify, classproperty
from pockets import uniquify, classproperty, sluggify
from residue import JSON, CoerceUTF8 as UnicodeText, UTCDateTime, UUID
from sqlalchemy.orm import backref
from sqlalchemy.schema import ForeignKey
Expand Down Expand Up @@ -192,33 +192,43 @@ def status(self, model):
if subclass:
return getattr(subclass, 'status', getattr(subclass, 'id'))
return ''

@property
def guidebook_name(self):
return self.group.name if self.group else ''


@property
def guidebook_subtitle(self):
return self.group_type_label
def guidebook_header(self):
# Temp: we need real header/thumbnail images later
if self.bio:
return self.bio
return ''

@property
def guidebook_desc(self):
return self.bio.desc if self.bio else ''

def guidebook_thumbnail(self):
if self.bio:
return self.bio
return ''

@property
def guidebook_image(self):
return self.bio.pic_filename if self.bio else ''

def guidebook_edit_link(self):
return f"../guests/bio?guest_id={self.id}"
@property
def guidebook_thumbnail(self):
return self.bio.pic_filename if self.bio else ''
def guidebook_data(self):
return {
'guidebook_name': self.group.name if self.group else '',
'guidebook_subtitle': self.group_type_label,
'guidebook_desc': self.bio.desc if self.bio else '',
'guidebook_location': '',
'guidebook_header': self.guidebook_images[0][0],
'guidebook_thumbnail': self.guidebook_images[0][1],
}

@property
def guidebook_images(self):
if not self.bio:
return ['', '']
return ['', ''], ['', '']

prepend = sluggify(self.group.name) + '_'

return [self.bio.pic_filename], [self.bio]
return [prepend + self.bio.pic_filename, prepend + self.bio.pic_filename], [self.bio, self.bio]


class GuestInfo(MagModel):
Expand Down
13 changes: 5 additions & 8 deletions uber/models/mits.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def guidebook_thumbnail(self):

@property
def guidebook_edit_link(self):
return f"../mits/team?id={self.id}"
return f"../mits_admin/team?id={self.team.id}"

@property
def guidebook_data(self):
Expand All @@ -212,8 +212,8 @@ def guidebook_data(self):
'guidebook_subtitle': self.name,
'guidebook_desc': self.description,
'guidebook_location': '',
'guidebook_header': self.guidebook_header.filename,
'guidebook_thumbnail': self.guidebook_thumbnail.filename,
'guidebook_header': self.guidebook_images[0][0],
'guidebook_thumbnail': self.guidebook_images[0][1],
}

@property
Expand All @@ -234,12 +234,9 @@ def guidebook_images(self):
if not thumbnail:
thumbnail = self.pictures[1] if len(self.pictures) > 1 else self.pictures[0]

prepend = sluggify(self.name)
prepend = sluggify(self.name) + '_'

if header == thumbnail:
return [prepend + header.filename], [header]
else:
return [prepend + header.filename, prepend + thumbnail.filename], [header, thumbnail]
return [prepend + header.filename, prepend + thumbnail.filename], [header, thumbnail]


class MITSPicture(MagModel):
Expand Down
51 changes: 22 additions & 29 deletions uber/models/mivs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from datetime import datetime, timedelta
from functools import wraps

from pockets import sluggify
from pytz import UTC
from residue import CoerceUTF8 as UnicodeText, UTCDateTime, UUID
from sqlalchemy import func
Expand Down Expand Up @@ -474,22 +474,6 @@ def confirmed(self):
def has_been_accepted(self):
return self.status == c.ACCEPTED

@property
def guidebook_name(self):
return self.studio.name

@property
def guidebook_subtitle(self):
return self.title

@property
def guidebook_desc(self):
return self.description

@property
def guidebook_location(self):
return ''

@property
def guidebook_header(self):
for image in self.images:
Expand All @@ -504,28 +488,37 @@ def guidebook_thumbnail(self):
return image
return ''

@property
def guidebook_edit_link(self):
return f"../mivs/show_info?id={self.id}"

@property
def guidebook_data(self):
return {
'guidebook_name': self.studio.name,
'guidebook_subtitle': self.title,
'guidebook_desc': self.description,
'guidebook_location': '',
'guidebook_header': self.guidebook_images[0][0],
'guidebook_thumbnail': self.guidebook_images[0][1],
}

@property
def guidebook_images(self):
if not self.images:
return ['', '']

header = None
thumbnail = None
for image in self.images:
if image.is_header and not header:
header = image
if image.is_thumbnail and not thumbnail:
thumbnail = image
header = self.guidebook_header
thumbnail = self.guidebook_thumbnail

if not header:
header = self.images[0]
if not thumbnail:
thumbnail = self.images[1] if len(self.images) > 1 else self.images[0]

if header == thumbnail:
return [header.filename], [header]
else:
return [header.filename, thumbnail.filename], [header, thumbnail]
prepend = sluggify(self.title) + '_'

return [prepend + header.filename, prepend + thumbnail.filename], [header, thumbnail]


class IndieGameImage(MagModel):
Expand All @@ -541,7 +534,7 @@ class IndieGameImage(MagModel):

@property
def url(self):
return 'view_image?id={}'.format(self.id)
return '../mivs/view_image?id={}'.format(self.id)

@property
def filepath(self):
Expand Down
Loading

0 comments on commit d3ad111

Please sign in to comment.