1451: Этап №5: Аминка баги - Урл ТОП размещения

update
remotes/origin/stage5
Alexander Burdeiny 10 years ago
parent de038917f9
commit 096d4b86e1
  1. 2
      expobanner/management/commands/banner_log_update.py
  2. 35
      fabfile.py
  3. 2
      functions/custom_fields.py

@ -40,8 +40,6 @@ class Command(BaseCommand):
unique_views = Log.objects.filter(type=1, **params).values('ip').distinct().count()
unique_clicks = Log.objects.filter(type=2, **params).values('ip').distinct().count()
print(views, clicks, unique_views, unique_clicks)
logstat.click += clicks
logstat.view += views
logstat.unique_click += unique_clicks

35
fabfile.py vendored

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from os.path import join, basename
from collections import namedtuple, OrderedDict
import re
from fabric.api import *
@ -24,7 +24,7 @@ services = ['nginx', 'apache2']
stages = {}
tickets = {}
commands = {}
def stage(stage_num):
def ticket(func):
@ -35,19 +35,37 @@ def stage(stage_num):
return func
return ticket
# command_pattern
# cp = re.compile('^python manage.py (?P<command>\w+)$')
cp = re.compile('^(?P<command>\w+)$')
def register_command(command_string):
command = cp.match(command_string).group('command')
if not command:
raise ValueError('Invalid command string {command_string}'.format(command_string=command_string))
def func():
with cd(REMOTE_HOME_DIR):
run('python manage.py ' + command)
commands.update({command: func})
# run command
def rc(command):
if command in commands and callable(commands[command]):
commands[command]()
else:
raise ValueError('Command {command} is not callable'.format(command=command))
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)
@ -109,9 +127,12 @@ def stage_init(stage_num):
def t1451():
with cd(REMOTE_HOME_DIR):
run('python manage.py migrate expobanner')
run('python manage.py migrate banner_log_update_old')
run('python manage.py migrate banner_log_update')
rc('banner_log_update_old')
rc('banner_log_update')
register_command('banner_log_update_old')
register_command('banner_log_update')
# def stage3_pre_final():
# with cd(REMOTE_HOME_DIR):

@ -281,7 +281,7 @@ class MonthMultiSelectField(models.CharField):
@staticmethod
def get_data_from_string(s):
pattern = re.compile('^(?P<month>([1-9]|[1][0-2]))/(?P<year>[0-9]{4})$')
p = re.compile('^(?P<month>([1-9]|[1][0-2]))/(?P<year>[0-9]{4})$')
m = p.match(s)
return m.group('month'), m.group('year')

Loading…
Cancel
Save