-
Notifications
You must be signed in to change notification settings - Fork 1
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 #206 from gcivil-nyu-org/develop
Https, video, community
- Loading branch information
Showing
54 changed files
with
2,044 additions
and
228 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
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,114 @@ | ||
option_settings: | ||
aws:elasticbeanstalk:environment:proxy:staticfiles: | ||
/static: static | ||
aws:elasticbeanstalk:application:environment: | ||
DJANGO_SETTINGS_MODULE: "TutorNYU.settings" | ||
PYTHONPATH: "/var/app/current:$PYTHONPATH" | ||
DJANGO_ASGI_APPLICATION: "TutorNYU.asgi:application" | ||
DAPHNE_PORT: "5000" | ||
aws:elasticbeanstalk:container:python: | ||
WSGIPath: "TutorNYU.wsgi:application" | ||
aws:elbv2:listener:80: | ||
DefaultProcess: http | ||
ListenerEnabled: 'true' | ||
Protocol: HTTP | ||
Rules: ws | ||
aws:elbv2:listenerrule:ws: | ||
PathPatterns: /ws/* | ||
Process: websocket | ||
Priority: 1 | ||
aws:elasticbeanstalk:environment:process:http: | ||
Port: '80' | ||
Protocol: HTTP | ||
aws:elasticbeanstalk:environment:process:websocket: | ||
Port: '5000' | ||
Protocol: HTTP | ||
aws:elbv2:listener:443: | ||
DefaultProcess: http | ||
ListenerEnabled: 'true' | ||
Protocol: HTTPS | ||
SSLCertificateArns: arn:aws:acm:us-west-2:381492260474:certificate/65f910d1-d446-4350-a9ce-5a9a65853cd5 | ||
Rules: wss | ||
aws:elbv2:listenerrule:wss: | ||
PathPatterns: /ws/* | ||
Process: websocket | ||
Priority: 2 | ||
aws:elasticbeanstalk:environment:process:https: | ||
Port: '443' | ||
Protocol: HTTPS | ||
|
||
container_commands: | ||
00_make_executable: | ||
command: "chmod +x /opt/elasticbeanstalk/hooks/appdeploy/pre/50start_supervisord.sh" | ||
|
||
01_start_supervisord: | ||
command: "/opt/elasticbeanstalk/hooks/appdeploy/pre/50start_supervisord.sh" | ||
leader_only: true | ||
|
||
02_start_daphne: | ||
command: "supervisorctl -c /opt/python/etc/supervisord.conf start daphne >> /var/log/daphne_supervisor_start.log 2>&1" | ||
leader_only: true | ||
|
||
files: | ||
"/opt/elasticbeanstalk/hooks/appdeploy/pre/50start_supervisord.sh": | ||
mode: "000755" | ||
owner: root | ||
group: root | ||
content: | | ||
#!/bin/bash | ||
|
||
SUPERVISORD="/var/app/venv/staging-LQM1lest/bin/supervisord" | ||
SUPERVISORCTL="/var/app/venv/staging-LQM1lest/bin/supervisorctl" | ||
|
||
CONFIG="/opt/python/etc/supervisord.conf" | ||
|
||
if pgrep -f $SUPERVISORD > /dev/null; then | ||
echo "Supervisord is running, attempting to stop it." | ||
$SUPERVISORCTL -c $CONFIG shutdown | ||
sleep 5 | ||
|
||
if pgrep -f $SUPERVISORD > /dev/null; then | ||
echo "Supervisord did not shut down gracefully; forcing shutdown." | ||
pkill -f $SUPERVISORD | ||
sleep 2 | ||
fi | ||
fi | ||
echo "Starting supervisord..." | ||
$SUPERVISORD -c $CONFIG | ||
|
||
|
||
|
||
"/opt/python/etc/supervisord.conf": | ||
mode: "000644" | ||
owner: root | ||
group: root | ||
content: | | ||
[supervisord] | ||
nodaemon=false | ||
|
||
[unix_http_server] | ||
file=/tmp/supervisor.sock | ||
|
||
[supervisorctl] | ||
serverurl=unix:///tmp/supervisor.sock | ||
|
||
[rpcinterface:supervisor] | ||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface | ||
|
||
[program:daphne] | ||
command=/var/app/venv/staging-LQM1lest/bin/daphne -u /tmp/daphne.sock -b 0.0.0.0 -p 5000 TutorNYU.asgi:application | ||
directory=/var/app/current | ||
autostart=true | ||
autorestart=true | ||
stdout_logfile=/var/log/daphne.out.log | ||
stderr_logfile=/var/log/daphne.err.log | ||
environment=DJANGO_SETTINGS_MODULE="TutorNYU.settings",PYTHONPATH="/var/app/current:$PYTHONPATH" | ||
|
||
[program:gunicorn] | ||
command=/var/app/venv/staging-LQM1lest/bin/gunicorn TutorNYU.wsgi:application --bind 0.0.0.0:8000 | ||
directory=/var/app/current | ||
autostart=true | ||
autorestart=true | ||
stdout_logfile=/var/log/gunicorn.out.log | ||
stderr_logfile=/var/log/gunicorn.err.log | ||
environment=DJANGO_SETTINGS_MODULE="TutorNYU.settings",PYTHONPATH="/var/app/current:$PYTHONPATH" |
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
Empty file.
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,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
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,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class CommunityConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "Community" |
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,42 @@ | ||
from django import forms | ||
from TutorRegister.models import Post, Reply | ||
|
||
|
||
class CreatePostForm(forms.ModelForm): | ||
class Meta: | ||
model = Post | ||
|
||
fields = ["title", "content", "label", "attachment"] | ||
|
||
labels = { | ||
"title": "Title", | ||
"content": "Content", | ||
"label": "Label", | ||
"attachment": "Attachment", | ||
} | ||
|
||
widgets = { | ||
"title": forms.TextInput(attrs={"class": "form-control"}), | ||
"content": forms.Textarea(attrs={"class": "form-control"}), | ||
"label": forms.RadioSelect(attrs={"class": "form-check-input"}), | ||
"attachment": forms.FileInput(attrs={"class": "form-control-file"}), | ||
} | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(CreatePostForm, self).__init__(*args, **kwargs) | ||
|
||
self.fields["label"].choices = [ | ||
("resource", "Resource"), | ||
("question", "Question"), | ||
] | ||
|
||
|
||
class CreateReplyForm(forms.ModelForm): | ||
class Meta: | ||
model = Reply | ||
|
||
fields = ["content"] | ||
|
||
labels = {"content": "Content"} | ||
|
||
widgets = {"content": forms.Textarea(attrs={"class": "form-control"})} |
Empty file.
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,3 @@ | ||
from django.db import models | ||
|
||
# Create your models here. |
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,122 @@ | ||
{% extends 'Dashboard/base_student.html' %} | ||
|
||
{% block title %}Create New Post{% endblock %} | ||
|
||
{% block content %} | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Create Post</title> | ||
<!-- Bootstrap CSS --> | ||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"> | ||
<style> | ||
.btn-purple { | ||
color: #800080; | ||
background-color: transparent; | ||
border-color: #800080; | ||
} | ||
.btn-purple.clicked { | ||
color: #fff; | ||
background-color: #800080; | ||
border-color: #800080; | ||
} | ||
.btn-purple:hover { | ||
color: #fff; | ||
background-color: #800080; | ||
border-color: #800080; | ||
} | ||
.card-header { | ||
background: none; /* Remove background */ | ||
border-bottom: none; /* Remove border */ | ||
} | ||
.btn-purple:not(.clicked):hover { | ||
background-color: #800080; | ||
border-color: #800080; | ||
color: white; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container-fluid"> | ||
<div class="row justify-content-center"> | ||
<div class="col-lg-8"> | ||
<div class="card mt-5 rounded-4 shadow"> | ||
<div class="card-header"> | ||
<h5 class="card-title" style="margin-top: 20px; margin-left: 20px;"><strong>Create a New Post</strong></h5> | ||
</div> | ||
<div class="card-body" style="margin-left: 20px; margin-right: 20px;"> | ||
<form method="post" enctype="multipart/form-data"> | ||
{% csrf_token %} | ||
{% if form.errors %} | ||
<div class="alert alert-danger" role="alert"> | ||
Please correct the errors below: | ||
<ul> | ||
{% for error in form.non_field_errors %} | ||
<li>{{ error }}</li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
{% endif %} | ||
<div class="mb-3"> | ||
<label class="form-label">Label:</label> | ||
<div class="btn-group" role="group" aria-label="User Type"> | ||
{% for value, label in form.label.field.choices %} | ||
<input type="radio" class="btn-check" name="label" id="label_{{ forloop.counter }}" value="{{ value }}" autocomplete="off"> | ||
<label class="btn btn-purple" style="margin-right: 5px;" onclick="selectLabel(this)" for="label_{{ forloop.counter }}">{{ label }}</label> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
<div class="mb-3"> | ||
<label for="title" class="form-label">Title</label> | ||
{{ form.title }} | ||
{% for error in form.title.errors %} | ||
<div class="text-danger">{{ error }}</div> | ||
{% endfor %} | ||
</div> | ||
<div class="mb-3"> | ||
<label for="content" class="form-label">Content</label> | ||
{{ form.content }} | ||
{% for error in form.content.errors %} | ||
<div class="text-danger">{{ error }}</div> | ||
{% endfor %} | ||
</div> | ||
<div class="mb-3"> | ||
<label for="attachment" class="form-label">Attach File (optional)</label> | ||
<input class="form-control" type="file" id="attachment" name="attachment"> | ||
{% for error in form.attachment.errors %} | ||
<div class="text-danger">{{ error }}</div> | ||
{% endfor %} | ||
</div> | ||
<div class="d-flex justify-content-center"> | ||
<button type="submit" class="btn btn-primary btn-purple" style="background-color: #600E90; color: white; border-color: #600E90; margin-bottom: 20px; margin-left: 20px">Post</button> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<!-- Bootstrap Bundle with Popper --> | ||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"></script> | ||
<script> | ||
function selectLabel(button) { | ||
// Remove 'clicked' class from all buttons | ||
document.querySelectorAll('.btn-purple').forEach(btn => { | ||
btn.classList.remove('clicked'); | ||
btn.style.backgroundColor = "white"; | ||
btn.style.color='#600E90'; | ||
}); | ||
// Add 'clicked' class to selected button | ||
button.classList.add('clicked'); | ||
button.style.backgroundColor='#600E90'; | ||
button.style.color = 'white'; | ||
} | ||
</script> | ||
</body> | ||
</html> | ||
|
||
{% endblock %} |
Oops, something went wrong.