diff --git a/accounts/models.py b/accounts/models.py index 94251f8d..1ca10054 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -222,6 +222,23 @@ class User(AbstractBaseUser, PermissionsMixin): """ return self.seminar_users.language().select_related('country', 'city').all() + def remove_from_calendar(self, data): + expo = data['expo'] + conf = data['conf'] + seminar = data['seminar'] + webinar = data['webinar'] + calendar = self.calendar + if expo: + calendar.expositions.remove(*expo) + if conf: + calendar.conferences.remove(*conf) + if seminar: + calendar.seminars.remove(*seminar) + if webinar: + calendar.webinars.remove(*webinar) + + + class Profile(models.Model): diff --git a/accounts/urls.py b/accounts/urls.py index e7842ee5..ffd93efa 100644 --- a/accounts/urls.py +++ b/accounts/urls.py @@ -15,6 +15,7 @@ urlpatterns = patterns('', url(r'^profile/$', login_required(ProfileView.as_view())), url(r'^profile/company/$', login_required(ProfileCompanyView.as_view())), url(r'^profile/settings/$', login_required(SettingsView.as_view())), + url(r'^profile/calendar/remove/$', 'accounts.views.remove_from_calendar'), url(r'^profile/calendar/$', login_required(CalendarView.as_view())), url(r'^profile/feed/page/(?P\d+)/$', Feed.as_view()), url(r'^profile/feed/$', login_required(Feed.as_view())), diff --git a/accounts/views.py b/accounts/views.py index f0cf357a..12b7637a 100644 --- a/accounts/views.py +++ b/accounts/views.py @@ -481,4 +481,24 @@ class Feed(ListView): user = self.request.user filter_form = self.filter_form(user=user) context['filter_form'] = filter_form - return context \ No newline at end of file + return context + + +@login_required +def remove_from_calendar(request): + if request.GET: + expo = request.GET.get('expo') + conf = request.GET.get('conf') + seminar = request.GET.get('seminar') + webinar = request.GET.get('webinar') + + data = {'expo': expo if expo is None else json.loads(expo), + 'conf': conf if conf is None else json.loads(conf), + 'seminar': seminar if seminar is None else json.loads(seminar), + 'webinar': webinar if webinar is None else json.loads(webinar)} + user = request.user + user.remove_from_calendar(data) + + return HttpResponse(json.dumps({'success': True}), content_type='application/json') + else: + return Http404 \ No newline at end of file diff --git a/templates/client/accounts/calendar.html b/templates/client/accounts/calendar.html index 4cb234ab..4b12759f 100644 --- a/templates/client/accounts/calendar.html +++ b/templates/client/accounts/calendar.html @@ -24,8 +24,64 @@ {% endwith %} +
+
+
{{ days.15|date:"F"}}’{{ days.15|date:"y"}}
+ {% include 'includes/accounts/calendar_list.html' with events=events %} +
+ +
+
{% trans 'Все / выделенные:' %}
+ + +
+ + + +
+ + {% endblock %} {% block scripts %} + {% endblock %} \ No newline at end of file diff --git a/templates/client/includes/accounts/calendar_list.html b/templates/client/includes/accounts/calendar_list.html new file mode 100644 index 00000000..47c1600b --- /dev/null +++ b/templates/client/includes/accounts/calendar_list.html @@ -0,0 +1,44 @@ + \ No newline at end of file diff --git a/templates/client/includes/accounts/calendar_table.html b/templates/client/includes/accounts/calendar_table.html index 2a6d694d..3a81bb28 100644 --- a/templates/client/includes/accounts/calendar_table.html +++ b/templates/client/includes/accounts/calendar_table.html @@ -9,7 +9,7 @@
- < + <
{{ days.15|date:"F"}}’{{ days.15|date:"y"}}
>