Spaces:
Running
Running
Commit
·
252fc68
1
Parent(s):
833b984
added default color option and fixed timezone warning while creating question
Browse files- db.sqlite3 +0 -0
- polls/migrations/0002_alter_question_pub_date.py +19 -0
- polls/models.py +1 -1
- polls/static/polls/create.js +16 -4
- polls/templates/polls/create.html +16 -1
db.sqlite3
CHANGED
|
Binary files a/db.sqlite3 and b/db.sqlite3 differ
|
|
|
polls/migrations/0002_alter_question_pub_date.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Generated by Django 4.2.4 on 2023-08-11 15:46
|
| 2 |
+
|
| 3 |
+
from django.db import migrations, models
|
| 4 |
+
import django.utils.timezone
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
class Migration(migrations.Migration):
|
| 8 |
+
|
| 9 |
+
dependencies = [
|
| 10 |
+
('polls', '0001_initial'),
|
| 11 |
+
]
|
| 12 |
+
|
| 13 |
+
operations = [
|
| 14 |
+
migrations.AlterField(
|
| 15 |
+
model_name='question',
|
| 16 |
+
name='pub_date',
|
| 17 |
+
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='date published'),
|
| 18 |
+
),
|
| 19 |
+
]
|
polls/models.py
CHANGED
|
@@ -22,7 +22,7 @@ class Question(models.Model):
|
|
| 22 |
|
| 23 |
author = models.ForeignKey(User,on_delete=models.CASCADE)
|
| 24 |
question_text = models.CharField(max_length=300)
|
| 25 |
-
pub_date = models.DateTimeField("date published",default=
|
| 26 |
theme_color = models.ForeignKey(ThemeColor,on_delete=models.SET_NULL,blank=True,null=True)
|
| 27 |
|
| 28 |
def __str__(self):
|
|
|
|
| 22 |
|
| 23 |
author = models.ForeignKey(User,on_delete=models.CASCADE)
|
| 24 |
question_text = models.CharField(max_length=300)
|
| 25 |
+
pub_date = models.DateTimeField("date published",default=timezone.now)
|
| 26 |
theme_color = models.ForeignKey(ThemeColor,on_delete=models.SET_NULL,blank=True,null=True)
|
| 27 |
|
| 28 |
def __str__(self):
|
polls/static/polls/create.js
CHANGED
|
@@ -182,8 +182,20 @@ function changetheme(elem){
|
|
| 182 |
// console.log(rgbtohex(elem.style.backgroundColor));
|
| 183 |
// console.log(rgbtohex(elem.style.color));
|
| 184 |
// question_container.style.color=rgbtohex(elem.style.color);
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
}
|
|
|
|
| 182 |
// console.log(rgbtohex(elem.style.backgroundColor));
|
| 183 |
// console.log(rgbtohex(elem.style.color));
|
| 184 |
// question_container.style.color=rgbtohex(elem.style.color);
|
| 185 |
+
if(elem.hasAttribute("data-id")){
|
| 186 |
+
|
| 187 |
+
var style=`
|
| 188 |
+
:root{
|
| 189 |
+
--primary-color:${elem.dataset.primary};
|
| 190 |
+
--secondary-color:${elem.dataset.secondary};
|
| 191 |
+
}
|
| 192 |
+
`;
|
| 193 |
+
custom_style.innerText=style;
|
| 194 |
+
theme=elem.dataset.id;
|
| 195 |
+
}
|
| 196 |
+
else{
|
| 197 |
+
theme=null;
|
| 198 |
+
custom_style.innerText='';
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
}
|
polls/templates/polls/create.html
CHANGED
|
@@ -3,6 +3,7 @@
|
|
| 3 |
{% block head %}
|
| 4 |
{% load static %}
|
| 5 |
<link type="text/css" rel="stylesheet" href="{% static 'polls/create.css' %}">
|
|
|
|
| 6 |
{% endblock %}
|
| 7 |
|
| 8 |
{% block body %}
|
|
@@ -13,14 +14,28 @@
|
|
| 13 |
<div class="themes_container">
|
| 14 |
Themes
|
| 15 |
<div class="themes">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
{% for theme in themes %}
|
| 17 |
<div class="theme"
|
| 18 |
|
| 19 |
data-id="{{ theme.pk }}"
|
|
|
|
|
|
|
| 20 |
|
| 21 |
style="
|
| 22 |
background-color: {{ theme.primary_color }};
|
| 23 |
-
color:
|
| 24 |
border: 10px solid {{ theme.secondary_color }};
|
| 25 |
"
|
| 26 |
onclick="changetheme(this);"
|
|
|
|
| 3 |
{% block head %}
|
| 4 |
{% load static %}
|
| 5 |
<link type="text/css" rel="stylesheet" href="{% static 'polls/create.css' %}">
|
| 6 |
+
<style id="custom_style"></style>
|
| 7 |
{% endblock %}
|
| 8 |
|
| 9 |
{% block body %}
|
|
|
|
| 14 |
<div class="themes_container">
|
| 15 |
Themes
|
| 16 |
<div class="themes">
|
| 17 |
+
<div class="theme"
|
| 18 |
+
|
| 19 |
+
style="
|
| 20 |
+
background-color: black;
|
| 21 |
+
color: white;
|
| 22 |
+
border: 10px solid black;
|
| 23 |
+
"
|
| 24 |
+
onclick="changetheme(this);"
|
| 25 |
+
|
| 26 |
+
>
|
| 27 |
+
<span>Default</span>
|
| 28 |
+
</div>
|
| 29 |
{% for theme in themes %}
|
| 30 |
<div class="theme"
|
| 31 |
|
| 32 |
data-id="{{ theme.pk }}"
|
| 33 |
+
data-primary="{{ theme.primary_color }}"
|
| 34 |
+
data-secondary="{{ theme.secondary_color }}"
|
| 35 |
|
| 36 |
style="
|
| 37 |
background-color: {{ theme.primary_color }};
|
| 38 |
+
color: white;
|
| 39 |
border: 10px solid {{ theme.secondary_color }};
|
| 40 |
"
|
| 41 |
onclick="changetheme(this);"
|