conference main page

remotes/origin/1203
Ivan Kovalkovskyi 10 years ago
parent 1ef3efd313
commit bc10a73aa2
  1. 1
      conference/models.py
  2. 54
      expobanner/admin.py
  3. 6
      expobanner/admin_urls.py
  4. 32
      expobanner/forms.py
  5. 8
      expobanner/models.py
  6. 2
      templates/admin/expobanner/default_form.html
  7. 23
      templates/admin/expobanner/main_list.html
  8. 33
      templates/admin/expobanner/paid_create.html
  9. 1
      templates/admin/includes/admin_nav.html

@ -111,6 +111,7 @@ class Conference(TranslatableModel, EventMixin, ExpoMixin):
keywords=models.CharField(max_length=250),
)
main = models.ForeignKey('expobanner.MainPage', blank=True, null=True, on_delete=models.SET_NULL)
#fields saves information about creating and changing model
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)

@ -6,9 +6,9 @@ from django.shortcuts import get_object_or_404
from django.db.models import Sum
from expobanner.models import URL, BannerGroup, Banner, Paid, MainPage, Top
from expobanner.forms import UrlCreateForm, BannerCreateGroupForm, BannerCreateForm, BannerGroupUpdateForm,\
PaidCreateForm, PaidUpdateForm, TopCreateForm, BannerLinkCreateForm, MainCreateForm, MainUpdateForm, TopUpdateForm
PaidCreateForm, PaidUpdateForm, TopCreateForm, BannerLinkCreateForm, MainCreateForm, MainConfCreateForm, MainUpdateForm, TopUpdateForm
from exposition.models import Exposition
from conference.models import Conference
class BannersControl(TemplateView):
template_name = 'admin/expobanner/banners_control.html'
@ -203,6 +203,8 @@ class PaidStat(DetailView):
return context
# ----------------------------------
class MainList(ListView):
model = Exposition
template_name = 'admin/expobanner/main_list.html'
@ -227,7 +229,6 @@ class MainUpdate(UpdateView):
template_name = 'admin/expobanner/default_form.html'
success_url = '/admin/expobanners/main/list/'
def get_context_data(self, **kwargs):
context = super(MainUpdate, self).get_context_data(**kwargs)
obj = self.object
@ -235,6 +236,50 @@ class MainUpdate(UpdateView):
return context
class MainConfList(ListView):
model = Conference
template_name = 'admin/expobanner/main_list.html'
paginate_by = settings.ADMIN_PAGINATION
def get_queryset(self):
qs = self.model.objects.language().filter(main__isnull=False).order_by('-main__public')
if self.request.GET.get('onlypublic'):
qs = qs.filter(main__public=True)
return qs
def get_context_data(self, **kwargs):
context = super(MainConfList, self).get_context_data(**kwargs)
context.update({'conf': True})
return context
from django.core.urlresolvers import reverse_lazy
class MainConfCreate(CreateView):
form_class = MainConfCreateForm
template_name = 'admin/expobanner/paid_create.html'
success_url = reverse_lazy('expobanner-conf-list_main')
def get_context_data(self, **kwargs):
context = super(MainConfCreate, self).get_context_data(**kwargs)
context.update({'conf': True})
return context
class MainConfUpdate(UpdateView):
model = MainPage
form_class = MainUpdateForm
template_name = 'admin/expobanner/default_form.html'
success_url = reverse_lazy('expobanner-conf-list_main')
def get_context_data(self, **kwargs):
context = super(MainConfUpdate, self).get_context_data(**kwargs)
obj = self.object
context['conference'] = obj.get_event()
return context
def main_turn(request, pk, status):
main = get_object_or_404(MainPage, pk=pk)
if status == 'on':
@ -242,10 +287,11 @@ def main_turn(request, pk, status):
else:
main.public = False
main.save()
return HttpResponseRedirect('/admin/expobanners/main/list/')
return HttpResponseRedirect(request.META['HTTP_REFERER'])
from datetime import datetime
class MainStat(DetailView):
model = MainPage
template_name = 'admin/expobanner/main_stat.html'

@ -36,4 +36,10 @@ urlpatterns = patterns('expobanner.admin',
url(r'^main/$', MainCreate.as_view(), name='expobanner-create_main'),
url(r'^main/turn/(?P<pk>\d+)/(?P<status>.*)/$', main_turn, name='expobanner-main-turn'),
url(r'^main/(?P<pk>\d+)/stat/$', MainStat.as_view(), name='expobanner_stat_main'),
# conference on main page
url(r'^main/conf/list/$', MainConfList.as_view(), name='expobanner-conf-list_main'),
url(r'^main/conf/(?P<pk>\d+)/edit/$', MainConfUpdate.as_view(), name='expobanner-conf-update_main'),
url(r'^main/conf/$', MainConfCreate.as_view(), name='expobanner-conf-create_main'),
url(r'^main/conf/turn/(?P<pk>\d+)/(?P<status>.*)/$', main_turn, name='expobanner-conf-main-turn'),
#url(r'^main/conf/(?P<pk>\d+)/stat/$', MainStat.as_view(), name='expobanner_stat_main'),
)

@ -2,6 +2,7 @@
from django import forms
from expobanner.models import URL, BannerGroup, Banner, Paid, Top, MainPage
from exposition.models import Exposition
from conference.models import Conference
from country.models import Country
from ckeditor.widgets import CKEditorWidget
from theme.models import Theme, Tag
@ -107,6 +108,7 @@ class PaidCreateForm(forms.ModelForm):
raise forms.ValidationError(u'Такой выставки не существует')
return expo
class MainCreateForm(forms.ModelForm):
verbose = u'Добавить выставку на главную'
exposition = forms.CharField(label=u'Выставка', widget=forms.HiddenInput())
@ -137,6 +139,36 @@ class MainCreateForm(forms.ModelForm):
return expo
class MainConfCreateForm(forms.ModelForm):
verbose = u'Добавить конференцию на главную'
conf = forms.CharField(label=u'Конференция', widget=forms.HiddenInput())
class Meta:
model = MainPage
fields = ['position', 'public']
def save(self, commit=True):
main = super(MainConfCreateForm, self).save(commit=False)
if commit:
conf = self.cleaned_data['conf']
link = conf.get_permanent_url()
link_b = Banner.objects.create_for_paid(conf, link, 'main_page_link')
main.link = link_b
main.save()
conf.main = main
conf.save()
return main
def clean_conf(self):
conf_id = self.cleaned_data['conf']
try:
conf = Conference.objects.get(id=conf_id)
except Conference.DoesNotExist:
raise forms.ValidationError(u'Такой конференции не существует')
return conf
class PaidUpdateForm(forms.ModelForm):
tickets = forms.URLField(label=u'Линк на билеты')
participation = forms.URLField(label=u'Линк на участие')

@ -297,7 +297,13 @@ class MainPage(models.Model, StatMixin):
try:
return self.exposition_set.all()[0]
except IndexError:
return None
try:
return self.conference_set.all()[0]
except IndexError:
return None
def __unicode__(self):
return self.get_event().url
def generatePassword(length=5):

@ -51,7 +51,7 @@
<div class="box span8">
<div class="box-header well">
<h2><i class="icon-pencil"></i>{{ form.verbose }}</h2>
<h2><i class="icon-pencil"></i> {% if form.verbose %} {{ form.verbose }} {% else %} {{ object.get_event }} {% endif %}</h2>
</div>
<div class="box-content">
{% for field in form %}

@ -4,13 +4,17 @@
<div class="box span8">
<div class="box-header well">
<h2><i class="icon-arrow-down"></i>Список выставок на главной</h2>
<h2><i class="icon-arrow-down"></i>Список {% if conf %}конференций{% else %}выставок{% endif %} на главной</h2>
</div>
<div class="box-content">
{% block list_table %}
<div style="float:left;">
{% if conf %}
<a class="btn btn-success" href="{% url 'expobanner-conf-create_main' %}"><i class="icon-plus-sign icon-white"></i> Добавить конференцию</a>
{% else %}
<a class="btn btn-success" href="{% url 'expobanner-create_main' %}"><i class="icon-plus-sign icon-white"></i> Добавить выставку</a>
</div>
{% endif %}
</div>
<div style="float:right;">
<form method="get" id="form">
Только опубликование<input id="public" type="checkbox" name="onlypublic" value="true">
@ -19,7 +23,11 @@
<table class="table table-hover">
<thead>
<tr>
<th>Выставка</th>
{% if conf %}
<th>Конференция</th>
{% else %}
<th>Выставка</th>
{% endif %}
<th>Позиция</th>
<th>&nbsp;</th>
<th>&nbsp;</th>
@ -31,8 +39,13 @@
<tr>
<td>{{ item }}</td>
<td>{{ item.main.position }}</td>
<td><a href="{% url 'expobanner-update_main' item.main.id %}">Изменить</a> </td>
<td>{% if item.main.public %}<a href="{% url 'expobanner-main-turn' item.main.id 'off' %}">отключить</a>{% else %}<a href="{% url 'expobanner-main-turn' item.main.id 'on' %}">включить</a>{% endif %} </td>
{% if conf %}
<td><a href="{% url 'expobanner-conf-update_main' item.main.id %}">Изменить</a> </td>
<td>{% if item.main.public %}<a href="{% url 'expobanner-conf-main-turn' item.main.id 'off' %}">отключить</a>{% else %}<a href="{% url 'expobanner-conf-main-turn' item.main.id 'on' %}">включить</a>{% endif %} </td>
{% else %}
<td><a href="{% url 'expobanner-update_main' item.main.id %}">Изменить</a> </td>
<td>{% if item.main.public %}<a href="{% url 'expobanner-main-turn' item.main.id 'off' %}">отключить</a>{% else %}<a href="{% url 'expobanner-main-turn' item.main.id 'on' %}">включить</a>{% endif %} </td>
{% endif %}
<td><a href="{% url 'expobanner_stat_main' item.main.id %}">Статистика</a> </td>
</tr>
{% endfor %}

@ -39,6 +39,39 @@
}
});
$('#id_conf').select2({
placeholder: 'Найти',
width: 'element',
ajax: {
url: '/admin/conference/search/',
dataType: "json",
quietMillis: 200,
multiple: true,
data: function(term, page){
return {term: term,
page: page};
},
results: function (data) {
var results = [];
$.each(data, function(index, item){
results.push({
id: item.id,
text: item.label
});
});
return {results: results};
}
},
initSelection : function(element, callback) {
var id= $(element).val();
var text = $(element).attr('data-init-text');
callback({id: id, text:text});
}
});
});
</script>
{% endblock %}

@ -107,6 +107,7 @@
<li><a href="/admin/expobanners/paid/list/">Платные выставки</a></li>
<li><a href="/admin/expobanners/top/list/">Выставки в топе</a></li>
<li><a href="/admin/expobanners/main/list/">Выставки на главной</a></li>
<li><a href="/admin/expobanners/main/conf/list/">Конференции на главной</a></li>
</ul>
</li>

Loading…
Cancel
Save