Skip to content

Commit

Permalink
feature: Added cancelling of events
Browse files Browse the repository at this point in the history
  • Loading branch information
whustedt committed Jun 6, 2024
1 parent 6626a07 commit fab1f12
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 54 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Below are the available API endpoints with their respective usage:
- **POST** `/delete/<int:id>`
- Deletes an entry by ID.

- **Toggle Entry Cancellation**
- **POST** `/toggle_canceled/<int:id>`
- Toggles the cancellation status of an entry by ID. The route changes the `canceled` state of the entry to either `True` or `False` depending on its current state. A successful operation will redirect back to the main page, updating the entry's status in the view.

- **API Data Access**
- **GET** `/api/data`
- Returns all entries in JSON format, including additional attributes such as `date_formatted` and `index` which help in sorting and formatting entries relative to the current date.
Expand Down Expand Up @@ -163,6 +167,10 @@ This project uses Flickity, which is licensed under the GPLv3.

As such, modifications to the Flickity source code used in this project are documented in the repository. To comply with the GPLv3, all source code for this application is available under the same license. The full license text is included in the LICENSE file in this repository.

## Icon Attribution

This project uses the icon "cracked glass" by Olena Panasovska from [Noun Project](https://thenounproject.com/icon/cracked-glass-3292568/) licensed under [CC BY 3.0](https://creativecommons.org/licenses/by/3.0/). To meet the attribution requirements, this link points directly to the icon's detail page. Please refer to the Noun Project's guidelines for detailed information on how to properly attribute the creator in different formats and mediums.

## Docker Image

Instead of Docker Hub, this project's Docker images are now built and pushed through GitHub Actions to the GitHub Container Registry.
3 changes: 2 additions & 1 deletion app/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def get_formatted_entries(entries):
'image_url': url_for('uploaded_file', filename=entry.image_filename) if entry.image_filename else None,
'image_url_external': url_for('uploaded_file', filename=entry.image_filename, _external=True) if entry.image_filename else None,
'index': i - index,
'isToday': entry.date == today
'isToday': entry.date == today,
'cancelled': entry.cancelled
}
data.append(entry_data)

Expand Down
1 change: 1 addition & 0 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Entry(db.Model):
description = db.Column(db.String(1000), nullable=True)
image_filename = db.Column(db.String(100), nullable=True)
url = db.Column(db.String(1000), nullable=True)
cancelled = db.Column(db.Boolean, nullable=False, default=False)
last_updated_by = db.Column(db.String(130), nullable=True)

# Define category choices
Expand Down
20 changes: 19 additions & 1 deletion app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,23 @@ def delete(id):
db.session.commit()
return redirect(url_for('index'))

@app.route('/toggle_cancelled/<int:id>', methods=['POST'])
def toggle_cancelled(id):
"""Toggle the cancelled state of an entry."""
try:
entry = db.session.query(Entry).get(id)
if entry is None:
return jsonify({"error": "Entry not found"}), 404

# Toggle the cancelled state
entry.cancelled = not entry.cancelled
db.session.commit()

return redirect(url_for('index'))
except Exception as e:
current_app.logger.error(f"Error toggling the cancelled state of the entry: {e}")
return jsonify({"error": "Failed to update entry"}), 500

@app.route('/timeline', methods=['GET'])
def timeline():
"""Generate a timeline view of entries, calculating positions based on dates."""
Expand Down Expand Up @@ -257,7 +274,8 @@ def batch_import():
category=item['category'],
title=item['title'],
description=item.get('description', None),
url = item.get('url', None)
url = item.get('url', None),
cancelled = item.get('cancelled', False)
)
db.session.add(new_entry)
except KeyError as e:
Expand Down
9 changes: 2 additions & 7 deletions app/static/admin/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,24 +132,19 @@ img {
opacity: .5;
}

button.edit {
button.edit, button.cancel-restore, button.delete {
background-color: #008CBA; /* Blue for edit */
color: white;
border: none;
padding: 5px 10px;
cursor: pointer;
font-size: 1rem;
border-radius: 4px;
margin: 1px 0px;
}

button.delete {
background-color: #f44336; /* Red for delete */
color: white;
border: none;
padding: 5px 10px;
cursor: pointer;
font-size: 1rem;
border-radius: 4px;
}

.maintenance-panel {
Expand Down
15 changes: 15 additions & 0 deletions app/static/timeline/cracked-glass.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 18 additions & 1 deletion app/static/timeline/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,22 @@ html, body {
@keyframes shake-tilt { 0%, 50%, 100% { transform: translateX(0) rotate(0); } 30%, 70% { transform: translateX(2px) rotate(5deg); }}
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); }}
@keyframes pulsateShadow { 0%, 100% { box-shadow: 0 0 8px 0 orangered } 50% { box-shadow: 0 0 11px 3px orangered }}
@keyframes pulsate {0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); }
@keyframes pulsate {0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); }}

.timeline-item.cancelled .title {
text-decoration: line-through; /* Strikethrough for the title */
}

.timeline-item.cancelled::after {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: url('cracked-glass.svg'); /* Path to the SVG file */
background-size: cover;
background-repeat: no-repeat;
z-index: 2;
opacity: .7;
}
Loading

0 comments on commit fab1f12

Please sign in to comment.