Skip to content

Commit 3699245

Browse files
authored
Merge branch 'main' into subdomains-to-query-paths
2 parents fa4a8dd + ee0fcd3 commit 3699245

File tree

19 files changed

+832
-56
lines changed

19 files changed

+832
-56
lines changed

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ ENV GIT_SHA=$git_sha
2424
# Copy the source code in last to optimize rebuilding the image
2525
COPY . .
2626

27+
# Set dummy variables so collectstatic can load settings.py
28+
RUN \
29+
SECRET_KEY=dummy_value \
30+
DATABASE_URL=postgres://localhost \
31+
METRICITY_DB_URL=postgres://localhost \
32+
python manage.py collectstatic --noinput --clear
33+
2734
# Run web server through custom manager
2835
ENTRYPOINT ["python", "manage.py"]
2936
CMD ["run"]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This is all of the code that is responsible for maintaining [our website][9] and
1212
The website is built on Django and should be simple to set up and get started with.
1313
If you happen to run into issues with setup, please don't hesitate to open an issue!
1414

15-
If you're looking to contribute or play around with the code, take a look at [the wiki][10] or the [`docs` directory](docs). If you're looking for things to do, check out [our issues][11].
15+
If you're looking to contribute or play around with the code, take a look at [the wiki][10]. If you're looking for things to do, check out [our issues][11].
1616

1717
[1]: https://github.com/python-discord/site/workflows/Lint%20&%20Test/badge.svg?branch=main
1818
[2]: https://github.com/python-discord/site/actions?query=workflow%3A%22Lint+%26+Test%22+branch%3Amain

manage.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,17 @@ def prepare_server(self) -> None:
138138

139139
print("Applying migrations.")
140140
call_command("migrate", verbosity=self.verbosity)
141-
print("Collecting static files.")
142-
call_command("collectstatic", interactive=False, clear=True, verbosity=self.verbosity)
143141

144142
if self.debug:
143+
# In Production, collectstatic is ran in the Docker image
144+
print("Collecting static files.")
145+
call_command(
146+
"collectstatic",
147+
interactive=False,
148+
clear=True,
149+
verbosity=self.verbosity - 1
150+
)
151+
145152
self.set_dev_site_name()
146153
self.create_superuser()
147154

pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ The first time you run this command, it may take a few minutes while Docker down
9797
$ docker-compose up
9898
```
9999

100-
If you get any Docker related errors, reference the [Possible Issues](./docker/possible-issues) section of the Docker page.
100+
If you get any Docker related errors, reference the [Possible Issues](../docker#possible-issues) section of the Docker page.
101101
{: .notification .is-warning }
102102

103103
## Run on the host

pydis_site/apps/content/resources/guides/pydis-guides/contributing/sir-lancebot/env-var-reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Additionally, you may find the following environment variables useful during dev
3232
| `REDIS_PASSWORD` | |
3333
| `USE_FAKEREDIS` | If the FakeRedis module should be used. Set this to true if you don't have a Redis database setup. |
3434
| `BOT_SENTRY_DSN` | The DSN of the sentry monitor. |
35-
| `TRASHCAN_EMOJI` | The emoji to use for the trashcan during paginated embeds |
35+
| `TRASHCAN_EMOJI` | The full emoji to use for the trashcan. Format should be like the output of `\:emoji:`. |
3636

3737

3838
---

pydis_site/apps/home/views/home.py

Lines changed: 34 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class HomeView(View):
1919

2020
github_api = "https://api.github.com/users/python-discord/repos?per_page=100"
2121
repository_cache_ttl = 3600
22-
headers = {"Authorization": f"token {GITHUB_TOKEN}"}
2322

2423
# Which of our GitHub repos should be displayed on the front page, and in which order?
2524
repos = [
@@ -35,6 +34,16 @@ def __init__(self):
3534
"""Clean up stale RepositoryMetadata."""
3635
RepositoryMetadata.objects.exclude(repo_name__in=self.repos).delete()
3736

37+
# If no token is defined (for example in local development), then
38+
# it does not make sense to pass the Authorization header. More
39+
# specifically, GitHub will reject any requests from us due to the
40+
# invalid header. We can make a limited number of anonymous requests
41+
# though, which is useful for testing.
42+
if GITHUB_TOKEN:
43+
self.headers = {"Authorization": f"token {GITHUB_TOKEN}"}
44+
else:
45+
self.headers = {}
46+
3847
def _get_api_data(self) -> Dict[str, Dict[str, str]]:
3948
"""
4049
Call the GitHub API and get information about our repos.
@@ -74,58 +83,52 @@ def _get_api_data(self) -> Dict[str, Dict[str, str]]:
7483

7584
def _get_repo_data(self) -> List[RepositoryMetadata]:
7685
"""Build a list of RepositoryMetadata objects that we can use to populate the front page."""
77-
database_repositories = []
78-
79-
# First, let's see if we have any metadata cached.
80-
cached_data = RepositoryMetadata.objects.all()
86+
# First off, load the timestamp of the least recently updated entry.
87+
last_update = (
88+
RepositoryMetadata.objects.values_list("last_updated", flat=True)
89+
.order_by("last_updated").first()
90+
)
8191

82-
# If we don't, we have to create some!
83-
if not cached_data:
92+
# If we did not retrieve any results here, we should import them!
93+
if last_update is None:
8494

8595
# Try to get new data from the API. If it fails, we'll return an empty list.
8696
# In this case, we simply don't display our projects on the site.
8797
api_repositories = self._get_api_data()
8898

8999
# Create all the repodata records in the database.
90-
for api_data in api_repositories.values():
91-
repo_data = RepositoryMetadata(
100+
return RepositoryMetadata.objects.bulk_create(
101+
RepositoryMetadata(
92102
repo_name=api_data["full_name"],
93103
description=api_data["description"],
94104
forks=api_data["forks_count"],
95105
stargazers=api_data["stargazers_count"],
96106
language=api_data["language"],
97107
)
98-
99-
repo_data.save()
100-
database_repositories.append(repo_data)
101-
102-
return database_repositories
108+
for api_data in api_repositories.values()
109+
)
103110

104111
# If the data is stale, we should refresh it.
105-
if (timezone.now() - cached_data[0].last_updated).seconds > self.repository_cache_ttl:
112+
if (timezone.now() - last_update).seconds > self.repository_cache_ttl:
106113
# Try to get new data from the API. If it fails, return the cached data.
107114
api_repositories = self._get_api_data()
108115

109116
if not api_repositories:
110117
return RepositoryMetadata.objects.all()
111118

112119
# Update or create all RepoData objects in self.repos
113-
for repo_name, api_data in api_repositories.items():
114-
try:
115-
repo_data = RepositoryMetadata.objects.get(repo_name=repo_name)
116-
repo_data.description = api_data["description"]
117-
repo_data.language = api_data["language"]
118-
repo_data.forks = api_data["forks_count"]
119-
repo_data.stargazers = api_data["stargazers_count"]
120-
except RepositoryMetadata.DoesNotExist:
121-
repo_data = RepositoryMetadata(
122-
repo_name=api_data["full_name"],
123-
description=api_data["description"],
124-
forks=api_data["forks_count"],
125-
stargazers=api_data["stargazers_count"],
126-
language=api_data["language"],
127-
)
128-
repo_data.save()
120+
database_repositories = []
121+
for api_data in api_repositories.values():
122+
repo_data, _created = RepositoryMetadata.objects.update_or_create(
123+
repo_name=api_data["full_name"],
124+
defaults={
125+
'repo_name': api_data["full_name"],
126+
'description': api_data["description"],
127+
'forks': api_data["forks_count"],
128+
'stargazers': api_data["stargazers_count"],
129+
'language': api_data["language"],
130+
}
131+
)
129132
database_repositories.append(repo_data)
130133
return database_repositories
131134

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
description: A free, collaborative, in-browser IDE to code in 50+ languages —
22
without spending a second on setup.
3-
name: repl.it
4-
title_url: https://repl.it/
3+
name: replit
4+
title_url: https://replit.com/
55
position: 3

pydis_site/templates/events/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,6 @@ <h2 class="title is-4">PyWeek</h2>
121121
{% endblock %}
122122

123123
{% block sidebar %}
124-
{% include "events/sidebar/upcoming-event.html" %}
124+
{% include "events/sidebar/ongoing-event.html" %}
125125
{% include "events/sidebar/events-list.html" %}
126126
{% endblock %}

pydis_site/templates/events/pages/code-jams/8/_index.html

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212

1313
{% block event_content %}
1414
<p>Twice a year we host a code jam for members of our server to participate in. The code jam is an event where we place you
15-
in a team with 5 other random server members. You then have 7 days to code some sort of application or program in Python.
15+
in a team with 5 other random server members. You then have 8 days to code some sort of application or program in Python.
1616
Your program must use the specified technology/framework and incorporate the theme chosen by the server.
1717
</p>
1818
<p>
19-
After the 7 days is complete, your team has 2 days to finish documentation and create a video presentation showcasing
20-
and walking through the program that your team has created. More details and specifics of this will be released within the next 2 weeks.
19+
After the 8 days is complete, your team has 3 days to finish documentation and create a video presentation showcasing
20+
and walking through the program that your team has created.
2121
</p>
2222

2323
<h3 id="important-dates"><a href="#important-dates">Important Dates</a></h3>
@@ -26,10 +26,10 @@ <h3 id="important-dates"><a href="#important-dates">Important Dates</a></h3>
2626
<li>Monday, June 21 - <a href="https://github.com/python-discord/cj8-qualifier">The Qualifier</a> is released</li>
2727
<li>Friday, June 25 - Voting for the theme opens</li>
2828
<li>Saturday, June 26 @ 4PM UTC- <a class="has-text-link" href="{% url "events:page" path="code-jams/8/github-bootcamp" %}">GitHub Bootcamp</a></li>
29-
<li>Wednesday, June 30 - The Qualifier closes</li>
30-
<li>Friday, July 9 - Code Jam begins</li>
31-
<li>Friday, July 16 - Coding portion of the jam ends</li>
32-
<li>Sunday, July 18 - Code Jam submissions are closed</li>
29+
<li>Wednesday, July 1 - The Qualifier closes</li>
30+
<li>Friday, July 9 @ 5PM UTC - Code Jam begins and the theme is announced</li>
31+
<li>Saturday, July 17 @ 5PM UTC - Coding portion of the jam ends</li>
32+
<li>Tuesday, July 20 - Code Jam submissions are closed and video presentation must be submitted</li>
3333
</ul>
3434

3535
<h3 id="technology"><a href="#technology">Technology</a></h3>
@@ -52,11 +52,10 @@ <h3 if="qualifier"><a href="#qualifier">The Qualifier</a></h3>
5252
<li>The Qualifier must be submitted through the Code Jam sign-up form.</li>
5353
</ul>
5454
</p>
55-
<h3 id="how-to-join"><a href="#how-to-join">How to Join</a></h3>
55+
<h3 id="submissions"><a href="#submissions">Submissions</a></h3>
5656
<p>
57-
To enter into the code jam you must complete <a href="#qualifier">The Qualifier</a> and submit the sign-up form.
58-
Don't forget to join us on Discord at <a href="https://discord.gg/python">discord.gg/python</a>!
59-
<div class="has-text-centered"><a class="button is-link" href="https://form.jotform.com/211714357615050" target="_blank">Sign up for the Code Jam</a></div>
57+
63 teams started out on July 9th 2021. By the end of the jam, 51 teams made project submissions. Check them all out here:
58+
<div class="has-text-centered"><a class="button is-link" href="submissions">View Submissions</a></div>
6059
</p>
6160
<h3 id="prizes"><a href="#prizes">Prizes</a></h3>
6261
<p>

pydis_site/templates/events/pages/code-jams/8/frameworks.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ <h3 id="rich"><a href="#rich">Rich</a></h3>
7373
<li><strong>Supports:</strong> Linux, Mac, and Windows</li>
7474
<li>Documentation is good and overall is very OOP focused</li>
7575
<li>Robust with many features and example snippets</li>
76+
<li>To supplement Rich the following library is approved, although no guarantees are made for stability.</li>
77+
<ul>
78+
<li><a href="https://github.com/willmcgugan/textual" target="_blank">Textual</a> - a TUI framework using Rich as the render.
79+
<br>It is still under active development, is only available on Mac/Linux, and is not stable yet.</li>
80+
</ul>
7681
</ul>
7782
</div>
7883
<div class="column">

0 commit comments

Comments
 (0)