Skip to content

Commit 4c49257

Browse files
committed
database file (sqlite) moved to ../ + git version + deploy.sh script + maintenance + clean
1 parent 6790a61 commit 4c49257

File tree

9 files changed

+79
-35
lines changed

9 files changed

+79
-35
lines changed

cdc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ todo long run
1111
- flake8 compliant (pep8 + other stuff)
1212

1313
to do now
14+
- log : for each page, log : ip, date, page ??
1415
- https://docs.djangoproject.com/en/dev/ref/contrib/sitemaps/
15-
- htaccess ? (index follow)
1616
- previsualisation des posts
1717
- news / tuto / articles : export pdf (pandoc)
1818
- syndication (rss + atom) : https://docs.djangoproject.com/en/dev/ref/contrib/syndication/

iTeam/context_processors.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
# @Author: Adrien Chardon
4+
# @Date: 2014-10-28 11:31:30
5+
# @Last Modified by: Adrien Chardon
6+
# @Last Modified time: 2014-10-28 11:36:55
7+
8+
# This file is part of iTeam.org.
9+
# Copyright (C) 2014 Adrien Chardon (Nodraak).
10+
#
11+
# iTeam.org is free software: you can redistribute it and/or modify
12+
# it under the terms of the GNU Affero General Public License as published by
13+
# the Free Software Foundation, either version 3 of the License, or
14+
# (at your option) any later version.
15+
#
16+
# iTeam.org is distributed in the hope that it will be useful,
17+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
# GNU Affero General Public License for more details.
20+
#
21+
# You should have received a copy of the GNU Affero General Public License
22+
# along with iTeam.org. If not, see <http://www.gnu.org/licenses/>.
23+
24+
25+
def git_version(request):
26+
"""
27+
Return the current deployed git version.
28+
29+
If not running on a production machine (if the 'git_version.txt' file is
30+
not found), this will just display that the running version is local.
31+
"""
32+
33+
try:
34+
with open('git_version.txt') as f:
35+
v = f.read().strip()
36+
except IOError:
37+
v = 'local_version'
38+
39+
return {'git_version': v}

iTeam/settings.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# @Author: Adrien Chardon
44
# @Date: 2014-09-02 12:01:06
55
# @Last Modified by: Adrien Chardon
6-
# @Last Modified time: 2014-10-27 13:02:07
6+
# @Last Modified time: 2014-10-28 11:33:49
77

88
# This file is part of iTeam.org.
99
# Copyright (C) 2014 Adrien Chardon (Nodraak).
@@ -150,7 +150,6 @@
150150
'django.contrib.staticfiles',
151151

152152
'email_obfuscator',
153-
# 'social.apps.django_app.default',
154153
)
155154

156155
MIDDLEWARE_CLASSES = (
@@ -177,24 +176,10 @@
177176
'django.core.context_processors.tz',
178177
'django.contrib.messages.context_processors.messages',
179178

180-
# 'social.apps.django_app.context_processors.backends',
181-
# 'social.apps.django_app.context_processors.login_redirect',
179+
# Custom context processors
180+
'iTeam.context_processors.git_version',
182181
)
183182

184-
"""
185-
AUTHENTICATION_BACKENDS = (
186-
'django.contrib.auth.backends.ModelBackend',
187-
188-
'social.backends.facebook.FacebookOAuth2',
189-
)
190-
"""
191-
192-
"""
193-
FILE_UPLOAD_HANDLERS = (
194-
"django.core.files.uploadhandler.MemoryFileUploadHandler",
195-
"django.core.files.uploadhandler.TemporaryFileUploadHandler",
196-
)
197-
"""
198183

199184
############################################
200185
# Database + Cache

prod/deploy.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ fi
1515
cd /opt/iteam-env/iteam-site/
1616

1717
# Maintenance mode
18-
#sudo rm /etc/nginx/sites-enabled/iteam
19-
#sudo ln -s /etc/nginx/sites-available/iteam-maintenance /etc/nginx/sites-enabled/iteam-maintenance
20-
#sudo service nginx reload
18+
sudo rm /etc/nginx/sites-enabled/iteam
19+
sudo ln -s /etc/nginx/sites-available/iteam-maintenance /etc/nginx/sites-enabled/iteam-maintenance
20+
sudo service nginx reload
2121

22-
# Delete old branch if exists
22+
# Retrieve prod branch
2323
git branch prod origin/prod
2424
git checkout prod
25+
# Delete old branch if exists
2526
git branch -D $1
26-
# Switch to new tag
27+
# Switch to new tag (Server has git < 1.9, git fetch --tags doesn't retrieve commits...)
2728
git fetch --tags
28-
# Server has git < 1.9, git fetch --tags doesn't retrieve commits...
2929
git fetch
3030
# Checkout the tag
3131
git checkout $1
@@ -39,17 +39,25 @@ python manage.py collectstatic --noinput
3939
# Update application data
4040
source ../bin/activate
4141
pip install --upgrade -r requirements.txt
42-
python manage.py migrate
42+
#python manage.py migrate
4343
deactivate
4444

4545
# Restart iteam
4646
sudo supervisorctl restart iteam
4747

4848
# Exit maintenance mode
49-
#sudo rm /etc/nginx/sites-enabled/iteam-maintenance
50-
#sudo ln -s /etc/nginx/sites-available/iteam /etc/nginx/sites-enabled/iteam
51-
#sudo service nginx reload
49+
sudo rm /etc/nginx/sites-enabled/iteam-maintenance
50+
sudo ln -s /etc/nginx/sites-available/iteam /etc/nginx/sites-enabled/iteam
51+
sudo service nginx reload
5252

5353
# Display current branch and commit
54-
git status
55-
echo "Commit deployé : `git rev-parse HEAD`"
54+
DEPLOYED_HASH=$(git show-ref --tags | grep v1.0-RC1.1 | cut -d " " -f 1)
55+
DEPLOYED_TAG=$(git show-ref --tags | grep v1.0-RC1.1 | cut -d " " -f 2 | cut -d "/" -f 3)
56+
HEAD_HASH=$(git rev-parse HEAD)
57+
58+
echo "$DEPLOYED_TAG" > git_version.txt
59+
60+
echo "Commit deployé :"
61+
echo "tag\t$DEPLOYED_TAG"
62+
echo "hash\t$DEPLOYED_HASH"
63+
echo "head\t$HEAD_HASH"

prod/nginx-maintenance.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ server {
1818
# media and static files
1919

2020
location /static/ {
21-
alias /opt/iteam-env/iteam_static/;
21+
alias /opt/iteam-env/static/;
2222
expires 1d;
2323
add_header Pragma public;
2424
add_header Cache-Control "public, must-revalidate, proxy-revalidate";

prod/settings_prod.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,9 @@
3737
('images', os.path.join(SITE_ROOT, 'assets', 'images')),
3838
)
3939

40+
DATABASES = {
41+
'default': {
42+
'ENGINE': 'django.db.backends.sqlite3',
43+
'NAME': os.path.join(SITE_ROOT, 'db.sqlite3'),
44+
}
45+
}

templates/base.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,17 @@
132132
<footer class="row">
133133
<div class="large-6 columns">
134134
<p>
135-
iTeam 2014 - <a href="https://github.com/Nodraak/iteam-site">Open source</a>
135+
iTeam 2014 - <a href="https://github.com/Nodraak/iteam-site">Open source ({{ git_version }})</a>
136136
</p>
137137
</div>
138138
<div class="large-6 columns hide-for-medium hide-for-large hide-for-xlarge hide-for-xxlarge">
139139
<ul class="inline-list left">
140-
{% include "footer.html" %}
140+
{% include "footer.part.html" %}
141141
</ul>
142142
</div>
143143
<div class="large-6 columns hide-for-small">
144144
<ul class="inline-list right">
145-
{% include "footer.html" %}
145+
{% include "footer.part.html" %}
146146
</ul>
147147
</div>
148148
</footer>

templates/pages/apropos.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ <h5>Javascript</h5>
107107
</ul>
108108
</div>
109109
</div>
110+
<div class="row">
111+
<h3>Droits</h3>
112+
<p>
113+
ITeam.org est un site donc le code source est sous licence <a href="https://github.com/Nodraak/iteam-site/blob/prod/LICENSE">GNU GPL Affero version 3</a>, et provient en partie de <a href="http://progdupeu.pl">progdupeu.pl</a> et <a href="http://zestedesavoir.com">zestedesavoir.com</a>.
114+
</p>
115+
</div>
110116
</div>
111117
</div>
112118
</div>

0 commit comments

Comments
 (0)