feedback fixes

Makefile added
fabfile.py added
remotes/origin/stage3_release
Alexander Burdeiny 10 years ago
parent bae3ca28fa
commit af66e4959f
  1. 71
      Makefile
  2. 2
      expobanner/admin.py
  3. 118
      fabfile.py
  4. 13
      stats_collector/admin.py
  5. 4
      stats_collector/forms.py
  6. 2
      templates/admin/stats/event_stat.html
  7. 6
      templates/client/includes/side_places.html

@ -0,0 +1,71 @@
.PHONY: requirements requirements-upgrade freeze syncdb run run-public makemessages compilemessages collectstatic cloc clean user south
project_name=proj
requirements:
-@echo "### Installing requirements"
-@pip install -r requirements.txt
requirements-upgrade:
-@echo "### Upgrading requirements"
-@pip freeze | cut -d = -f 1 | xargs pip install -U
freeze:
-@echo "### Freezing python packages to requirements.txt"
-@pip freeze > requirements.txt
syncdb:
-@echo "### Creating database tables and loading fixtures"
@PYTHONPATH=$(PYTHONPATH):. DJANGO_SETTINGS_MODULE=$(project_name).settings ipython manage.py syncdb --noinput
@PYTHONPATH=$(PYTHONPATH):. DJANGO_SETTINGS_MODULE=$(project_name).settings ipython manage.py migrate
run:
@PYTHONPATH=$(PYTHONPATH):. DJANGO_SETTINGS_MODULE=$(project_name).settings ipython manage.py runserver
run-public:
@PYTHONPATH=$(PYTHONPATH):. DJANGO_SETTINGS_MODULE=$(project_name).settings ipython manage.py runserver 0.0.0.0:8000
shell:
@PYTHONPATH=$(PYTHONPATH):. DJANGO_SETTINGS_MODULE=$(project_name).settings python manage.py shell
solrrun:
/opt/solr/bin/solr start -p 8983
solrstop:
/opt/solr/bin/solr stop -all
makemessages:
-@ipython manage.py makemessages --all
compilemessages:
-@ipython manage.py compilemessages
collectstatic:
@ipython manage.py collectstatic
user:
-@ipython manage.py createsuperuser
# If the first argument is "south"...
ifeq (south,$(firstword $(MAKECMDGOALS)))
# use the rest as arguments for "south"
RUN_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# ...and turn them into do-nothing targets
$(eval $(RUN_ARGS):;@:)
endif
south:
-@python manage.py schemamigration $(RUN_ARGS) --auto
-@python manage.py migrate $(RUN_ARGS)
cloc:
-@echo "### Counting lines of code within the project"
-@echo "# Total:" ; find . -iregex '.*\.py\|.*\.js\|.*\.html\|.*\.css' -type f -exec cat {} + | wc -l
-@echo "# Python:" ; find . -name '*.py' -type f -exec cat {} + | wc -l
-@echo "# JavaScript:" ; find . -name '*.js' -type f -exec cat {} + | wc -l
-@echo "# HTML:" ; find . -name '*.html' -type f -exec cat {} + | wc -l
-@echo "# CSS:" ; find . -name '*.css' -type f -exec cat {} + | wc -l
clean:
-@echo "### Cleaning *.pyc and .DS_Store files "
-@find . -name '*.pyc' -exec rm -f {} \;
-@find . -name '.DS_Store' -exec rm -f {} \;

@ -272,7 +272,7 @@ class PaidCreate(CreateView):
class PaidConfCreate(PaidCreate): class PaidConfCreate(PaidCreate):
form_class = PaidConfCreateForm form_class = PaidConfCreateForm
success_url = '/admin/expobanners/paid/list/' success_url = '/admin/expobanners/paid_conf/list/'
class PaidUpdate(UpdateView): class PaidUpdate(UpdateView):

118
fabfile.py vendored

@ -0,0 +1,118 @@
# -*- coding: utf-8 -*-
from os.path import join, basename
from collections import namedtuple
from fabric.api import *
env.roledefs = {
'dev': ['root@176.121.11.165'],
'prod': ['root@176.121.11.162'],
}
env.passwords = {
'root@176.121.11.165:22': 'ue6R287QZfMc',
'root@176.121.11.162:22': 'XcS2jx5e8k6n',
}
REMOTE_HOME_DIR = '/home/www/expomap/'
LOCAL_HOME_DIR = '/home/alexander/projects/expomap/'
nginx_conf = '/etc/nginx/sites-available/hit.expomap.ru'
apache2_conf = '/etc/apache2/sites-available/proj.com'
settings_conf = join(REMOTE_HOME_DIR, 'proj/settings.py')
services = ['nginx', 'apache2']
def set_host(host):
env.hosts = env.roledefs.get(host)
env.role = host
def dev():
set_host('dev')
def prod():
set_host('prod')
def get_configs():
localdir = join(LOCAL_HOME_DIR, 'support/', env.role)
get(nginx_conf, localdir)
get(apache2_conf, localdir)
get(join(REMOTE_HOME_DIR, 'schema.xml'), localdir)
get(settings_conf, localdir)
def put_configs():
localdir = join(LOCAL_HOME_DIR, 'support/', env.role)
# nginx
put(join(localdir, basename(nginx_conf)),
nginx_conf)
# apache2
put(join(localdir, basename(apache2_conf)),
apache2_conf)
# settings
put(join(localdir, basename(settings_conf)),
settings_conf)
def call_state(state, only=None):
if only is not None and only in services:
run('service {only} {state}'.format(only=only, state=state))
return
for service in services:
run('service {service} {state}'.format(service=service, state=state))
def put_1345():
call_state('stop', only='nginx')
with cd(REMOTE_HOME_DIR):
run('git pull')
# put_configs()
call_state('start', only='nginx')
def chown():
with cd(REMOTE_HOME_DIR):
run('chown -Rv www-data:www-data .')
def pull():
with cd(REMOTE_HOME_DIR):
call_state('stop', only='apache2')
run('git pull')
call_state('start', only='apache2')
def stage3_pre_final():
with cd(REMOTE_HOME_DIR):
run('pip install pandas')
run('pip install django-rosetta==0.7.6')
run('git checkout master')
run('git pull')
call_state('stop')
put_configs()
run('python manage.py migrate conference 0001 --fake')
run('python manage.py migrate conference')
run('python manage.py migrate expobanner')
run('python manage.py migrate theme 0001 --fake')
run('python manage.py migrate theme 0002')
run('python manage.py migrate article 0001 --fake')
run('python manage.py migrate article 0002')
run('python manage.py migrate stats_collector')
run('python manage.py crontab remove')
run('python manage.py crontab add')
chown()
call_state('start')
def stage3_release():
call_state('stop')
with cd(REMOTE_HOME_DIR):
# run('python manage.py themeblog_to_blog')
run('git checkout stage3_release')
run('git pull')
run('python manage.py migrate settings 0002 --fake')
run('python manage.py migrate settings')
run('python manage.py migrate article 0003')
chown()
call_state('start')

@ -67,10 +67,15 @@ class StatBaseView(FormView):
return super(StatBaseView, self).get(request, *args, **kwargs) return super(StatBaseView, self).get(request, *args, **kwargs)
def form_valid(self, form): def form_valid(self, form):
if form.cleaned_data['date_begin']: begin = form.cleaned_data['date_begin']
self.qs = self.qs.filter(created_at__gte=form.cleaned_data['date_begin']) end = form.cleaned_data['date_end']
if form.cleaned_data['date_end']: if (begin and end) and begin == end:
self.qs = self.qs.filter(created_at__lte=form.cleaned_data['date_end']) self.qs = self.qs.filter(created_at=begin)
else:
if begin:
self.qs = self.qs.filter(created_at__gte=begin)
if end:
self.qs = self.qs.filter(created_at__lte=end)
def make_json_response(self, data): def make_json_response(self, data):
return HttpResponse(json.dumps(data), content_type='application/json') return HttpResponse(json.dumps(data), content_type='application/json')

@ -31,9 +31,9 @@ class BaseDateFilter(forms.Form):
date_end = self.cleaned_data['date_end'] date_end = self.cleaned_data['date_end']
if not date_begin and date_end: if not date_begin and date_end:
self.cleaned_data['date_begin'] = date_end - timedelta(days=14) self.cleaned_data['date_begin'] = date_end - timedelta(days=14)
elif date_begin and date_end and date_begin >= date_end: elif date_begin and date_end and date_begin > date_end:
raise forms.ValidationError( raise forms.ValidationError(
_(u'Дата начала должна быть меньше даты окончания.'), _(u'Дата начала должна быть меньше либо соответствовать дате окончания.'),
code='invalid') code='invalid')
return self.cleaned_data return self.cleaned_data

@ -23,7 +23,7 @@
{% endautoescape %} {% endautoescape %}
]); ]);
var options = { var options = {
title: '{% trans "Статистика разделов" %}', title: '{% trans "Статистика событий" %}',
legend: { position: 'bottom' }, legend: { position: 'bottom' },
vAxis: { vAxis: {
title: '{% trans "Просмотры" %}' title: '{% trans "Просмотры" %}'

@ -5,9 +5,9 @@
<ul> <ul>
<li><a href="/places/country/">{% trans 'По странам' %}</a></li> <li><a href="/places/country/">{% trans 'По странам' %}</a></li>
<li><a href="/places/city/">{% trans 'По городам' %}</a></li> <li><a href="/places/city/">{% trans 'По городам' %}</a></li>
<li><a href="/places/city/moscow/">{% trans 'Места в Москве' %}</a></li> <li><a href="/places/city/moscow/">{% trans 'Площадки Москвы' %}</a></li>
<li><a href="/places/city/saint-petersburg/">{% trans 'Места в Петербурге' %}</a></li> <li><a href="/places/city/saint-petersburg/">{% trans 'Площадки Петербурга' %}</a></li>
<li><a href="/places/country/russia/">{% trans 'Места в России' %}</a></li> <li><a href="/places/country/russia/">{% trans 'Площадки России' %}</a></li>
</ul> </ul>
</nav> </nav>
</div> </div>

Loading…
Cancel
Save