From 7171482a5eeb0ee945baafbe80ed2929aa5a28c3 Mon Sep 17 00:00:00 2001 From: Alexander Burdeiny Date: Mon, 5 Sep 2016 08:11:56 +0300 Subject: [PATCH] unsubscribe 500 error fix --- emencia/django/newsletter/forms.py | 2 +- .../django/newsletter/views/mailing_list.py | 2 +- fabfile.py | 24 ++--- support/dev/settings.py | 2 + support/dev/tech_work_hit.expomap.ru | 12 ++- support/prod/settings.py | 3 +- support/prod/tech_work_hit.expomap.ru | 97 +++++++++++++++++++ 7 files changed, 125 insertions(+), 17 deletions(-) create mode 100644 support/prod/tech_work_hit.expomap.ru diff --git a/emencia/django/newsletter/forms.py b/emencia/django/newsletter/forms.py index dcc9baf3..3ab7616e 100644 --- a/emencia/django/newsletter/forms.py +++ b/emencia/django/newsletter/forms.py @@ -293,7 +293,7 @@ class SubscribeSettingsForm(AbstractSubscribeForm): europe_expo = forms.BooleanField(required=False, label=_(u'Выставки Европы')) def __init__(self, *args, **kwargs): - self.contact = kwargs.pop('contact') + self.contact = kwargs.pop('contact', None) self.activation_send = False lang = translation.get_language() self.cities_choices = dict(City.objects.language(lang).all().values_list('pk', 'name')) diff --git a/emencia/django/newsletter/views/mailing_list.py b/emencia/django/newsletter/views/mailing_list.py index abe75c39..f25d9a2d 100644 --- a/emencia/django/newsletter/views/mailing_list.py +++ b/emencia/django/newsletter/views/mailing_list.py @@ -80,7 +80,7 @@ class UnsubscribeView(DetailView): if setting.area.filter(id=SubscribeSettingsForm.EUROPE_ID).exists(): initial['europe_expo'] = True - form = SubscribeSettingsForm(instance=setting, initial=initial) + form = SubscribeSettingsForm(instance=setting, initial=initial, contact=contact) return form def get_context_data(self, **kwargs): diff --git a/fabfile.py b/fabfile.py index f30e0d09..004a97e8 100644 --- a/fabfile.py +++ b/fabfile.py @@ -86,11 +86,11 @@ def get_configs(): 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) + # 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) @@ -126,11 +126,11 @@ def stage_init(stage_num): run('git fetch') run('git checkout stage{stage_num}'.format(stage_num=stage_num)) run('git pull') - stage_num = int(stage_num) - if stage_num in stages and isinstance(stages[stage_num], dict): - for func_name, func in stages[stage_num].iteritems(): - func() - call_state('start', only='apache2') + # stage_num = int(stage_num) + # if stage_num in stages and isinstance(stages[stage_num], dict): + # for func_name, func in stages[stage_num].iteritems(): + # func() + # call_state('start', only='apache2') def migrate(app_name): @@ -138,10 +138,10 @@ def migrate(app_name): run('python manage.py migrate {app_name}'.format(app_name=app_name)) -def devmode(state): +def devmode(state=True): localdir = join(LOCAL_HOME_DIR, 'support/', env.role) # nginx - conf = nginx_conf_tech if state else nginx_conf + conf = nginx_conf_tech if state == True else nginx_conf put(join(localdir, basename(conf)), nginx_conf) run('/etc/init.d/nginx reload') diff --git a/support/dev/settings.py b/support/dev/settings.py index 0279ca10..25625221 100644 --- a/support/dev/settings.py +++ b/support/dev/settings.py @@ -394,6 +394,8 @@ CRONJOBS = [ # ('41 5 * * *', 'django.core.management.call_command', ['newsletter_create_announce']), ('12 4 * * *', 'django.core.management.call_command', ['stats_daily']), + ('5 10 * * *', 'django.core.management.call_command', ['update_events_filter_fields']), + ] PYMORPHY_DICTS = { diff --git a/support/dev/tech_work_hit.expomap.ru b/support/dev/tech_work_hit.expomap.ru index 715269f8..6856096b 100644 --- a/support/dev/tech_work_hit.expomap.ru +++ b/support/dev/tech_work_hit.expomap.ru @@ -4,6 +4,12 @@ server { return 301 https://$host$request_uri; } +geo $maintenance { + default yes; + 127.0.0.1/32 no; + 31.43.24.170/24 no; +} + server { listen 443; server_name 176.121.11.165 www.expomap.ru expomap.ru dev.expomap.ru; @@ -25,7 +31,9 @@ server { error_page 503 /dev_work.html; location / { - return 503; + if ($maintenance = yes) { + return 503; + } auth_basic "Unauthorized"; auth_basic_user_file /home/www/proj/.htpasswd; proxy_pass http://127.0.0.1:8080/; @@ -73,7 +81,7 @@ server { } location = /dev_work.html { - root home/www/proj/support/; + root /home/www/proj/support/; internal; } diff --git a/support/prod/settings.py b/support/prod/settings.py index 7cffd26f..a9ac78e2 100644 --- a/support/prod/settings.py +++ b/support/prod/settings.py @@ -8,7 +8,7 @@ from django.utils.translation import ugettext_lazy as _ DJANGO_ROOT = os.path.dirname(os.path.realpath(django.__file__)) SITE_ROOT = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0] -DEBUG = False +DEBUG = True ADMINS = ( @@ -394,6 +394,7 @@ CRONJOBS = [ ('41 5 * * *', 'django.core.management.call_command', ['newsletter_create_announce']), ('12 4 * * *', 'django.core.management.call_command', ['stats_daily']), + ('5 10 * * *', 'django.core.management.call_command', ['update_events_filter_fields']), ] PYMORPHY_DICTS = { diff --git a/support/prod/tech_work_hit.expomap.ru b/support/prod/tech_work_hit.expomap.ru new file mode 100644 index 00000000..e7940a24 --- /dev/null +++ b/support/prod/tech_work_hit.expomap.ru @@ -0,0 +1,97 @@ +server { + server_name expomap.ru www.expomap.ru; +# listen 80; + + return 301 https://expomap.ru$request_uri; +} + +geo $maintenance { + default yes; + 127.0.0.1/32 no; + 31.43.24.170/24 no; +} + +server { + listen 176.121.11.162:443 ssl; + server_name www.expomap.ru; + +# ssl on; +# ssl_certificate /etc/nginx/ssl/expomap.ru.crt; +# ssl_certificate_key /etc/nginx/ssl/expomap.ru.key; + + return 301 https://expomap.ru$request_uri; +} + +server { + listen 176.121.11.162:443 ssl default_server ; + server_name expomap.ru ; +# ssl_stapling on; + ssl on; + ssl_certificate /etc/nginx/ssl/expomap.ru.crt; + ssl_certificate_key /etc/nginx/ssl/expomap.ru.key; + ssl_dhparam /etc/nginx/ssl/dhparam.pem; + ssl_session_timeout 24h; + ssl_session_cache shared:SSL:25m; + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_ciphers kEECDH+AES128:kEECDH:kEDH:-3DES:kRSA+AES128:kEDH+3DES:DES-CBC3-SHA:!RC4:!aNULL:!eNULL:!MD5:!EXPORT:!LOW:!SEED:!CAMELLIA:!IDEA:!PSK:!SRP:!SSLv2; + ssl_prefer_server_ciphers on; + add_header Strict-Transport-Security "max-age=31536000;"; + add_header Content-Security-Policy-Report-Only "default-src https:; script-src https: 'unsafe-eval' 'unsafe-inline'; style-src https: 'unsafe-inline'; img-src https: data:; font-src https: data:"; + + client_header_timeout 360s; + + error_page 503 /dev_work.html; + + location / { +# auth_basic "Unauthorized"; +# auth_basic_user_file /home/www/proj/.htpasswd; + + if ($maintenance = yes) { + return 503; + } + + proxy_pass http://127.0.0.1:8080; + proxy_redirect off; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + include /etc/nginx/geoip_proxy.conf; + + client_max_body_size 100m; + client_body_buffer_size 128k; + + proxy_connect_timeout 90; + proxy_send_timeout 90; + proxy_read_timeout 90; + proxy_buffer_size 16k; + proxy_buffers 256 8k; + proxy_busy_buffers_size 2000k; + proxy_temp_file_write_size 2048k; + } + + + location /965E1EE7949FD639CA0124C8D8C57774.txt { + root /home/www/proj/; + } + + location /4885b11a73674eb6d54593c1d7efd758821e5ee79b8132feecaba10560f0123a.html { + root /home/www/proj/support; + } + + location /static { + root /home/www/proj; + } + location /media { + root /home/www/proj; + } + + location /templates { + root /home/www/proj/static; + } + location /subdmn { + root /home/old_files; + } + + +} +