Skip to content

Commit c6243be

Browse files
author
Kátia Nakamura
committed
prepare the initial page with dynamic data
- add conference model to conference app - add count_down model to conference app - relocate speaker model to speaker app - dynamic home page
1 parent 59e8b0c commit c6243be

File tree

23 files changed

+239
-90
lines changed

23 files changed

+239
-90
lines changed

pyconbalkan/conference/admin.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
from django.contrib import admin
22

3-
from pyconbalkan.conference.models import Conference
3+
from pyconbalkan.conference.models import Conference, CountDown
44

55

66
class ConferenceAdmin(admin.ModelAdmin):
77
class Meta:
88
model = Conference
99

1010

11+
class CountDownAdmin(admin.ModelAdmin):
12+
class Meta:
13+
model = CountDown
14+
15+
1116
admin.site.register(Conference, ConferenceAdmin)
17+
admin.site.register(CountDown, CountDownAdmin)

pyconbalkan/conference/migrations/0001_initial.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
# Generated by Django 1.11.11 on 2018-04-25 18:12
2+
# Generated by Django 1.11.11 on 2018-04-26 21:51
33
from __future__ import unicode_literals
44

55
from django.db import migrations, models
@@ -18,7 +18,11 @@ class Migration(migrations.Migration):
1818
name='Conference',
1919
fields=[
2020
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
21+
('active', models.BooleanField(default=False)),
22+
('event', models.CharField(blank=True, max_length=100, null=True)),
23+
('name', models.CharField(blank=True, max_length=100, null=True)),
2124
('year', models.PositiveIntegerField()),
25+
('number', models.PositiveIntegerField()),
2226
('city', models.CharField(blank=True, max_length=200, null=True)),
2327
('country', django_countries.fields.CountryField(blank=True, max_length=2, null=True)),
2428
('address', models.TextField(blank=True, null=True)),
@@ -27,5 +31,20 @@ class Migration(migrations.Migration):
2731
('max_attendees', models.PositiveIntegerField(blank=True, null=True)),
2832
('type', models.IntegerField(choices=[(0, 'International'), (1, 'National')])),
2933
],
34+
options={
35+
'abstract': False,
36+
},
37+
),
38+
migrations.CreateModel(
39+
name='CountDown',
40+
fields=[
41+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
42+
('active', models.BooleanField(default=False)),
43+
('title', models.CharField(blank=True, max_length=100, null=True)),
44+
('count_down', models.DateTimeField(blank=True, null=True)),
45+
],
46+
options={
47+
'abstract': False,
48+
},
3049
),
3150
]

pyconbalkan/conference/models.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,37 @@
11
from django.db import models
22
from django_countries.fields import CountryField
33

4+
from pyconbalkan.core.models import SingleActiveModel
45

5-
class Conference(models.Model):
6+
7+
class Conference(SingleActiveModel):
68
INTERNATIONAL = 0
79
NATIONAL = 1
810
CONF_TYPE = (
911
(INTERNATIONAL, 'International'),
1012
(NATIONAL, 'National'),
1113
)
1214

15+
event = models.CharField(null=True, blank=True, max_length=100)
16+
name = models.CharField(null=True, blank=True, max_length=100)
1317
year = models.PositiveIntegerField()
18+
number = models.PositiveIntegerField()
1419
city = models.CharField(null=True, blank=True, max_length=200)
1520
country = CountryField(null=True, blank=True)
1621
address = models.TextField(null=True, blank=True)
1722
from_date = models.DateField(null=True, blank=True)
1823
to_date = models.DateField(null=True, blank=True)
1924
max_attendees = models.PositiveIntegerField(null=True, blank=True)
20-
type = models.IntegerField(choices=CONF_TYPE)
25+
type = models.IntegerField(choices=CONF_TYPE)
26+
27+
28+
def __str__(self):
29+
return '{} {} {}'.format(self.event, self.name, self.year)
30+
31+
32+
class CountDown(SingleActiveModel):
33+
title = models.CharField(null=True, blank=True, max_length=100)
34+
count_down = models.DateTimeField(null=True, blank=True)
35+
36+
def __str__(self):
37+
return self.title

pyconbalkan/conference/templates/index.html

Whitespace-only changes.

pyconbalkan/core/admin.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
from django.apps import AppConfig
2-
from django.contrib import admin
3-
4-
from pyconbalkan.core.models import Speaker, SpeakerPhoto
52

63

74
class CoreConfig(AppConfig):
85
name = 'core'
96

10-
11-
class SpeakerImageInline(admin.TabularInline):
12-
model = SpeakerPhoto
13-
14-
15-
class SpeakerAdmin(admin.ModelAdmin):
16-
inlines = [SpeakerImageInline]
17-
18-
19-
admin.site.register(Speaker, SpeakerAdmin)

pyconbalkan/core/models.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
from django.db import models
22

3-
# Create your models here.
43

4+
class SingleActiveModel(models.Model):
5+
active = models.BooleanField(default=False)
56

6-
class Speaker(models.Model):
7-
name = models.CharField(max_length=50)
8-
job = models.CharField(max_length=100)
7+
class Meta:
8+
abstract = True
99

10-
def __str__(self):
11-
return self.name
10+
def save(self, *args, **kwargs):
11+
if self.active:
12+
# select all other active items
13+
qs = type(self).objects.filter(active=True)
14+
# except self (if self already exists)
15+
if self.pk:
16+
qs = qs.exclude(pk=self.pk)
17+
# and deactive them
18+
qs.update(active=False)
1219

20+
super(SingleActiveModel, self).save(*args, **kwargs)
1321

14-
class SpeakerPhoto(models.Model):
15-
speaker = models.ForeignKey('Speaker', related_name='images')
16-
profile_picture = models.ImageField(upload_to="static/img")

pyconbalkan/core/static/css/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ ul.countdown li div {
185185
}
186186

187187
.moveDown {
188-
margin-top: 30px;
188+
margin-top: 50px;
189189
}
190190

191191
#btnBuyNow {
-195 KB
Binary file not shown.

pyconbalkan/core/static/js/timer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Set the date we're counting down to
2-
var countDownDate = new Date("Sep 8, 2018 10:00:00").getTime();
2+
var countDownDate = new Date("May 15, 2018 00:00:01").getTime();
33

44
// Update the count down every 1 second
55
var x = setInterval(function() {

pyconbalkan/core/templates/index.html renamed to pyconbalkan/core/templates/home.html

Lines changed: 94 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,37 @@
2121

2222
<!-- Timer JS -->
2323
<script src="{% static 'js/timer.js' %}" type="text/javascript"></script>
24+
<script src="{% static 'js/index.js' %}" type="text/javascript"></script>
2425

2526
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
2627
<!--[if lt IE 9]>
2728
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
2829
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
2930
<![endif]-->
31+
<link href="https://fonts.googleapis.com/css?family=Montserrat:400,700,900"
32+
rel="stylesheet">
33+
<style>
34+
body {
35+
font-family: Montserrat, sans-serif;
36+
}
37+
.blue {
38+
font-weight: 900;
39+
color: #53A8DC;
40+
}
41+
.yellow {
42+
font-weight: 900;
43+
color: #F9D768;
44+
}
45+
.black {
46+
font-size: 48px;
47+
font-weight: bold;
48+
}
49+
.white {
50+
color: #FFFFFF;
51+
font-size: 36px;
52+
font-weight: bold;
53+
}
54+
</style>
3055
</head>
3156

3257
<body>
@@ -65,28 +90,32 @@
6590

6691
<div class="col-xl-3 offset-1">
6792
<div>
68-
<h1 class="font900 one">PyCon</h1>
69-
<h2 class="one">Balkan</h2>
70-
<h3>Belgrade 2018</h3>
93+
{% if conference %}
94+
<h1 class="font900 one">{{ conference.event }}</h1>
95+
<h2 class="one">{{ conference.name }}</h2>
96+
<h3>{{ conference.city }} {{ conference.year }}</h3>
97+
{% endif %}
7198
</div>
7299
<hr>
73-
<div class="details">
74-
<h1 class="font900 font-yellow">#1</h1>
75-
<p>Hilton, Kralja Milana 35, 11000 Belgrade Serbia</p>
76-
<div>
77-
<p><i class="far fa-calendar-alt"></i> 8-12 September</p>
78-
<p><i class="fas fa-users"></i> Over 400 Attendees</p>
79-
<p><i class="fas fa-globe"></i> International Event</p>
80-
</div>
81-
<div>
100+
{% if conference %}
101+
<div class="details">
102+
<h1 class="font900 font-yellow">#{{ conference.number }}</h1>
103+
<p>{{ conference.address }}</p>
104+
<div>
105+
<p><i class="far fa-calendar-alt"></i> {{ conference.from_date }} - {{ conference.to_date }}</p>
106+
<p><i class="fas fa-users"></i> {{ conference.max_attendees }} attendees</p>
107+
<p><i class="fas fa-globe"></i> {{ conference.get_type_display }}</p>
108+
</div>
109+
{# <div>#}
82110
{# <a class="btn btn-primary btn-md round" href="#" role="button"><b>JOIN US</b></a>#}
83-
</div>
84-
<div>
111+
{# </div>#}
112+
{# <div>#}
85113
{# <i class="fa-lg fab fa-facebook-f sn-icons"></i>#}
86114
{# <i class="fa-lg fab fa-twitter sn-icons"></i>#}
87115
{# <i class="fa-lg fab fa-linkedin-in sn-icons"></i>#}
116+
{# </div>#}
88117
</div>
89-
</div>
118+
{% endif %}
90119
</div>
91120

92121
<!-- END of Left Side -->
@@ -95,54 +124,64 @@ <h1 class="font900 font-yellow">#1</h1>
95124
<!-- Main Content -->
96125

97126
<div class="col-xl-6 offset-1">
98-
<h1 class="font900 font-blue">Early bird tickets</h1>
99-
<div class="countdown-timer">
100-
<span id="days" class="font900 font-blue"></span>
101-
<span class="font-blue font900" id="days-text"> Days</span>
102-
<ul class="countdown">
103-
<li>
104-
<span id="hours" class="hms font-yellow"></span>
105-
<div class="hms-text">hours</div>
106-
</li>
107-
<li>
108-
<span id="minutes" class="hms font-yellow"></span>
109-
<div class="hms-text">minutes</div>
110-
</li>
111-
<li>
112-
<span id="seconds" class="hms font-yellow"></span>
113-
<div class="hms-text">sec</div>
114-
</li>
115-
</ul>
116-
</div>
117-
<div class="moveDown">
118-
{# <a class="btn btn-secondary btn-md round" href="#" role="button" id="btnBuyNow"><b>Buy Now</b></a>#}
119-
</div>
127+
{% if count_down %}
128+
<h1 class="font900 font-blue">{{ count_down.title }}</h1>
129+
<div class="countdown-timer">
130+
<span id="days" class="font900 font-blue"></span>
131+
<span class="font-blue font900" id="days-text"> Days</span>
132+
<ul class="countdown">
133+
<li>
134+
<span id="hours" class="hms font-yellow"></span>
135+
<div class="hms-text">hours</div>
136+
</li>
137+
<li>
138+
<span id="minutes" class="hms font-yellow"></span>
139+
<div class="hms-text">minutes</div>
140+
</li>
141+
<li>
142+
<span id="seconds" class="hms font-yellow"></span>
143+
<div class="hms-text">sec</div>
144+
</li>
145+
</ul>
146+
</div>
120147

121-
<div class="moveDown">
122-
{# <h1 class="font900 font-yellow">Speakers</h1>#}
123-
</div>
148+
{# <div class="moveDown">#}
149+
{# <a class="btn btn-secondary btn-md round" href="#" role="button" id="btnBuyNow"><b>Buy Now</b></a>#}
150+
{# </div>#}
151+
{% endif %}
152+
153+
<div class="moveDown">
154+
<h1 class="font900 font-yellow">Speakers</h1>
155+
</div>
124156

125-
<div class="card-deck moveDown">
126-
<div class="card">
127-
<div class="row">
128-
{% for speaker in speakerPhoto %}
129-
<div class="col-sm">
130-
<img src="{{ speaker.profile_picture }}">
131-
<ul class="card-body h-100 justify-content-center">
132-
<li><b>{{ speaker.speaker.name }}</b></li>
133-
<hr>
134-
<li>{{ speaker.speaker.job }}</li>
135-
</ul>
157+
{% if speakers %}
158+
<div class="card-deck moveDown">
159+
<div class="card">
160+
<div class="row">
161+
{% for speaker in speakers %}
162+
<div class="col-sm">
163+
<img src="{{ speaker.images.first.profile_picture }}">
164+
<ul class="card-body h-100 justify-content-center">
165+
<li><b>{{ speaker.name }}</b></li>
166+
<hr>
167+
<li>{{ speaker.job }}</li>
168+
</ul>
169+
</div>
170+
{% endfor %}
136171
</div>
137-
{% endfor %}
138172
</div>
139173
</div>
140-
</div>
174+
{% else %}
175+
<div class="white">
176+
<span class="blue">C</span>OMING <span class="yellow">S</span>OON
177+
</div>
178+
{% endif %}
179+
141180

142-
<div class="moveDown">
181+
{# <div class="moveDown">#}
143182
{# <a class="btn btn-secondary btn-md round" href="#" role="button" id="seeMore"><b>See More</b></a>#}
144183
{# <a class="btn btn-primary btn-md round" href="#" role="button" id="attend"><b>Attend</b></a>#}
145-
</div>
184+
{# </div>#}
146185
</div>
147186

148187

0 commit comments

Comments
 (0)