Skip to content

Commit f3f6e83

Browse files
committed
add new timezone example and update sidebar spacing
1 parent e6ffca2 commit f3f6e83

File tree

4 files changed

+123
-20
lines changed

4 files changed

+123
-20
lines changed

content/pages/examples/django/django-db-models-model.markdown

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,12 @@ ACCESS_CHOICES = (
137137
~~ can_change_advanced_settings = models.BooleanField(_("can change advanced settings"),
138138
default=False)
139139
~~ can_publish = models.BooleanField(_("can publish"), default=True)
140-
~~ can_change_permissions = models.BooleanField(_("can change permissions"), default=False, help_text=_("on page level"))
140+
~~ can_change_permissions = models.BooleanField(_("can change permissions"),
141+
default=False,
142+
help_text=_("on page level"))
141143
~~ can_move_page = models.BooleanField(_("can move"), default=True)
142-
~~ can_view = models.BooleanField(_("view restricted"), default=False, help_text=_("frontend view restriction"))
144+
~~ can_view = models.BooleanField(_("view restricted"), default=False,
145+
help_text=_("frontend view restriction"))
143146
~~
144147
~~ class Meta:
145148
~~ abstract = True
@@ -227,7 +230,8 @@ ACCESS_CHOICES = (
227230
permissions_by_action = {
228231
'add_page': ['can_add', 'can_change'],
229232
'change_page': ['can_change'],
230-
'change_page_advanced_settings': ['can_change', 'can_change_advanced_settings'],
233+
'change_page_advanced_settings': ['can_change',
234+
'can_change_advanced_settings'],
231235
'change_page_permissions': ['can_change', 'can_change_permissions'],
232236
'delete_page': ['can_change', 'can_delete'],
233237
'delete_page_translation': ['can_change', 'can_delete'],

content/pages/examples/django/django-utils-timezone.markdown

Lines changed: 99 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ meta: Python code examples for timezone-related classes and functions provided b
1010
# django.utils.timezone Examples
1111
[timezone.py](https://github.com/django/django/blob/master/django/utils/timezone.py)
1212
is a source file within the [Django](/django.html) project that contains
13-
timezone-related classes and functions that are helpful when building
14-
web applications.
13+
date and time-related helper classes and functions that are useful when
14+
building web applications.
15+
1516

1617
## Example 1 from django-cms
1718
[django-cms](https://github.com/divio/django-cms)
@@ -46,15 +47,107 @@ class PageQuerySet(PublisherQuerySet):
4647
~~ now = timezone.now()
4748
if language:
4849
~~ pub = self.on_site(site).filter(
49-
~~ Q(publication_date__lte=now) | Q(publication_date__isnull=True),
50-
~~ Q(publication_end_date__gt=now) | Q(publication_end_date__isnull=True),
50+
~~ Q(publication_date__lte=now) | \
51+
~~ Q(publication_date__isnull=True),
52+
~~ Q(publication_end_date__gt=now) | \
53+
~~ Q(publication_end_date__isnull=True),
5154
~~ title_set__published=True, title_set__language=language,
5255
)
5356
else:
5457
~~ pub = self.on_site(site).filter(
55-
~~ Q(publication_date__lte=now) | Q(publication_date__isnull=True),
56-
~~ Q(publication_end_date__gt=now) | Q(publication_end_date__isnull=True),
58+
~~ Q(publication_date__lte=now) | \
59+
~~ Q(publication_date__isnull=True),
60+
~~ Q(publication_end_date__gt=now) | \
61+
~~ Q(publication_end_date__isnull=True),
5762
~~ title_set__published=True,
5863
)
5964
return pub.exclude(title_set__publisher_state=4)
6065
```
66+
67+
68+
## Example 2 from django-smithy
69+
[django-smithy](https://github.com/jamiecounsell/django-smithy) is
70+
a [Django](/django.html) code library that allows users to send
71+
HTTP requests from the Django admin user interface. The code for
72+
the project is open source under the
73+
[MIT license](https://github.com/jamiecounsell/django-smithy/blob/master/LICENSE).
74+
75+
[**django-smithy/smithy/migrations/0001_initial.py**](https://github.com/jamiecounsell/django-smithy/blob/master/smithy/migrations/0001_initial.py)
76+
77+
```python
78+
# Generated by Django 2.1.5 on 2019-03-16 20:32
79+
80+
from django.db import migrations, models
81+
import django.db.models.deletion
82+
~~import django.utils.timezone
83+
import model_utils.fields
84+
85+
86+
class Migration(migrations.Migration):
87+
88+
initial = True
89+
90+
dependencies = [
91+
]
92+
93+
operations = [
94+
migrations.CreateModel(
95+
name='Cookie',
96+
fields=[
97+
('id', models.AutoField(auto_created=True,
98+
primary_key=True, serialize=False,
99+
verbose_name='ID')),
100+
~~ ('created', model_utils.fields.AutoCreatedField(\
101+
~~ default=django.utils.timezone.now, editable=False,
102+
~~ verbose_name='created')),
103+
~~ ('modified', model_utils.fields.AutoLastModifiedField(\
104+
~~ default=django.utils.timezone.now, editable=False,
105+
~~ verbose_name='modified')),
106+
('name', models.CharField(max_length=200)),
107+
('value', models.TextField()),
108+
],
109+
options={
110+
'abstract': False,
111+
},
112+
),
113+
migrations.CreateModel(
114+
name='Header',
115+
fields=[
116+
('id', models.AutoField(auto_created=True,
117+
primary_key=True,
118+
serialize=False,
119+
verbose_name='ID')),
120+
~~ ('created', model_utils.fields.AutoCreatedField(\
121+
~~ default=django.utils.timezone.now, editable=False,
122+
~~ verbose_name='created')),
123+
~~ ('modified', model_utils.fields.AutoLastModifiedField(\
124+
~~ default=django.utils.timezone.now, editable=False,
125+
~~ verbose_name='modified')),
126+
('name', models.CharField(max_length=200)),
127+
('value', models.TextField()),
128+
],
129+
options={
130+
'abstract': False,
131+
},
132+
),
133+
migrations.CreateModel(
134+
name='QueryParameter',
135+
fields=[
136+
('id', models.AutoField(auto_created=True,
137+
primary_key=True,
138+
serialize=False,
139+
verbose_name='ID')),
140+
~~ ('created', model_utils.fields.AutoCreatedField(\
141+
~~ default=django.utils.timezone.now, editable=False,
142+
~~ verbose_name='created')),
143+
~~ ('modified', model_utils.fields.AutoLastModifiedField(\
144+
~~ default=django.utils.timezone.now, editable=False,
145+
~~ verbose_name='modified')),
146+
('name', models.CharField(max_length=200)),
147+
('value', models.TextField()),
148+
],
149+
options={
150+
'abstract': False,
151+
},
152+
),
153+
```

theme/templates/desktop-toc.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ <h3><a href="/table-of-contents.html">Table of Contents</a></h3>
66
{% for p in pages|sort(attribute='sortorder') %}
77
{% if p %}
88
{% if p.toc == "True" %}<a href="/{{ p.slug }}.html" class="lgi {% if page and p.slug == page.slug %}active{% endif %}">{{ p.sidebartitle }}</a>
9-
{% elif p.sortorder[0:2] == page.sortorder[0:2] %}<a href="/{{ p.slug }}.html" class="lgi{% if p.slug == page.slug %} active{% endif %} {% if p.sortorder[0:2]|int > 9 and p.sortorder[2:4]|int > 1 %}sbc2{% else %}sbc{% endif %}">{{ p.sidebartitle }}</a>
9+
{% elif p.sortorder[0:2] == page.sortorder[0:2] %}<a href="/{{ p.slug }}.html" class="lgi{% if p.slug == page.slug %} active{% endif %} {% if not p.sortorder[0:2] == '50' %}{% if p.sortorder[0:2]|int > 9 and p.sortorder[2:4]|int > 1 %}sbc2{% else %}sbc{% endif %}{% endif %}">{{ p.sidebartitle }}</a>
1010
{% endif %}
1111
{% endif %}
1212
{% endfor %}

theme/templates/table-of-contents.html

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -213,25 +213,31 @@ <h2><a href="/blog.html">Blog Post Tutorials</a></h2>
213213
{% for a in articles %}<h4 class="bp"><a href="/blog/{{ a.slug }}.html">{{ a.title }}</a></h4>{% endfor %}
214214
</div>
215215
<div class="c3">
216-
<h2>Example Code</h2>
217-
<h3>Django examples</h3>
216+
<h2><a href="https://www.deploypython.com/">Books &amp; Videos</a></h2>
217+
<h4 class="bp"><a href="https://training.talkpython.fm/courses/explore_ansible/introduction-to-ansible-with-python">Introduction to Ansible</a></h4>
218+
<h4 class="bp"><a href="https://training.talkpython.fm/courses/explore_entrepreneurs/python-for-entrepreneurs-build-and-launch-your-online-business">Python for Entrepreneurs</a></h4>
219+
<h4 class="bp"><a href="https://www.deploypython.com/">Deploying Flask Web Apps</a></h4>
220+
</div>
221+
</div>
222+
223+
<h2>Example Python Code</h2>
224+
<div class="row">
225+
<div class="c6">
226+
<h3 style="margin-top:16px">Django examples</h3>
218227
<h4 class="bp"><a href="/django-conf-urls-url-examples.html">django.conf.urls.url</a></h4>
219228
<h4 class="bp"><a href="/django-contrib-admin-examples.html">django.contrib.admin</a></h4>
229+
<h4 class="bp"><a href="/django-core-mail-send-mail-examples.html">django.core.mail.send_mail</a></h4>
220230
<h4 class="bp"><a href="/django-core-mail-messages-emailmessage-examples.html">django.core.mail.messages.EmailMessage</a></h4>
221-
<h4 class="bp"><a href="/django-db-models-signal-examples.html">django.db.models.signal</a></h4>
222231
<h4 class="bp"><a href="/django-db-models-model-examples.html">django.db.models.Model</a></h4>
232+
<h4 class="bp"><a href="/django-db-models-signal-examples.html">django.db.models.signal</a></h4>
223233
<h4 class="bp"><a href="/django-dispatch-dispatcher-signal-examples.html">django.dispatch.dispatcher.Signal</a></h4>
224234
<h4 class="bp"><a href="/django-forms-examples.html">django.forms</a></h4>
225235
<h4 class="bp"><a href="/django-urls-path-examples.html">django.urls.path</a></h4>
226236
<h4 class="bp">django.utils</h4>
227237
<h4 class="bp"><a href="/django-utils-timezone-examples.html">django.utils.timezone</a></h4>
228-
229-
<br>
230-
231-
<h2><a href="https://www.deploypython.com/">Books &amp; Videos</a></h2>
232-
<h4 class="bp"><a href="https://training.talkpython.fm/courses/explore_ansible/introduction-to-ansible-with-python">Introduction to Ansible</a></h4>
233-
<h4 class="bp"><a href="https://training.talkpython.fm/courses/explore_entrepreneurs/python-for-entrepreneurs-build-and-launch-your-online-business">Python for Entrepreneurs</a></h4>
234-
<h4 class="bp"><a href="https://www.deploypython.com/">Deploying Flask Web Apps</a></h4>
238+
</div>
239+
<div class="c6">
240+
<!--<h3 style="margin-top:16px">Flask examples</h3>-->
235241
</div>
236242
</div>
237243
{% endblock %}

0 commit comments

Comments
 (0)