Skip to content

Commit

Permalink
Merge pull request #1721 from emfcamp/village-submitted-content-fixes
Browse files Browse the repository at this point in the history
Village attendee-submitted-content fixes
  • Loading branch information
lukegb authored Jun 1, 2024
2 parents 2937ff6 + ffcbc5f commit 1cd0f42
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
5 changes: 5 additions & 0 deletions apps/villages/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def admin_village(village_id):
form = AdminVillageForm()

if form.validate_on_submit():
for venue in village.venues:
if venue.name == village.name:
# Rename a village venue if it exists and has the old name.
venue.name = form.name.data

form.populate_obj(village)
db.session.add(village)
db.session.commit()
Expand Down
10 changes: 10 additions & 0 deletions apps/villages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ def edit(year, village_id):

form = VillageForm()
if form.validate_on_submit():
if Village.get_by_name(form.name.data):
# FIXME: this should be a WTForms validation
flash("A village already exists with that name, please choose another")
return redirect(url_for(".register"))

for venue in village.venues:
if venue.name == village.name:
# Rename a village venue if it exists and has the old name.
venue.name = form.name.data

form.populate_obj(village)
form.populate_obj(village.requirements)
db.session.commit()
Expand Down
36 changes: 23 additions & 13 deletions models/cfp.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,22 +799,11 @@ def slug(self):

@property
def latlon(self):
if self.scheduled_venue and self.scheduled_venue.location:
loc = to_shape(self.scheduled_venue.location)
return (loc.y, loc.x)
return None
return self.scheduled_venue.latlon if self.scheduled_venue else None

@property
def map_link(self) -> Optional[str]:
latlon = self.latlon
if latlon:
return "https://map.emfcamp.org/#18.5/%s/%s/m=%s,%s" % (
latlon[0],
latlon[1],
latlon[0],
latlon[1],
)
return None
return self.scheduled_venue.map_link if self.scheduled_venue else None

@property
def display_title(self) -> str:
Expand Down Expand Up @@ -1183,6 +1172,27 @@ def emf_venue_names_by_type(cls):
def get_by_name(cls, name):
return cls.query.filter_by(name=name).one()

@property
def latlon(self):
if self.location:
loc = to_shape(self.location)
return (loc.y, loc.x)
if self.village and self.village.latlon:
return self.village.latlon
return None

@property
def map_link(self) -> Optional[str]:
latlon = self.latlon
if latlon:
return "https://map.emfcamp.org/#18.5/%s/%s/m=%s,%s" % (
latlon[0],
latlon[1],
latlon[0],
latlon[1],
)
return None


# TODO: change the relationships on User and Proposal to 1-to-1
db.Index(
Expand Down

0 comments on commit 1cd0f42

Please sign in to comment.