remotes/origin/1203
Назар Котюк 11 years ago
parent 7cd090f065
commit d64c068623
  1. 24
      accounts/views.py
  2. 2
      city/admin.py
  3. 2
      city/forms.py
  4. 4
      conference/forms.py
  5. 2
      exposition/admin_urls.py
  6. 2
      functions/admin_forms.py
  7. 31
      organiser/management/commands/organiser_from_old_db.py
  8. 8
      place_exposition/management/commands/convert_logo.py
  9. 2
      settings/templatetags/template_filters.py
  10. 7
      templates/admin/city/city_add.html
  11. 6
      templates/client/includes/accounts/calendar_table.html

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
import dateutil.relativedelta as rdelta
import json, datetime
import calendar as python_calendar
from django.shortcuts import get_object_or_404
@ -70,7 +71,7 @@ class CalendarView(TemplateView):
number_of_days = python_calendar.monthrange(now.year, now.month)[1]
# number of days in current month
days = [timezone.make_aware(datetime.datetime(now.year, now.month, i+1), timezone.get_default_timezone()) for i in range(number_of_days)]
context['days'] = days
#context['days'] = days
calendar = self.request.user.calendar
# events in current month
@ -80,15 +81,32 @@ class CalendarView(TemplateView):
number_of_days = python_calendar.monthrange(year, month)[1]
days = [timezone.make_aware(datetime.datetime(year, month, i+1), timezone.get_default_timezone()) for i in range(number_of_days)]
# number of days in current month
context['days'] = days
#context['days'] = days
calendar = self.request.user.calendar
now = now.replace(year=year, month=month, day=1)
# events in current month
context['events'] = calendar.events_by_month(now)
# add days from previous mondey to next sunday
first_day = days[0]
if first_day.weekday() != 0:
past_monday = first_day + rdelta.relativedelta(days=-1, weekday=rdelta.MO(-1))
a = [past_monday + datetime.timedelta(days=x) for x in range((first_day - past_monday).days)]
days = a + days
last_day = days[-1]
if last_day != 6:
next_sunday = last_day + rdelta.relativedelta(days=1, weekday=rdelta.SU(+1))
b = [last_day + datetime.timedelta(days=x+1) for x in range((next_sunday - last_day).days)]
days += b
events = context['events']
days = context['days']
context['days'] = days
#days = context['days']
event_in_day = False
counter = 0
dates_with_events = []

@ -56,7 +56,7 @@ def city_change(request, url):
else:
#fill form with data from database
data = {'population' : c.population, 'phone_code' : c.phone_code,
'city_id' : city_id}
'city_id' : city_id, 'inflect':c.inflect}
if c.country:
data['country'] = c.country.id

@ -33,6 +33,7 @@ class CityForm(forms.Form):
phone_code = forms.CharField(label='Код города', required=False,
widget=forms.TextInput(attrs={'placeholder':'Код города'}))
code_IATA = forms.ModelChoiceField(label='Код IATA', queryset=Iata.objects.all(), empty_label=None, required=False)
inflect = forms.CharField(label='Inflect', required=False)
#field for comparing tmp files
key = forms.CharField(required=False, widget=forms.HiddenInput())
#
@ -85,6 +86,7 @@ class CityForm(forms.Form):
city.phone_code = data['phone_code']
city.population = data.get('population')
city.inflect = data['inflect']
if data.get('code_IATA'):
city.code_IATA = Iata.objects.get(id=data['code_IATA'].id)# .id cause select uses queryset

@ -36,12 +36,12 @@ class ConferenceCreateForm(forms.Form):
data_begin = forms.DateField(label='Дата начала')
data_end = forms.DateField(label='Дата окночания')
country = forms.ModelChoiceField(label='Страна', queryset=Country.objects.all(), empty_label=None)
country = forms.ChoiceField(label=u'Страна', choices=[(c.id, c.name) for c in Country.objects.all()])
theme = forms.ModelMultipleChoiceField(label='Тематики', queryset=Theme.objects.all())
place = forms.ModelChoiceField(label='Место проведения', queryset=PlaceConference.objects.all(),
empty_label='', required=False)
#creates select input with empty choices cause it will be filled with ajax
city = forms.ChoiceField(label='Город', choices=[('','')])
city = forms.CharField(label=u'Город', widget=forms.HiddenInput())
tag = forms.MultipleChoiceField(label='Теги', required=False)
web_page = forms.CharField(label='Веб страница', required=False)

@ -6,7 +6,7 @@ urlpatterns = patterns('exposition.admin',
url(r'^upload-photo/(?P<expo_id>.*)/$', 'upload_exposition_photo'),
#url(r'^add.*/$', 'exposition_add'),
#url(r'^delete/(?P<url>.*)/$', 'exposition_delete'),
url(r'^delete/(?P<url>.*)/$', 'exposition_delete'),
#url(r'^change/(?P<url>.*)/$', 'exposition_change'),
url(r'^all/$', ExpositionListView.as_view()),
url(r'^switch/(?P<url>.*)/(?P<action>.*)$', 'exposition_switch'),

@ -44,6 +44,6 @@ class AdminFilterForm(forms.Form):
qs = model.objects.all()
if name:
qs = qs.filter(translations__name__contains=name).distinct()
qs = qs.filter(translations__name__icontains=name).distinct()
return qs

@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
from django.core.management.base import BaseCommand, CommandError
from organiser.models import Organiser
from theme.models import Theme, Tag
from functions.form_check import translit_with_separator
from accounts.models import User
import MySQLdb
from MySQLdb.cursors import DictCursor
@ -21,9 +23,9 @@ def convert_to_int(st):
class Command(BaseCommand):
def handle(self, *args, **options):
db = MySQLdb.connect(host="localhost",
user="root",
user="kotzilla",
passwd="qazedc",
db="expomap_ru",
db="old_expomap",
charset='utf8',
cursorclass=DictCursor)
@ -31,18 +33,18 @@ class Command(BaseCommand):
sql = """SELECT DISTINCT(customers_company) as name, specialize, otrasly as theme, tags, adress,
phone, fax, email, website, twitter, about, customers_company.url
sql = """SELECT DISTINCT(customers_company) as name, customers_email_address as user_email, specialize, otrasly as theme, tags, adress,
phone, fax, email, website, twitter, about, customers_company.url, company_last_modified as modified
FROM customers
LEFT JOIN customers_company
ON customers.customers_company=customers_company.title
ON customers.customers_id = customers_company.customers_id
WHERE customers_status = 4
"""
cursor.execute(sql)
res = cursor.fetchall()
print(res[0].get('user_email'))
for o in res:
if not o.get('name'):
@ -66,7 +68,7 @@ class Command(BaseCommand):
organiser.description = o.get('about')
if organiser.name:
print('not_saved: %s'%o['name'])
print('not_saved: %s'%o['name'].encode('utf8'))
organiser.save()
print('saved: %s'%str(organiser))
@ -75,12 +77,10 @@ class Command(BaseCommand):
if theme_id:
try:
theme = Theme.objects.get(id=theme_id)
organiser.theme.add(theme)
except Theme.DoesNotExist:
continue
organiser.theme.add(theme)
pass
if not theme:
continue
tags = o.get('tags')
if tags:
@ -104,5 +104,14 @@ class Command(BaseCommand):
organiser.save()
print(organiser)
user_email = o.get('user_email')
if user_email:
try:
user = User.objects.get(username=user_email)
user.organiser = organiser
user.save()
except User.DoesNotExist:
print('no user with this email: %s'%user_email)
print('success')

@ -27,15 +27,9 @@ def handle_place(place):
place.save()
class Command(BaseCommand):
def handle(self, *args, **options):
for place in PlaceExposition.objects.all('en'):
if place.files.filter(purpose='logo').exists():
handle_place(place)
print(place)
print(place)

@ -232,7 +232,7 @@ def next_monthes(value):
@register.filter
def get_rus_day(date):
days = {1: u'Пн', 2: u'Вт', 3: u'Ср', 4: u'Чт', 5: u'Пт', 6: u'Сб', 0: u'Вс',}
days = {0: u'Пн', 1: u'Вт', 2: u'Ср', 3: u'Чт', 4: u'Пт', 5: u'Сб', 6: u'Вс',}
return days.get(date.weekday(), '')

@ -35,6 +35,13 @@
{% with field='name' form=form languages=languages %}
{% include 'admin/forms/multilang.html' %}
{% endwith %}
{# population #}
<div class="control-group">
<label class="control-label">{{ form.inflect.label }}:</label>
<div class="controls">
{{ form.inflect }}
</div>
</div>
{# country #}
<div class="control-group">
<label class="control-label"><b>{{ form.country.label }}:</b></label>

@ -9,9 +9,9 @@
<div class="ep-sect-body calenadar-body">
<header>
<div class="pc-month-wrap">
<a class="pcm-prev" href="/profile/calendar/?year={{ days.0|add_month:'-1'|date:'Y' }}&month={{ days.0|add_month:'-1'|date:'m' }}">&lt;</a>
<div class="pc-month">{{ days.0|date:"F"}}’{{ days.0|date:"y"}}</div>
<a class="pcm-next" href="/profile/calendar/?year={{ days.0|add_month:'1'|date:'Y' }}&month={{ days.0|add_month:'1'|date:'m' }}">&gt;</a>
<a class="pcm-prev" href="/profile/calendar/?year={{ days.15|add_month:'-1'|date:'Y' }}&month={{ days.0|add_month:'-1'|date:'m' }}">&lt;</a>
<div class="pc-month">{{ days.15|date:"F"}}’{{ days.15|date:"y"}}</div>
<a class="pcm-next" href="/profile/calendar/?year={{ days.15|add_month:'1'|date:'Y' }}&month={{ days.15|add_month:'1'|date:'m' }}">&gt;</a>
</div>
</header>
<div class="cal-wrap">

Loading…
Cancel
Save