8000 Merge branch 'master' into release · pythonanywhere/pythondotorg@a892323 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a892323

Browse files
committed
Merge branch 'master' into release
2 parents c3b51e2 + fbc996d commit a892323

File tree

14 files changed

+99
-19
lines changed

14 files changed

+99
-19
lines changed

downloads/models.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,33 @@ def update_supernav():
121121
box.save()
122122

123123

124+
def update_homepage_download_box():
125+
try:
126+
latest_python2 = Release.objects.released().python2().latest()
127+
except Release.DoesNotExist:
128+
latest_python2 = None
129+
130+
try:
131+
latest_python3 = Release.objects.released().python3().latest()
132+
except Release.DoesNotExist:
133+
latest_python3 = None
134+
135+
content = render_to_string('downloads/homepage-downloads-box.html', {
136+
'latest_python2': latest_python2,
137+
'latest_python3': latest_python3,
138+
})
139+
140+
box = Box.objects.get(label='homepage-downloads')
141+
box.content = content
142+
box.save()
143+
144+
124145
@receiver(post_save, sender=Release)
125146
def update_download_supernav(sender, instance, signal, created, **kwargs):
126147
""" Update download supernav """
127148
if instance.is_published:
128149
update_supernav()
150+
update_homepage_download_box()
129151

130152

131153
class ReleaseFile(ContentManageable, NameSlugModel):
@@ -139,13 +161,15 @@ class ReleaseFile(ContentManageable, NameSlugModel):
139161
description = models.TextField(blank=True)
140162
is_source = models.BooleanField('Is Source Distribution', default=False)
141163
url = models.URLField('URL', unique=True, db_index=True, help_text="Download URL")
142-
gpg_signature_file = models.URLField('GPG SIG URL',
164+
gpg_signature_file = models.URLField(
165+
'GPG SIG URL',
143166
blank=True,
144167
help_text="GPG Signature URL"
145168
)
146169
md5_sum = models.CharField('MD5 Sum', max_length=200, blank=True)
147170
filesize = models.IntegerField(default=0)
148171
download_button = models.BooleanField(default=False, help_text="Use for the supernav download button for this OS")
172+
149173
class Meta:
150174
verbose_name = 'Release File'
151175
verbose_name_plural = 'Release Files'

downloads/tests/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def setUp(self):
1515
self.download_supernav_box.content.markup_type = 'html'
1616
self.download_supernav_box.save()
1717

18+
self.download_homepage_box = Box.objects.create(label='homepage-downloads')
19+
self.download_homepage_box.content.markup_type = 'html'
20+
self.download_homepage_box.save()
21+
1822
self.windows = OS.objects.create(name='Windows')
1923
self.osx = OS.objects.create(name='Mac OSX')
2024
self.linux = OS.objects.create(name='Linux')

fixtures/codesamples.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@
3333
"model": "codesamples.codesample",
3434
"fields": {
3535
"copy_markup_type": "html",
36-
"code": "<pre><code><span class=\"comment\"># List comprehensions</span>\r\n>>> fruits = ['Banana', 'Apple', 'Strawberry']\r\n>>> loud_fruits = [fruit.upper() for fruit in fruits]\r\n>>> print(loud_fruits)\r\n<span class=\"output\">['BANANA', 'APPLE', 'STRAWBERRY']</span>\r\n\r\n<span class=\"comment\"># List and the enumerate function</span>\r\n>>> list(enumerate(fruits))\r\n<span class=\"output\">[(0, 'Banana'), (1, 'Apple'), (2, 'Strawberry')]</span></code></pre>",
36+
"code": "<pre><code><span class=\"comment\"># List comprehensions</span>\r\n>>> fruits = ['Banana', 'Apple', 'Lime']\r\n>>> loud_fruits = [fruit.upper() for fruit in fruits]\r\n>>> print(loud_fruits)\r\n<span class=\"output\">['BANANA', 'APPLE', 'LIME']</span>\r\n\r\n<span class=\"comment\"># List and the enumerate function</span>\r\n>>> list(enumerate(fruits))\r\n<span class=\"output\">[(0, 'Banana'), (1, 'Apple'), (2, 'Lime')]</span></code></pre>",
3737
"_copy_rendered": "<h1>Compound Data Types</h1>\r\n <p>Lists (known as arrays in other languages) are one of the compound data types that Python understands. Lists can be indexed, sliced and manipulated with other built-in functions. <a href=\"http://docs.python.org/3.3/tutorial/introduction.html#lists\">More about lists</a></p>",
3838
"is_published": true,
3939
"copy": "<h1>Compound Data Types</h1>\r\n <p>Lists (known as arrays in other languages) are one of the compound data types that Python understands. Lists can be indexed, sliced and manipulated with other built-in functions. <a href=\"http://docs.python.org/3.3/tutorial/introduction.html#lists\">More about lists</a></p>",
4040
"updated": "2014-02-20T18:06:09.903Z",
4141
"created": "2014-02-20T18:06:09.903Z",
42-
"_code_rendered": "<pre><code><span class=\"comment\"># List comprehensions</span>\r\n>>> fruits = ['Banana', 'Apple', 'Strawberry']\r\n>>> loud_fruits = [fruit.upper() for fruit in fruits]\r\n>>> print(loud_fruits)\r\n<span class=\"output\">['BANANA', 'APPLE', 'STRAWBERRY']</span>\r\n\r\n<span class=\"comment\"># List and the enumerate function</span>\r\n>>> list(enumerate(fruits))\r\n<span class=\"output\">[(0, 'Banana'), (1, 'Apple'), (2, 'Strawberry')]</span></code></pre>",
42+
"_code_rendered": "<pre><code><span class=\"comment\"># List comprehensions</span>\r\n>>> fruits = ['Banana', 'Apple', 'Lime']\r\n>>> loud_fruits = [fruit.upper() for fruit in fruits]\r\n>>> print(loud_fruits)\r\n<span class=\"output\">['BANANA', 'APPLE', 'LIME']</span>\r\n\r\n<span class=\"comment\"># List and the enumerate function</span>\r\n>>> list(enumerate(fruits))\r\n<span class=\"output\">[(0, 'Banana'), (1, 'Apple'), (2, 'Lime')]</span></code></pre>",
4343
"code_markup_type": "html"
4444
},
4545
"pk": 3

jobs/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ def editable(self):
146146
return self.status in (self.STATUS_DRAFT, self.STATUS_REVIEW,
147147
self.STATUS_REJECTED)
148148

149+
def get_previous_listing(self):
150+
return self.get_previous_by_created(status=self.STATUS_APPROVED)
151+
152+
def get_next_listing(self):
153+
return self.get_next_by_created(status=self.STATUS_APPROVED)
154+
149155
comment_was_posted.connect(on_comment_was_posted)
150156
job_was_approved.connect(on_job_was_approved)
151157
job_was_rejected.connect(on_job_was_rejected)

jobs/tests/test_models.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ def setUp(self):
1313
country='USA',
1414
)
1515

16+
def create_job(self, **kwargs):
17+
job_kwargs = {
18+
'city': "Memphis",
19+
'region': "TN",
20+
"country": "USA",
21+
}
22+
job_kwargs.update(**kwargs)
23+
job = factories.JobFactory(**job_kwargs)
24+
25+
return job
26+
1627
def test_is_new(self):
1728
self.assertTrue(self.job.is_new)
1829

@@ -58,3 +69,21 @@ def test_review_manager(self):
5869
self.assertEqual(Job.objects.review().count(), 1)
5970
factories.ReviewJobFactory()
6071
self.assertEqual(Job.objects.review().count(), 2)
72+
73+
def test_get_previous_approved(self):
74+
job1 = self.create_job(status=Job.STATUS_APPROVED)
75+
job2 = self.create_job()
76+
job3 = self.create_job(status=Job.STATUS_APPROVED)
77+
78+
self.assertEqual(job1.get_next_listing(), job3)
79+
self.assertEqual(job3.get_previous_listing(), job1)
80+
81+
job2.status = Job.STATUS_APPROVED
82+
job2.save()
83+
84+
self.assertEqual(job1.get_next_listing(), job2)
85+
self.assertEqual(job2.get_next_listing(), job3)
86+
87+
self.assertEqual(job3.get_previous_listing(), job2)
88+
self.assertEqual(job2.get_previous_listing(), job1)
89+

pydotorg/settings/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
USE_L10N = True
3939
USE_TZ = True
4040

41+
DATE_FORMAT = 'Y-m-j'
42+
4143
### Files (media and static)
4244

4345
MEDIA_ROOT = os.path.join(BASE, 'media')

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
dj-database-url==0.2.1
22
django-braces==1.4.0
33
django-discover-runner==0.3
4-
# TODO: uncomment this when django-markup 0.5 is released
4+
# TODO: uncomment this when django-markup 0.5 is released
55
#django-markup==0.5
66
https://github.com/bartTC/django-markup/archive/ed661e20fc7042076977ee039f7bc1b7cb85b670.zip
77
django-pipeline==1.3.23
88
django-sitetree==0.9.4
99
django-secure==1.0
10-
Django==1.5.4
10+
Django==1.5.8
1111
docutils==0.11
1212
factory-boy==2.3.1
1313
Markdown==2.2.1
@@ -32,7 +32,7 @@ https://bitbucket.org/fcurella/django-timedelta-field/get/py3k.zip
3232

3333
South==0.8.4
3434

35-
git+https://github.com/bradjasper/django-jsonfield.git@c21b18
35+
git+https://github.com/bradjasper/django-jsonfield.git@b346fd7
3636
git+https://github.com/danirus/django-comments-xtd.git@182b54afc62e5d3967be75ac6ed8b19071764a6d
3737

3838
django-honeypot==0.4.0

static/sass/mq.css

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,10 +1862,9 @@ html[xmlns] .slides { display: block; }
18621862
float: left;
18631863
width: 33%; }
18641864
.jobs-form ul.errorlist {
1865-
/* Reset margin for errorlist so that messages are not drawn over other
1866-
labels */
1867-
margin-top: 0;
1868-
}
1865+
/* Reset margin for errorlist so that messages are not drawn over
1866+
other labels */
1867+
margin-top: 0; }
18691868

18701869
/* Footer */
18711870
.sitemap, .footer-links, .copyright {

static/sass/no-mq.css

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,10 +1573,9 @@ a.button {
15731573
float: left;
15741574
width: 33%; }
15751575
.jobs-form ul.errorlist {
1576-
/* Reset margin for errorlist so that messages are not drawn over other
1577-
labels */
1578-
margin-top: 0;
1579-
}
1576+
/* Reset margin for errorlist so that messages are not drawn over
1577+
other labels */
1578+
margin-top: 0; }
15801579

15811580
/* Footer */
15821581
.sitemap, .footer-links, .copyright {

templates/base.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,16 @@ <h1 class="site-headline">
201201
<li class="tier-1 last" aria-haspopup="true">
202202
{% if request.user.is_authenticated %}
203203
<a href="{% url 'account_logout' %}" title="Sign Out of Python.org">Sign Out</a>
204+
<ul class="subnav menu">
205+
<li class="tier-2 element-1" role="treeitem"><a href="{% url 'users:user_profile_edit' %}">Edit your user profile</a></li>
206+
<li class="tier-2 element-2" role="treeitem"><a href="{% url 'users:user_change_password' %}">Change your password</a></li>
207+
{% if request.user.has_membership %}
208+
<li class="tier-2 element-3" role="treeitem"><a href="{% url 'users:user_membership_edit' %}">Edit your PSF membership</a></li>
209+
{% else %}
210+
<li class="tier-2 element-3" role="treeitem"><a href="{% url 'users:user_membership_create' %}">Become a PSF member</a></li>
211+
{% endif %}
212+
<li class="tier-2 element-4" role="treeitem"><a href="{% url 'users:user_detail' slug=request.user.username %}">View your public profile</a></li>
213+
</ul>
204214
{% else %}
205215
<a href="{% url 'account_login' %}" title="Sign Up or Sign In to Python.org">Sign In</a>
206216
<ul class="subnav menu">

templates/blogs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ <h2 class="welcome-message">Welcome to the <span class="blog-name">Python Inside
1212

1313
<h1 class="call-to-action">{{ latest_entry.title }}</h1>
1414

15-
<p class="date-posted"><time datetime="{{ latest_entry.pub_date|date:"Y-m-d H:i|s" }}">{{ latest_entry.pub_date|date:"l, F j, Y" }}</time></p>
15+
<p class="date-posted"><time datetime="{{ latest_entry.pub_date|date:"Y-m-d H:i|s" }}">{{ latest_entry.pub_date }}</time></p>
1616
<p class="excerpt">{{ latest_entry.summary|striptags|truncatewords:50|safe }}
1717
<a class="readmore" href="{{ latest_entry.url }}">Read more</a></p>
1818
</div>
@@ -32,7 +32,7 @@ <h2 class="widget-title"><span aria-hidden="true" class="icon-news"></span>Lates
3232
{% for entry in entries %}
3333
<li>
3434
<h3 class="event-title"><a href="{{ entry.url }}">{{ entry.title }}</a></h3>
35-
<p><time datetime="{{ entry.pub_date|date:"Y-m-d" }}">{{ entry.pub_date|date:"m/d" }}<span class="say-no-more">/{{ entry.pub_date|date:"Y" }}</span></time></p>
35+
<p><time datetime="{{ entry.pub_date|date:"Y-m-d" }}">{{ entry.pub_date|date }}</time></p>
3636
</li>
3737
{% endfor %}
3838
</ul>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h2 class="widget-title"><span aria-hidden="true" class="icon-download"></span>Download</h2>
2+
<p>Python source code and installers are available for download for all versions! Not sure which version to use? <a href="https://wiki.python.org/moin/Python2orPython3">Check here</a>.</p>
3+
<p>Latest: <a href="{{ latest_python3.url }}">{{ latest_python3.release.name }}</a> - <a href="{{ latest_python2.url }}">{{ latest_python2.release.name }}</a></p>

templates/jobs/job_detail.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ <h2>Contact Info</h2>
138138

139139
<!-- Next or Previous Jobs by date posted -->
140140
<p class="previous-next">
141-
{% with object.get_previous_by_created as previous %}
141+
{% with object.get_previous_listing as previous %}
142142
{% if previous %}
143143
<a class="prev-button" href="{{ previous.get_absolute_url }}">
144144
<span class="prev-button-text"><span class="icon-arrow-left"><span>&larr;</span></span> Previous</span>
@@ -153,7 +153,7 @@ <h2>Contact Info</h2>
153153
{% endif %}
154154
{% endwith %}
155155

156-
{% with object.get_next_by_created as next %}
156+
{% with object.get_next_listing as next %}
157157
{% if next %}
158158
<a class="next-button" href="{{ next.get_absolute_url }}">
159159
<span class="next-button-text">Next <span class="icon-arrow-right"><span>&rarr;</span></span></span>

users/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from django.conf import settings
44
from django.core.mail import send_mail
55
from django.core.urlresolvers import reverse
6+
from django.http import Http404
67
from django.shortcuts import render, redirect
78
from django.utils.decorators import method_decorator
89
from django.views.generic import CreateView, DetailView, ListView, TemplateView, UpdateView
@@ -88,7 +89,10 @@ def dispatch(self, *args, **kwargs):
8889
return super().dispatch(*args, **kwargs)
8990

9091
def get_object(self):
91-
return self.request.user.membership.all()[0]
92+
try:
93+
return self.request.user.membership.all()[0]
94+
except IndexError:
95+
raise Http404()
9296

9397
def form_valid(self, form):
9498
self.object = form.save(commit=False)

0 commit comments

Comments
 (0)
0