Skip to content
This repository was archived by the owner on Feb 3, 2024. It is now read-only.

Commit 1db2b57

Browse files
authored
Merge branch 'ComputerScienceHouse:master' into random-quote
2 parents a4dc0f1 + 615c966 commit 1db2b57

File tree

6 files changed

+110
-197
lines changed

6 files changed

+110
-197
lines changed

quotefault/mail.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def send_report_email(reporter, quote):
2121
sender=app.config.get('MAIL_USERNAME'),
2222
recipients=recipients)
2323
template = 'mail/report'
24-
msg.body = render_template(template + '.txt', reporter = reporter, quote = quote )
25-
msg.html = render_template(template + '.html', reporter = reporter, quote = quote )
24+
msg.body = render_template(template + '.txt', reporter = reporter, quote = quote, server = app.config['SERVER_NAME'])
25+
msg.html = render_template(template + '.html', reporter = reporter, quote = quote, server = app.config['SERVER_NAME'])
2626
mail_client.send(msg)
2727

2828
def send_email(toaddr, subject, body):
Lines changed: 2 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,2 @@
1-
{% for quote, votes in quotes %}
2-
<div class="card m-3">
3-
<div class="card-body">
4-
"{{ quote.quote }}" <b>- {{ get_display_name(quote.speaker) }}</b>
5-
<div id="votes-{{ quote.id }}" class="upvote upvote-meta-stackoverflow">
6-
<a class="upvote" id="upVote-{{ quote.id }}" onClick="makeVote({{ quote.id }}, 1)">
7-
</a>
8-
<span class="count">
9-
{% if votes %}
10-
{{ votes }}
11-
{% else %}
12-
0
13-
{% endif %}
14-
</span>
15-
<a class="downvote" id="downVote-{{ quote.id }}"
16-
onClick="makeVote({{ quote.id }}, -1)">
17-
</a>
18-
</div>
19-
</div>
20-
<div class="card-footer">
21-
Submitted by <a
22-
href="https://profiles.csh.rit.edu/user/{{ quote.submitter }}">{{ get_display_name(quote.submitter) }}</a>
23-
on {{ quote.quote_time.strftime('%Y-%m-%d %H:%M:%S') }}
24-
25-
<button type="button" class="btn btn-danger btn-sm float-right" onclick="report({{quote.id}})" id="report_button_{{quote.id}}">Report</button>
26-
<div class="modal" id="report_{{quote.id}}">
27-
<div class="modal-dialog" role="document">
28-
<div class="modal-content">
29-
<div class="modal-header">
30-
<h5 class="modal-title">Report Quote</h5>
31-
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
32-
aria-hidden="true">&times;</span>
33-
</button>
34-
</div>
35-
<div class="modal-body">
36-
<p>Are you sure you want to report this quote?</p>
37-
</div>
38-
<div class="modal-footer">
39-
<!-- TODO: Probably should not be using form and buttons and rather be using input. -->
40-
<!-- <a class="btn btn-primary btn-sm" href="/report/{{quote.id}}" id="report::{{quote.id}}" type="button btn-danger">Yes</a> -->
41-
<form method="POST" action="/report/{{quote.id}}" id="report::{{quote.id}}" method="POST">
42-
<button type="submit" class="btn btn-danger">Yes</button>
43-
</form>
44-
<button type="button" class="btn btn-success" onclck="reportClose({{quote.id}})" id="report_close_{{quote.id}}">No
45-
</button>
46-
</div>
47-
</div>
48-
</div>
49-
</div>
50-
{% if metadata['uid'] == quote.submitter or metadata['uid'] == quote.speaker or metadata['is_admin'] %}
51-
<button type="button" class="btn btn-warning btn-sm float-right" onclick="hide({{quote.id}})" id="hide_button_{{quote.id}}">Hide</button>
52-
<div class="modal" id="hide_{{quote.id}}">
53-
<div class="modal-dialog" role="document">
54-
<div class="modal-content">
55-
<div class="modal-header">
56-
<h5 class="modal-title">Hide Quote</h5>
57-
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
58-
aria-hidden="true">&times;</span>
59-
</button>
60-
</div>
61-
<div class="modal-body">
62-
<p>Are you sure you want to hide this quote?</p>
63-
</div>
64-
<div class="modal-footer">
65-
<!-- TODO: Probably should not be using form and buttons and rather be using input. -->
66-
<!-- <a class="btn btn-primary btn-sm" href="/report/{{quote.id}}" id="report::{{quote.id}}" type="button btn-danger">Yes</a> -->
67-
<form method="POST" action="/hide/{{quote.id}}" id="hide::{{quote.id}}" method="POST">
68-
<button type="submit" class="btn btn-danger">Yes</button>
69-
</form>
70-
<button type="button" class="btn btn-success" onclick="hideClose({{quote.id}})" id="hide_close_{{quote.id}}">No</button>
71-
</div>
72-
</div>
73-
</div>
74-
</div>
75-
{% endif %}
76-
</div>
77-
</div>
78-
{% endfor %}
79-
1+
{% from 'bootstrap/macro.html' import display_quotes as display with context %}
2+
{{ display( quotes ) }}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{% macro display_quotes(quotes) -%}
2+
<script type="text/javascript">
3+
function report(id){
4+
// Get the modal
5+
var modal = document.getElementById(`report_${id}`);
6+
modal.style.display = "block";
7+
}
8+
function reportClose(id){
9+
// Get the modal
10+
var modal = document.getElementById(`report_${id}`);
11+
modal.style.display = "none";
12+
}
13+
function hide(id){
14+
// Get the modal
15+
var modal = document.getElementById(`hide_${id}`);
16+
modal.style.display = "block";
17+
}
18+
function hideClose(id){
19+
// Get the modal
20+
var modal = document.getElementById(`hide_${id}`);
21+
modal.style.display = "none";
22+
}
23+
</script>
24+
{% for quote, votes in quotes %}
25+
<div class="card m-3">
26+
<div class="card-body">
27+
"{{ quote.quote }}" <b>- {{ get_display_name(quote.speaker) }}</b>
28+
<div id="votes-{{ quote.id }}" class="upvote upvote-meta-stackoverflow">
29+
<a class="upvote" id="upVote-{{ quote.id }}" onClick="makeVote({{ quote.id }}, 1)">
30+
</a>
31+
<span class="count">
32+
{% if votes %}
33+
{{ votes }}
34+
{% else %}
35+
0
36+
{% endif %}
37+
</span>
38+
<a class="downvote" id="downVote-{{ quote.id }}"
39+
onClick="makeVote({{ quote.id }}, -1)">
40+
</a>
41+
</div>
42+
</div>
43+
<div class="card-footer">
44+
Submitted by <a
45+
href="https://profiles.csh.rit.edu/user/{{ quote.submitter }}">{{ get_display_name(quote.submitter) }}</a>
46+
on {{ quote.quote_time.strftime('%Y-%m-%d %H:%M:%S') }}
47+
48+
<button type="button" class="btn btn-danger btn-sm float-right" onclick="report({{quote.id}})" id="report_button_{{quote.id}}">Report</button>
49+
<div class="modal" id="report_{{quote.id}}">
50+
<div class="modal-dialog" role="document">
51+
<div class="modal-content">
52+
<div class="modal-header">
53+
<h5 class="modal-title">Report Quote</h5>
54+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
55+
aria-hidden="true">&times;</span>
56+
</button>
57+
</div>
58+
<div class="modal-body">
59+
<p>Are you sure you want to report this quote?</p>
60+
</div>
61+
<div class="modal-footer">
62+
<!-- TODO: Probably should not be using form and buttons and rather be using input. -->
63+
<!-- <a class="btn btn-primary btn-sm" href="/report/{{quote.id}}" id="report::{{quote.id}}" type="button btn-danger">Yes</a> -->
64+
<form method="POST" action="/report/{{quote.id}}" id="report::{{quote.id}}" method="POST">
65+
<button type="submit" class="btn btn-danger">Yes</button>
66+
</form>
67+
<button type="button" class="btn btn-success" onclick="reportClose({{quote.id}})" id="report_close_{{quote.id}}">No</button>
68+
</div>
69+
</div>
70+
</div>
71+
</div>
72+
{% if metadata['uid'] == quote.submitter or metadata['uid'] == quote.speaker or metadata['is_admin'] %}
73+
<button type="button" class="btn btn-warning btn-sm float-right" onclick="hide({{quote.id}})" id="hide_button_{{quote.id}}">Hide</button>
74+
<div class="modal" id="hide_{{quote.id}}">
75+
<div class="modal-dialog" role="document">
76+
<div class="modal-content">
77+
<div class="modal-header">
78+
<h5 class="modal-title">Hide Quote</h5>
79+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
80+
aria-hidden="true">&times;</span>
81+
</button>
82+
</div>
83+
<div class="modal-body">
84+
<p>Are you sure you want to hide this quote?</p>
85+
</div>
86+
<div class="modal-footer">
87+
<!-- TODO: Probably should not be using form and buttons and rather be using input. -->
88+
<!-- <a class="btn btn-primary btn-sm" href="/report/{{quote.id}}" id="report::{{quote.id}}" type="button btn-danger">Yes</a> -->
89+
<form method="POST" action="/hide/{{quote.id}}" id="hide::{{quote.id}}" method="POST">
90+
<button type="submit" class="btn btn-danger">Yes</button>
91+
</form>
92+
<button type="button" class="btn btn-success" onclick="hideClose({{quote.id}})" id="hide_close_{{quote.id}}">No</button>
93+
</div>
94+
</div>
95+
</div>
96+
</div>
97+
{% endif %}
98+
</div>
99+
</div>
100+
{% endfor %}
101+
{%- endmacro %}
102+

quotefault/templates/bootstrap/storage.html

Lines changed: 2 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,11 @@
11
{% extends "bootstrap/base.html" %}
2+
{% from 'bootstrap/macro.html' import display_quotes as display with context %}
23

34
{% block styles %}
45
<link rel="stylesheet" href="/static/css/votes/upvote.css">
56
{% endblock %}
67

78
{% block body %}
8-
<script type="text/javascript">
9-
function report(id){
10-
// Get the modal
11-
var modal = document.getElementById(`report_${id}`);
12-
modal.style.display = "block";
13-
}
14-
function reportClose(id){
15-
// Get the modal
16-
var modal = document.getElementById(`report_${id}`);
17-
modal.style.display = "none";
18-
}
19-
function hide(id){
20-
// Get the modal
21-
var modal = document.getElementById(`hide_${id}`);
22-
modal.style.display = "block";
23-
}
24-
function hideClose(id){
25-
// Get the modal
26-
var modal = document.getElementById(`hide_${id}`);
27-
modal.style.display = "none";
28-
}
29-
</script>
309
<div class="container">
3110
<!-- flash relevant message when submit button is clicked -->
3211
{% with messages = get_flashed_messages(with_categories=true) %}
@@ -38,98 +17,7 @@
3817
{% endfor %}
3918
{% endif %}
4019
{% endwith %}
41-
42-
{% for quote, votes in quotes %}
43-
{% if loop.index0 == 0 and config['PLUG'] == True and metadata.plug != 'False' %}
44-
<div class="card my-3">
45-
<div class="card-body">
46-
<div class="plug-body">
47-
<a href="https://plug.csh.rit.edu" title="Advertisements by CSH: Plug">
48-
<img style="width: 100%" src="https://plug.csh.rit.edu/data"
49-
alt="Advertisements by CSH: Plug">
50-
</a>
51-
</div>
52-
</div>
53-
</div>
54-
{% endif %}
55-
56-
<div class="card m-3">
57-
58-
<div class="card-body">
59-
"{{ quote.quote }}" <b>- {{ get_display_name(quote.speaker) }}</b>
60-
<div id="votes-{{ quote.id }}" class="upvote upvote-meta-stackoverflow">
61-
<a class="upvote" id="upVote-{{ quote.id }}" onClick="makeVote({{ quote.id }}, 1)">
62-
</a>
63-
<span class="count">
64-
{% if votes %}
65-
{{ votes }}
66-
{% else %}
67-
0
68-
{% endif %}
69-
</span>
70-
<a class="downvote" id="downVote-{{ quote.id }}"
71-
onClick="makeVote({{ quote.id }}, -1)">
72-
</a>
73-
</div>
74-
</div>
75-
<div class="card-footer">
76-
Submitted by <a href="https://profiles.csh.rit.edu/user/{{ quote.submitter }}">{{ get_display_name(quote.submitter) }}</a> on {{ quote.quote_time.strftime('%Y-%m-%d %H:%M:%S') }}
77-
78-
<button type="button" class="btn btn-danger btn-sm float-right" onclick="report({{quote.id}})" id="report_button_{{quote.id}}">Report</button>
79-
<div class="modal" id="report_{{quote.id}}">
80-
<div class="modal-dialog" role="document">
81-
<div class="modal-content">
82-
<div class="modal-header">
83-
<h5 class="modal-title">Report Quote</h5>
84-
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
85-
aria-hidden="true">&times;</span>
86-
</button>
87-
</div>
88-
<div class="modal-body">
89-
<p>Are you sure you want to report this quote?</p>
90-
</div>
91-
<div class="modal-footer">
92-
<!-- TODO: Probably should not be using form and buttons and rather be using input. -->
93-
<!-- <a class="btn btn-primary btn-sm" href="/report/{{quote.id}}" id="report::{{quote.id}}" type="button btn-danger">Yes</a> -->
94-
<form method="POST" action="/report/{{quote.id}}" id="report::{{quote.id}}" method="POST">
95-
<button type="submit" class="btn btn-danger">Yes</button>
96-
</form>
97-
<button type="button" class="btn btn-success" onclck="reportClose({{quote.id}})" id="report_close_{{quote.id}}">No
98-
</button>
99-
</div>
100-
</div>
101-
</div>
102-
</div>
103-
{% if metadata['uid'] == quote.submitter or metadata['uid'] == quote.speaker or metadata['is_admin'] %}
104-
<button type="button" class="btn btn-warning btn-sm float-right" onclick="hide({{quote.id}})" id="hide_button_{{quote.id}}">Hide</button>
105-
<div class="modal" id="hide_{{quote.id}}">
106-
<div class="modal-dialog" role="document">
107-
<div class="modal-content">
108-
<div class="modal-header">
109-
<h5 class="modal-title">Hide Quote</h5>
110-
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
111-
aria-hidden="true">&times;</span>
112-
</button>
113-
</div>
114-
<div class="modal-body">
115-
<p>Are you sure you want to hide this quote?</p>
116-
</div>
117-
<div class="modal-footer">
118-
<!-- TODO: Probably should not be using form and buttons and rather be using input. -->
119-
<!-- <a class="btn btn-primary btn-sm" href="/report/{{quote.id}}" id="report::{{quote.id}}" type="button btn-danger">Yes</a> -->
120-
<form method="POST" action="/hide/{{quote.id}}" id="hide::{{quote.id}}" method="POST">
121-
<button type="submit" class="btn btn-danger">Yes</button>
122-
</form>
123-
<button type="button" class="btn btn-success" onclick="hideClose({{quote.id}})" id="hide_close_{{quote.id}}">No</button>
124-
</div>
125-
</div>
126-
</div>
127-
</div>
128-
{% endif %}
129-
130-
</div>
131-
</div>
132-
{% endfor %}
20+
{{ display( quotes ) }}
13321
<button href="#moreQuotes" id="get_more" data-toggle="collapse" class="btn btn-default center-block">But wait, there's more!</button>
13422
<br>
13523
<div id="moreQuotes" class="collapse" aria-expanded="false">

quotefault/templates/mail/report.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ <h3>There is a new report on QuoteFault</h3>
77
<p>Report submitted by: {{reporter}}</p>
88
<p>Quote being reported: {{quote.quote}} -{{quote.speaker}}</p>
99
<p>Quote submitted by: {{quote.submitter}}</p>
10-
<p>Please attend to this on the <a href="https://quotefault.csh.rit.edu/admin">QuoteFault Admin Page</a>!</p>
10+
<p>Please attend to this on the <a href="https://{{server}}/admin">QuoteFault Admin Page</a>!</p>
1111
</div>
1212
{% endblock %}
1313

quotefault/templates/mail/report.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ Hello EBoard/RTP
33
Report submitted by: {{reporter}}
44
Quote being reported: {{quote.quote}} -{{quote.speaker}}
55
Quote submitted by: {{quote.submitter}}
6-
Please attend to this on https://quotefault.csh.rit.edu/admin
6+
Please attend to this on https://{{server}}/admin
77

0 commit comments

Comments
 (0)