Skip to content
This repository was archived by the owner on Mar 7, 2022. It is now read-only.

Commit 73ef372

Browse files
committed
Merge branch 'release/11-August-2017'
2 parents 235d87b + c3dabc3 commit 73ef372

File tree

12 files changed

+262
-24
lines changed

12 files changed

+262
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# A git repository for PyCon Korea 2017
2-
## Version 08-August-2017
2+
## Version 11-August-2017
33

44
[![Build Status](https://travis-ci.org/pythonkr/pyconkr-2017.svg?branch=master)](https://travis-ci.org/pythonkr/pyconkr-2017)
55

pyconkr/context_processors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ def default(request):
5555
'submenu': OrderedDict([
5656
('map', {'title': _('Venue Map')}),
5757
('transportation', {'title': _('Transportation')}),
58-
('restaurants', {'title': _('Restaurants')}),
5958
]),
6059
}),
6160
('cfp', {

pyconkr/models.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from sorl.thumbnail import ImageField as SorlImageField
1111
from jsonfield import JSONField
1212
from uuid import uuid4
13-
13+
from constance import config
1414

1515
class Room(models.Model):
1616
name = models.CharField(max_length=100)
@@ -185,6 +185,22 @@ def room(self):
185185

186186
return ', '.join([_.name for _ in self.rooms.all()])
187187

188+
def get_slide_url_by_begin_time(self):
189+
from datetime import datetime
190+
191+
if not config.SHOW_SLIDE_DATA:
192+
return None
193+
194+
time = self.times.first()
195+
196+
if not time:
197+
return None
198+
199+
if datetime.now().date() >= time.day.day and datetime.now().time() >= time.begin:
200+
return self.slide_url
201+
else:
202+
return None
203+
188204
def begin_time(self):
189205
return self.times.all()[0].begin.strftime("%H:%M")
190206

pyconkr/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,4 +238,5 @@ def static_url(url):
238238
'IMP_USER_CODE': ('', 'iamport user code'),
239239
'IMP_API_KEY': ('', 'iamport api key'),
240240
'IMP_API_SECRET': ('', 'iamport api secret'),
241+
'SHOW_SLIDE_DATA': (False, 'Show slide data on schedule table and program detail'),
241242
}
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
(function ($) {
2+
var Quickfit, QuickfitHelper, defaults, pluginName;
3+
4+
pluginName = 'quickfit';
5+
6+
defaults = {
7+
min: 8,
8+
max: 12,
9+
tolerance: 0.02,
10+
truncate: false,
11+
width: null,
12+
sampleNumberOfLetters: 10,
13+
sampleFontSize: 12
14+
};
15+
QuickfitHelper = (function () {
16+
17+
var sharedInstance = null;
18+
19+
QuickfitHelper.instance = function (options) {
20+
if (!sharedInstance) {
21+
sharedInstance = new QuickfitHelper(options);
22+
}
23+
return sharedInstance;
24+
};
25+
26+
function QuickfitHelper(options) {
27+
this.options = options;
28+
29+
this.item = $('<span id="meassure"></span>');
30+
this.item.css({
31+
position: 'absolute',
32+
left: '-1000px',
33+
top: '-1000px',
34+
'font-size': "" + this.options.sampleFontSize + "px"
35+
});
36+
$('body').append(this.item);
37+
38+
this.meassures = {};
39+
}
40+
41+
QuickfitHelper.prototype.getMeassure = function (letter) {
42+
var currentMeassure;
43+
currentMeassure = this.meassures[letter];
44+
if (!currentMeassure) {
45+
currentMeassure = this.setMeassure(letter);
46+
}
47+
return currentMeassure;
48+
};
49+
50+
QuickfitHelper.prototype.setMeassure = function (letter) {
51+
var currentMeassure, index, sampleLetter, text, _ref;
52+
53+
text = '';
54+
sampleLetter = letter === ' ' ? '&nbsp;' : letter;
55+
56+
for (index = 0, _ref = this.options.sampleNumberOfLetters - 1; 0 <= _ref ? index <= _ref : index >= _ref; 0 <= _ref ? index++ : index--) {
57+
text += sampleLetter;
58+
}
59+
60+
this.item.html(text);
61+
currentMeassure = this.item.width() / this.options.sampleNumberOfLetters / this.options.sampleFontSize;
62+
this.meassures[letter] = currentMeassure;
63+
64+
return currentMeassure;
65+
};
66+
67+
return QuickfitHelper;
68+
69+
})();
70+
71+
Quickfit = (function () {
72+
73+
function Quickfit(element, options) {
74+
this.$element = element;
75+
this.options = $.extend({}, defaults, options);
76+
this.$element = $(this.$element);
77+
this._defaults = defaults;
78+
this._name = pluginName;
79+
this.quickfitHelper = QuickfitHelper.instance(this.options);
80+
}
81+
82+
Quickfit.prototype.fit = function () {
83+
var elementWidth;
84+
if (!this.options.width) {
85+
elementWidth = this.$element.width();
86+
this.options.width = elementWidth - this.options.tolerance * elementWidth;
87+
}
88+
if (this.text = this.$element.attr('data-quickfit')) {
89+
this.previouslyTruncated = true;
90+
} else {
91+
this.text = this.$element.text();
92+
}
93+
this.calculateFontSize();
94+
95+
if (this.options.truncate) this.truncate();
96+
97+
return {
98+
$element: this.$element,
99+
size: this.fontSize
100+
};
101+
};
102+
103+
Quickfit.prototype.calculateFontSize = function () {
104+
var letter, textWidth, i;
105+
106+
textWidth = 0;
107+
for (i = 0; i < this.text.length; ++i) {
108+
letter = this.text.charAt(i);
109+
textWidth += this.quickfitHelper.getMeassure(letter);
110+
}
111+
112+
this.targetFontSize = parseInt(this.options.width / textWidth);
113+
return this.fontSize = Math.max(this.options.min, Math.min(this.options.max, this.targetFontSize));
114+
};
115+
116+
Quickfit.prototype.truncate = function () {
117+
var index, lastLetter, letter, textToAdd, textWidth;
118+
119+
if (this.fontSize > this.targetFontSize) {
120+
textToAdd = '';
121+
textWidth = 3 * this.quickfitHelper.getMeassure('.') * this.fontSize;
122+
123+
index = 0;
124+
while (textWidth < this.options.width && index < this.text.length) {
125+
letter = this.text[index++];
126+
if (lastLetter) textToAdd += lastLetter;
127+
textWidth += this.fontSize * this.quickfitHelper.getMeassure(letter);
128+
lastLetter = letter;
129+
}
130+
131+
if (textToAdd.length + 1 === this.text.length) {
132+
textToAdd = this.text;
133+
} else {
134+
textToAdd += '...';
135+
}
136+
this.textWasTruncated = true;
137+
138+
return this.$element.attr('data-quickfit', this.text).html(textToAdd);
139+
140+
} else {
141+
if (this.previouslyTruncated) {
142+
return this.$element.html(this.text);
143+
}
144+
}
145+
};
146+
147+
return Quickfit;
148+
149+
})();
150+
151+
return $.fn.quickfit = function (options) {
152+
var measurements = [];
153+
154+
// Separate measurements from repaints
155+
// First calculate all measurements...
156+
var $elements = this.each(function () {
157+
var measurement = new Quickfit(this, options).fit();
158+
measurements.push(measurement);
159+
return measurement.$element;
160+
});
161+
162+
// ... then apply the measurements.
163+
for (var i = 0; i < measurements.length; i++) {
164+
var measurement = measurements[i];
165+
166+
measurement.$element.css({ fontSize: measurement.size + 'px' });
167+
}
168+
169+
return $elements;
170+
};
171+
172+
})(jQuery, window);

pyconkr/templates/pyconkr/profile_detail.html

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ <h3>
2121
<a href="{% url 'profile_edit' %}"><i class="fa fa-pencil-square-o"></i></a>
2222
</h3>
2323

24-
<h4>{{ profile.organization }}</h4>
25-
<p>{{ profile.phone }}</p>
24+
{% if profile.organization %}
25+
<h4>{{ profile.organization }}</h4>
26+
{% endif %}
27+
{% if profile.phone %}
28+
<p>{{ profile.phone }}</p>
29+
{% endif %}
2630
<div>{{ profile.bio|safe }}</div>
2731
</div>
2832
</div>

pyconkr/templates/pyconkr/program_detail.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
{% endif %}
5858
</li>
5959
</ul>
60-
{% if program.slide_url %}
60+
{% if program.get_slide_url_by_begin_time %}
6161
<h3>{% trans "Slide" %}</h3>
62-
{{ program.slide_url|urlize }}
62+
{{ program.get_slide_url_by_begin_time|urlize }}
6363
{% endif %}
6464
{% if program.video_url %}
6565
<h3>{% trans "Video" %}</h3>

pyconkr/templates/pyconkr/program_list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ <h3 id="{{ obj.slug }}">
1616
{% for program in obj.program_set.all %}
1717
<li>
1818
<a href="{{ program.get_absolute_url }}">{{ program.name }}</a>
19-
{% if program.slide_url %}
20-
<small><a href="{{ program.slide_url }}"><span class="label label-primary">{% trans "Slides link" %}</span></a></small>
19+
{% if program.get_slide_url_by_begin_time %}
20+
<small><a href="{{ program.get_slide_url_by_begin_time }}"><span class="label label-primary">{% trans "Slides link" %}</span></a></small>
2121
{% endif %}
2222
{% if program.video_url %}
2323
<small><a href="{{ program.video_url }}"><span class="label label-info">{% trans "Video link" %}</span></a></small>

pyconkr/templates/schedule.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ <h2>{{ d }}</h2>
2727
&nbsp;<span class="glyphicon glyphicon-eye-close"></span>
2828
{% endif %}
2929
</a>
30-
{% if s.slide_url %}
31-
<small><a href="{{ s.slide_url }}"><span class="label label-slides">{% trans "Slides link" %}</span></a></small>
30+
{% if s.get_slide_url_by_begin_time %}
31+
<small><a href="{{ s.get_slide_url_by_begin_time }}"><span class="label label-slides">{% trans "Slides link" %}</span></a></small>
3232
{% endif %}
3333
{% if s.video_url %}
3434
<small><a href="{{ s.video_url }}"><span class="label label-vidieo">{% trans "Video link" %}</span></a></small>
@@ -64,8 +64,8 @@ <h2>{{ d }}</h2>
6464
&nbsp;<span class="glyphicon glyphicon-eye-close"></span>
6565
{% endif %}
6666
</a>
67-
{% if s.slide_url %}
68-
<small><a href="{{ s.slide_url }}"><span class="label label-slides">{% trans "Slides link" %}</span></a></small>
67+
{% if s.get_slide_url_by_begin_time %}
68+
<small><a href="{{ s.get_slide_url_by_begin_time }}"><span class="label label-slides">{% trans "Slides link" %}</span></a></small>
6969
{% endif %}
7070
{% if s.video_url %}
7171
<small><a href="{{ s.video_url }}"><span class="label label-vidieo">{% trans "Video link" %}</span></a></small>
@@ -130,8 +130,8 @@ <h2>{{ d }}</h2>
130130
{% endif %}
131131
</div>
132132
</a>
133-
{% if s.slide_url %}
134-
<small><a href="{{ s.slide_url }}"><span class="label label-slides">{% trans "Slides link" %}</span></a></small>
133+
{% if s.get_slide_url_by_begin_time %}
134+
<small><a href="{{ s.get_slide_url_by_begin_time }}"><span class="label label-slides">{% trans "Slides link" %}</span></a></small>
135135
{% endif %}
136136
{% if s.video_url %}
137137
<small><a href="{{ s.video_url }}"><span class="label label-video">{% trans "Video link" %}</span></a></small>

pyconkr/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
SprintProposal, EmailToken, Profile, Proposal, TutorialCheckin,
2323
SprintCheckin)
2424
from registration.models import Registration, Option
25+
from constance import config
2526

2627
logger = logging.getLogger(__name__)
2728
payment_logger = logging.getLogger('payment')
@@ -53,6 +54,7 @@ def schedule(request):
5354
narrow[d][t] = []
5455
for r in rooms:
5556
s = Program.objects.filter(date=d, times=t, rooms=r)
57+
5658
if s:
5759
if s[0].times.all()[0] == t and s[0].id not in processed:
5860
wide[d][t][r] = s[0]
@@ -136,7 +138,6 @@ class ProgramDetail(DetailView):
136138

137139
def get_context_data(self, **kwargs):
138140
context = super(ProgramDetail, self).get_context_data(**kwargs)
139-
140141
if self.request.user.is_authenticated():
141142
for speaker in self.object.speakers.all():
142143
if self.request.user.email == speaker.email:

0 commit comments

Comments
 (0)