-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from cf15-t5/development
Feat/tickets (#23)
- Loading branch information
Showing
29 changed files
with
472 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,10 @@ PORT=5000 | |
DEBUG=True | ||
|
||
DATABASE_URL="mysql+pymysql://username:password@localhost:3306/se_ticket" | ||
|
||
MAIL_SERVER='smtp.gmail.com' | ||
MAIL_PORT = 587 | ||
MAIL_USERNAME = '[email protected]' | ||
MAIL_PASSWORD = 'duewujqfideibbkm' | ||
MAIL_USE_TLS = False | ||
MAIL_USE_SSL = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Create_Ticket_table | ||
Revision ID: 734664dd0b82 | ||
Revises: c6f3e7ccf086 | ||
Create Date: 2023-08-21 16:05:02.108956 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = '734664dd0b82' | ||
down_revision = 'c6f3e7ccf086' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('tickets', | ||
sa.Column('ticket_id', sa.Integer(), nullable=False), | ||
sa.Column('event_id', sa.Integer(), nullable=True), | ||
sa.Column('user_id', sa.Integer(), nullable=True), | ||
sa.Column('ticket_code', sa.String(length=6), nullable=True), | ||
sa.Column('is_attended', sa.Boolean(), nullable=True), | ||
sa.Column('created_at', sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint(['event_id'], ['events.event_id'], ), | ||
sa.ForeignKeyConstraint(['user_id'], ['users.user_id'], ), | ||
sa.PrimaryKeyConstraint('ticket_id') | ||
) | ||
with op.batch_alter_table('events', schema=None) as batch_op: | ||
batch_op.drop_column('created_at') | ||
|
||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
with op.batch_alter_table('events', schema=None) as batch_op: | ||
batch_op.add_column(sa.Column('created_at', sa.DATE(), nullable=True)) | ||
|
||
op.drop_table('tickets') | ||
# ### end Alembic commands ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Event Information Ticket</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
.container { | ||
max-width: 600px; | ||
margin: 0 auto; | ||
background-color: #ffffff; | ||
padding: 20px; | ||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); | ||
} | ||
h1 { | ||
color: #333; | ||
} | ||
p { | ||
line-height: 1.6; | ||
color: #666; | ||
} | ||
.event-details { | ||
background-color: #f9f9f9; | ||
padding: 10px; | ||
border-radius: 5px; | ||
} | ||
.button { | ||
display: inline-block; | ||
padding: 10px 20px; | ||
background-color: #007BFF; | ||
color: #ffffff; | ||
text-decoration: none; | ||
border-radius: 5px; | ||
} | ||
.ticket-code { | ||
background-color: #007BFF; | ||
color: #ffffff; | ||
padding: 10px; | ||
border-radius: 5px; | ||
margin-top: 20px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Your Event Information Ticket</h1> | ||
<p>Dear [Recipient's Name],</p> | ||
<p>We are excited to have you join us for our upcoming event. Here are the details you'll need:</p> | ||
|
||
<div class="event-details"> | ||
<h2>Event Details</h2> | ||
<p><strong>Event Name:</strong> [Event Name]</p> | ||
<p><strong>Date:</strong> [Event Date]</p> | ||
<p><strong>Time:</strong> [Event Time]</p> | ||
<p><strong>Location:</strong> [Event Location]</p> | ||
</div> | ||
|
||
<p>If you have any questions or need further assistance, please don't hesitate to contact us.</p> | ||
<p>Thank you for being a part of this event!</p> | ||
|
||
<p>Your Ticket Code:</p> | ||
<div class="ticket-code"> | ||
{{ code }} | ||
</div> | ||
|
||
<p>Best Regards,<br>Your Event Team</p> | ||
|
||
<p><a class="button" href="[Event Link]">Get Directions</a></p> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from flask_mail import Mail | ||
from src.config.config import MAIL_PORT,MAIL_SERVER,MAIL_USE_SSL,MAIL_USE_TLS,MAIL_USERNAME,MAIL_PASSWORD | ||
def mailConfig(app): | ||
print(MAIL_SERVER,MAIL_PORT,MAIL_USE_SSL,MAIL_USE_TLS,MAIL_USERNAME,MAIL_PASSWORD) | ||
print(type(MAIL_SERVER),type(MAIL_PORT),type(MAIL_USE_SSL),type(MAIL_USE_TLS),type(MAIL_USERNAME),type(MAIL_PASSWORD)) | ||
app.config['MAIL_SERVER']= MAIL_SERVER | ||
app.config['MAIL_PORT'] = MAIL_PORT | ||
app.config['MAIL_USE_TLS'] = MAIL_USE_TLS == 'True' | ||
app.config['MAIL_USE_SSL'] = MAIL_USE_SSL == 'True' | ||
app.config['MAIL_USERNAME'] = MAIL_USERNAME | ||
app.config['MAIL_PASSWORD'] = MAIL_PASSWORD | ||
return Mail(app) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
'/auth/logout', | ||
'/categories', | ||
'/events/', | ||
'/tickets/' | ||
] | ||
|
||
admin_permission=[ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from flask import Blueprint | ||
from flask import request,g | ||
from src.services.TicketService import TicketService | ||
from src.middlewares.AuthMiddleware import isAuthenticated | ||
import src.utils.getResponse as Response | ||
|
||
TicketApp = Blueprint('TicketApp', __name__,) | ||
ticketService = TicketService() | ||
|
||
@TicketApp.route('/', methods=['GET']) | ||
@isAuthenticated | ||
def index(): | ||
|
||
result = ticketService.getAllTickets() | ||
return Response.success(result['data'],"success get all Tickets") | ||
|
||
@TicketApp.route('/', methods=['POST']) | ||
@isAuthenticated | ||
def store(): | ||
result = ticketService.createNewTicket(request.json,g.user['user_id']) | ||
if(result['status'] == 'failed'): | ||
return Response.error(result['data'],result['code']) | ||
return Response.success(result['data'],"success create new event") | ||
|
||
@TicketApp.route('/my', methods=['GET']) | ||
@isAuthenticated | ||
def myTicket(): | ||
result = ticketService.getTicketByUserId(g.user['user_id']) | ||
if(result['status'] == 'failed'): | ||
return Response.error(result['data'],result['code']) | ||
return Response.success(result['data'],"success get all my ticket") | ||
|
||
|
||
@TicketApp.route('/<id>/delete', methods=['DELETE']) | ||
@isAuthenticated | ||
def delete(id): | ||
result = ticketService.deleteCategory(id) | ||
if(result['status'] == 'failed'): | ||
return Response.error(result['data'],result['code']) | ||
|
||
return Response.success(result['data'],"success delete event") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from src.server.main import db,main_app | ||
from src.config.database import generateDatabase | ||
class Ticket(db.Model): | ||
__tablename__ = 'tickets' | ||
|
||
ticket_id = db.Column(db.Integer, primary_key=True) | ||
event_id = db.Column(db.Integer, db.ForeignKey('events.event_id')) | ||
user_id = db.Column(db.Integer, db.ForeignKey('users.user_id')) | ||
ticket_code = db.Column(db.String(6)) | ||
is_attended = db.Column(db.Boolean, default=False) | ||
created_at = db.Column(db.DateTime, default=db.func.current_timestamp()) | ||
event = db.relationship("Event", backref="tickets") | ||
user = db.relationship("User", back_populates="tickets") | ||
def __init__(self, event_id, user_id, ticket_code): | ||
self.event_id = event_id | ||
self.user_id = user_id | ||
self.ticket_code = ticket_code | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.