from django.http import HttpResponse
from .utils import queryset_to_workbook
def download_workbook(request):
queryset = User.objects.all()
columns = (
'first_name',
'last_name',
'email',
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
# coding: utf-8 | |
from weasyprint import HTML, CSS | |
def get_page_body(boxes): | |
for box in boxes: | |
if box.element_tag == 'body': | |
return box |
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
/* | |
How much money each staff has processed to date? | |
*/ | |
SELECT DISTINCT subquery.staff_id, subquery.staff, | |
SUM(subquery.payment_amount) OVER(PARTITION BY subquery.staff) AS total_amt_received | |
FROM ( | |
SELECT staff.staff_id staff_id, | |
CONCAT(staff.first_name, ' ', staff.last_name) AS staff, | |
payment.amount payment_amount, payment.payment_date payment_date |
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
/* | |
What are the top 10 film categories where most money have been received? | |
*/ | |
SELECT DISTINCT category.category_id, | |
category.name category, | |
COUNT(category) OVER(PARTITION BY category) AS rental_count, | |
ROUND(AVG(payment.amount) OVER(PARTITION BY category), 2) AS avg_amt_received, | |
SUM(payment.amount) OVER(PARTITION BY category) AS total_amt_received | |
FROM film |
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
/* | |
Who are the top 5 active customers who have spent most in renting films? | |
*/ | |
SELECT DISTINCT customer.customer_id, CONCAT(first_name, ' ', last_name) AS customer, | |
SUM(payment.amount) OVER(PARTITION BY customer) AS total_amt_spent | |
FROM customer | |
JOIN payment | |
ON customer.customer_id = payment.customer_id | |
WHERE customer.active = 1 |
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
/* | |
What are the top 10 most rented travel films in 2005 of over two hours duration? | |
*/ | |
SELECT DISTINCT subquery.film_id, subquery.title, | |
subquery.category, | |
COUNT(subquery.title) OVER(PARTITION BY subquery.title) AS rental_count | |
FROM ( | |
SELECT film.film_id film_id, film.title title, | |
category.name category, |
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
* { background-color: rgba(255,0,0,.2); } | |
* * { background-color: rgba(0,255,0,.2); } | |
* * * { background-color: rgba(0,0,255,.2); } | |
* * * * { background-color: rgba(255,0,255,.2); } | |
* * * * * { background-color: rgba(0,255,255,.2); } | |
* * * * * * { background-color: rgba(255,255,0,.2); } | |
* * * * * * * { background-color: rgba(255,0,0,.2); } | |
* * * * * * * * { background-color: rgba(0,255,0,.2); } | |
* * * * * * * * * { background-color: rgba(0,0,255,.2); } |
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
/* | |
##Device = Desktops | |
##Screen = 1281px to higher resolution desktops | |
*/ | |
@media (min-width: 1281px) { | |
//CSS | |
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
/* | |
* Programming Quiz: Build A Triangle (5-3) | |
*/ | |
// creates a line of * for a given length | |
function makeLine(length) { | |
var line = ""; | |
for (var j = 1; j <= length; j++) { | |
line += "* "; | |
} |
NewerOlder