finised app
This commit is contained in:
54
app.py
54
app.py
@@ -281,18 +281,31 @@ def delete_content(content_id):
|
||||
db.session.commit()
|
||||
return redirect(url_for('player_page', player_id=player_id))
|
||||
|
||||
@app.route('/player/<int:player_id>/fullscreen')
|
||||
@login_required
|
||||
@app.route('/player/<int:player_id>/fullscreen', methods=['GET', 'POST'])
|
||||
def player_fullscreen(player_id):
|
||||
player = Player.query.get_or_404(player_id)
|
||||
if player.groups:
|
||||
# If the player is part of a group, get the group's content
|
||||
group = player.groups[0] # Assuming a player can only be in one group
|
||||
content = Content.query.filter_by(group_id=group.id).all()
|
||||
|
||||
if request.method == 'POST':
|
||||
hostname = request.form['hostname']
|
||||
password = request.form['password']
|
||||
if player.hostname == hostname and bcrypt.check_password_hash(player.password, password):
|
||||
authenticated = True
|
||||
else:
|
||||
authenticated = False
|
||||
else:
|
||||
# If the player is not part of a group, get the player's content
|
||||
content = Content.query.filter_by(player_id=player_id).all()
|
||||
return render_template('player_fullscreen.html', player=player, content=content)
|
||||
authenticated = False
|
||||
|
||||
if authenticated or current_user.is_authenticated:
|
||||
if player.groups:
|
||||
# If the player is part of a group, get the group's content
|
||||
group = player.groups[0] # Assuming a player can only be in one group
|
||||
content = Content.query.filter_by(group_id=group.id).all()
|
||||
else:
|
||||
# If the player is not part of a group, get the player's content
|
||||
content = Content.query.filter_by(player_id=player_id).all()
|
||||
return render_template('player_fullscreen.html', player=player, content=content)
|
||||
else:
|
||||
return render_template('player_auth.html', player_id=player_id)
|
||||
|
||||
@app.route('/group/<int:group_id>/fullscreen')
|
||||
@login_required
|
||||
@@ -338,6 +351,29 @@ def add_group():
|
||||
return redirect(url_for('dashboard'))
|
||||
return render_template('add_group.html')
|
||||
|
||||
@app.route('/integrate_player')
|
||||
@login_required
|
||||
@admin_required
|
||||
def integrate_player():
|
||||
players = Player.query.all()
|
||||
groups = Group.query.all()
|
||||
return render_template('integrate_player.html', players=players, groups=groups)
|
||||
|
||||
@app.route('/player/<int:player_id>/edit', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
@admin_required
|
||||
def edit_player(player_id):
|
||||
player = Player.query.get_or_404(player_id)
|
||||
if request.method == 'POST':
|
||||
player.username = request.form['username']
|
||||
player.hostname = request.form['hostname']
|
||||
player.ip = request.form['ip']
|
||||
if request.form['password']:
|
||||
player.password = bcrypt.generate_password_hash(request.form['password']).decode('utf-8')
|
||||
db.session.commit()
|
||||
return redirect(url_for('player_page', player_id=player.id))
|
||||
return render_template('edit_player.html', player=player)
|
||||
|
||||
if __name__ == '__main__':
|
||||
with app.app_context():
|
||||
db.create_all() # Creează toate tabelele
|
||||
|
||||
Reference in New Issue
Block a user