digitalglarus booking update

This commit is contained in:
Tomislav R 2016-04-23 19:00:20 +02:00
parent 98cc38b1cf
commit 213f295394
22 changed files with 5935 additions and 3794 deletions

View file

@ -84,7 +84,7 @@ table {
/*select date*/ /*select date*/
.calendar tbody td:hover { .calendar tbody td:hover {
background: #8BC4C9; background: #347D80;
color: #f9f9f9; color: #f9f9f9;
/*border: .1px solid #8BC4C9;*/ /*border: .1px solid #8BC4C9;*/

View file

@ -15,15 +15,15 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="#"><span>Brand</span></a> <a class="navbar-brand" href="#"><span>Digital Glarus</span></a>
</div> </div>
<div class="collapse navbar-collapse" id="navbar-ex-collapse"> <div class="collapse navbar-collapse" id="navbar-ex-collapse">
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li class="active"> <li class="active">
<a href="#">Home</a> <a href="{% url 'digitalglarus:index' %}">Home</a>
</li> </li>
<li> <li>
<a href="#">Contacts</a> <a href="{% url 'digitalglarus:contact' %}">Contacts</a>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -1,6 +1,7 @@
from django.db import models from django.db import models
from cms.models import CMSPlugin from cms.models import CMSPlugin
from filer.fields.image import FilerImageField from filer.fields.image import FilerImageField
from django.core.urlresolvers import reverse
class Supporter(models.Model): class Supporter(models.Model):

View file

@ -0,0 +1,71 @@
.user {
padding-right: 2%;
background-position: 6px 7px;
background-repeat: no-repeat;
background-color: white;
padding: 5px 8px 4px 8px;
-webkit-border-radius: 0px 0px 8px 8px;
-moz-border-radius: 0px 0px 8px 8px;
border-radius: 1px 1px 1px 1px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin-left: 8px;
background-color: #333;
padding: 4px 4px 0px 4px;
-webkit-border-radius: 0px 0px 10px 10px;
-moz-border-radius: 0px 0px 10px 10px;
border-radius: 0px 0px 10px 10px;
font-size: 14px;
line-height: 1.42857143;
color: #794646;
background-color: #fff;
}
.user_loggedin{
padding-bottom: 2%;
padding-right: 2%;
background-position: 6px 7px;
background-repeat: no-repeat;
background-color: white;
padding: 5px 8px 4px 8px;
-webkit-border-radius: 0px 0px 8px 8px;
-moz-border-radius: 0px 0px 8px 8px;
border-radius: 1px 1px 1px 1px;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
float: left;
margin-left: 8px;
background-color: #333;
padding: 4px 4px 0px 4px;
-webkit-border-radius: 0px 0px 10px 10px;
-moz-border-radius: 0px 0px 10px 10px;
border-radius: 0px 0px 10px 10px;
font-size: 14px;
line-height: 1.42857143;
color: #777;
background-color: #fff;
}
.user > span {
width: 100%;
}
.u_P {
background-color: #fffcfc;
text-transform: uppercase;
padding-right: 2%;
padding-left:2%;
padding-bottom:0.5%;
margin-right: 1%;
}
.u_P a{
margin-bottom: 1%;
color: #777;
}
.u_P a:hover{
text-decoration: None;
color: #000;
}

View file

@ -21,12 +21,15 @@
<!-- Custom CSS --> <!-- Custom CSS -->
<link href="{% static 'digitalglarus/css/business-casual.css' %}" rel="stylesheet"> <link href="{% static 'digitalglarus/css/business-casual.css' %}" rel="stylesheet">
<link href="{% static 'digitalglarus/css/login.css' %}" rel="stylesheet">
<!-- Fonts --> <!-- Fonts -->
<link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" <link href="//fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800"
rel="stylesheet" type="text/css"> rel="stylesheet" type="text/css">
<link href="//fonts.googleapis.com/css?family=Josefin+Slab:100,300,400,600,700,100italic,300italic,400italic,600italic,700italic" <link href="//fonts.googleapis.com/css?family=Josefin+Slab:100,300,400,600,700,100italic,300italic,400italic,600italic,700italic"
rel="stylesheet" type="text/css"> rel="stylesheet" type="text/css">
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css"
rel="stylesheet" type="text/css">
{% render_block "css" postprocessor "compressor.contrib.sekizai.compress" %} {% render_block "css" postprocessor "compressor.contrib.sekizai.compress" %}
{% render_block "js" postprocessor "compressor.contrib.sekizai.compress" %} {% render_block "js" postprocessor "compressor.contrib.sekizai.compress" %}
@ -37,6 +40,7 @@
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]--> <![endif]-->
<script> <script>
(function (i, s, o, g, r, a, m) { (function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r; i['GoogleAnalyticsObject'] = r;
@ -58,14 +62,28 @@
<body> <body>
{% cms_toolbar %} {% cms_toolbar %}
<div class="pull-right u_P user">
{% if request.user.is_authenticated %}
<div class="user_loggedin">
<h4>{{ request.user.name }}
<a href="{% url 'logout_glarus' %}"><i class="fa fa-1x fa-sign-out"
aria-hidden="true"></i></a>
</h4>
</div>
{% else %}
<a href="{% url 'login_glarus' %}"><h4>Login</h4></a>
{% endif %}
</div>
<div class="brand">Digital Glarus</div> <div class="brand">Digital Glarus</div>
<div class="address-bar">The Swiss IT Valley | Schwanden, 8762 GL Switzerland | From 2015.10.13</div> <div class="address-bar">The Swiss IT Valley | Schwanden, 8762 GL Switzerland | From 2015.10.13</div>
<div>{% language_chooser "language_chooser.html" %}</div> <div>{% language_chooser "language_chooser.html" %}</div>
<!-- Navigation --> <!-- Navigation -->
<nav class="navbar navbar-default" role="navigation"> <nav class="navbar navbar-default" role="navigation">
<div class="container"> <div class="container">
<!-- Brand and toggle get grouped for better mobile display --> <!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" <button type="button" class="navbar-toggle" data-toggle="collapse"
data-target="#bs-example-navbar-collapse-1"> data-target="#bs-example-navbar-collapse-1">

View file

@ -9,6 +9,8 @@ urlpatterns = [
url(_(r'about/?$'), AboutView.as_view(), name='about'), url(_(r'about/?$'), AboutView.as_view(), name='about'),
url(_(r'contact/?$'), ContactView.as_view(), name='contact'), url(_(r'contact/?$'), ContactView.as_view(), name='contact'),
url(_(r'supporters/?$'), views.supporters, name='supporters'), url(_(r'supporters/?$'), views.supporters, name='supporters'),
url(_(r'calendar_api/(?P<month>\d+)/(?P<year>\d+)?$'),views.CalendarApi.as_view()),
url(_(r'calendar_api/'),views.CalendarApi.as_view()),
url(_(r'support-us/?$'), views.support, name='support'), url(_(r'support-us/?$'), views.support, name='support'),
url(r'^blog/(?P<slug>\w[-\w]*)/$', views.blog_detail, name='blog-detail'), url(r'^blog/(?P<slug>\w[-\w]*)/$', views.blog_detail, name='blog-detail'),
url(r'blog/$', views.blog, name='blog'), url(r'blog/$', views.blog, name='blog'),

View file

@ -9,12 +9,28 @@ from django.views.generic import TemplateView
from django.utils.translation import get_language from django.utils.translation import get_language
from djangocms_blog.models import Post from djangocms_blog.models import Post
from django.contrib import messages from django.contrib import messages
from django.http import JsonResponse
from django.views.generic import View
from .models import Supporter from .models import Supporter
from utils.forms import ContactUsForm from utils.forms import ContactUsForm
from django.views.generic.edit import FormView from django.views.generic.edit import FormView
from membership.calendar.calendar import BookCalendar
from membership.models import Calendar as CalendarModel
import json
from django.contrib.auth import logout
class CalendarApi(View):
def get(self,request,month,year):
calendar = BookCalendar(request.user,requested_month=month).formatmonth(int(year),int(month))
ret = {'calendar':calendar,'month':month,'year':year}
return JsonResponse(ret)
def post(self,request):
pd = json.loads(request.POST.get('data',''))
ret = {'status':'success'}
CalendarModel.add_dates(pd,request.user)
return JsonResponse(ret)
class ContactView(FormView): class ContactView(FormView):
template_name = 'contact.html' template_name = 'contact.html'
@ -45,17 +61,6 @@ def detail(request, message_id):
def about(request): def about(request):
return render(request, 'digitalglarus/about.html') return render(request, 'digitalglarus/about.html')
#def index(request):
# return render(request, 'digitalglarus/index.html')
#
#def letscowork(request):
# return render(request, 'digitalglarus/letscowork.html')
# def index(request):
# return home(request)
def home(request): def home(request):
return render(request, 'index.html') return render(request, 'index.html')
@ -92,3 +97,6 @@ def supporters(request):
'supporters': Supporter.objects.order_by('name') 'supporters': Supporter.objects.order_by('name')
} }
return render(request, 'supporters.html', context) return render(request, 'supporters.html', context)

View file

@ -282,9 +282,9 @@ CACHES = {
} }
if LOGIN_URL is None: if LOGIN_URL is None:
LOGIN_URL = APP_ROOT_ENDPOINT + 'accounts/login/' LOGIN_URL = APP_ROOT_ENDPOINT + 'login/'
if LOGOUT_URL is None: if LOGOUT_URL is None:
LOGOUT_URL = APP_ROOT_ENDPOINT + 'accounts/logout/' LOGOUT_URL = APP_ROOT_ENDPOINT + 'logout/'
if LOGIN_REDIRECT_URL is None: if LOGIN_REDIRECT_URL is None:
LOGIN_REDIRECT_URL = APP_ROOT_ENDPOINT LOGIN_REDIRECT_URL = APP_ROOT_ENDPOINT

View file

@ -24,8 +24,8 @@ urlpatterns += i18n_patterns('',
url(r'^digitalglarus/', include('digitalglarus.urls', url(r'^digitalglarus/', include('digitalglarus.urls',
namespace="digitalglarus"),name='digitalglarus'), namespace="digitalglarus"),name='digitalglarus'),
url(r'^blog/',include('ungleich.urls',namespace='ungleich')), url(r'^blog/',include('ungleich.urls',namespace='ungleich')),
url(r'^',include('ungleich_page.urls',namespace='ungleich_page'),name="ungleich_page"),
url(r'^login/',include(membership_urls)), url(r'^login/',include(membership_urls)),
url(r'^$',include('ungleich_page.urls',namespace='ungleich_page'),name="ungleich_page"),
url(r'^', include('cms.urls')), url(r'^', include('cms.urls')),
) )

View file

@ -0,0 +1 @@
__author__ = 'tomislav'

View file

@ -0,0 +1,136 @@
from calendar import month_name, day_abbr
from calendar import Calendar
from membership.models import Calendar as CalendarModel
import datetime
now = datetime.datetime.now()
class CustomCalendar(Calendar):
def __init__(self):
super(CustomCalendar, self).__init__(firstweekday=0)
def itermonthdays(self, year, month):
"""
Like itermonthdates(), but will yield day numbers. For days outside
the specified month the day number.
"""
for date in self.itermonthdates(year, month):
yield date.day
def itermonthdays2(self, year, month):
"""
Like itermonthdates(), but will yield (day number, weekday number)
tuples. For days outside the specified month the day number is 0.
"""
for date in self.itermonthdates(year, month):
yield (date.day, date.weekday(), date.month)
class CustomHTMLCalendar(CustomCalendar):
"""
This calendar returns complete HTML pages.
"""
# CSS classes for the day <td>s
def __init__(self, requested_month):
self.requested_month = requested_month
super(CustomHTMLCalendar, self).__init__()
def formatday(self, day, weekday, month=None,year=None):
"""
Return a day as a table cell.
"""
booked = CalendarModel.objects.filter(user_id=self.user.id)
is_booked= booked.filter(datebooked=datetime.date(day=day,month=month,year=year))
if month < int(self.requested_month):
return '<td class="prev-month %s">%d</td>' % ("selected" if is_booked else "",day)
elif month > int(self.requested_month):
return '<td class="next-month %s">%d</td>' % ("selected" if is_booked else "",day)
else:
return '<td class="%s">%d</td>' % ("selected" if is_booked else "",day)
def formatweek(self, theweek,year):
"""
Return a complete week as a table row.
"""
s = ''.join(self.formatday(d, wd, month,year) for (d, wd, month) in theweek)
return '<tr>%s</tr>' % s
def formatmonthname(self, theyear, themonth, withyear=True):
"""
Return a month name as a table row.
"""
if withyear:
s = '%s %s' % (month_name[themonth], theyear)
else:
s = '%s' % month_name[themonth]
return '<tr><th colspan="7" class="month">%s</th></tr>' % s
def add_before(self):
return '<a class="btn-prev fontawesome-angle-left" href="#"></a>'
def add_after(self):
return '<a class="btn-next fontawesome-angle-right" href="#"></a>'
def formatmonth(self, theyear, themonth, withyear=True):
"""
Return a formatted month as a table.
"""
v = []
a = v.append
a('<table border="0" cellpadding="0" cellspacing="0" class="month">')
a('\n')
a(self.add_before())
a('\n')
a(self.formatmonthname(theyear, themonth, withyear=withyear))
a('\n')
a(self.add_after())
a('\n')
a(self.formatweekheader())
a('\n')
for week in self.monthdays2calendar(theyear, themonth):
a(self.formatweek(week,theyear))
a('\n')
a('</table>')
a('\n')
a('<span id="datesbooked"></span>')
return ''.join(v)
class BookCalendar(CustomHTMLCalendar):
def __init__(self, user,requested_month):
self.user=user
super(BookCalendar, self).__init__(requested_month)
def formatmonth(self, year, month):
self.year, self.month = year, month
return super(BookCalendar, self).formatmonth(year, month)
def day_cell(self, cssclass, body):
return '<td>%s</td>' % body
def formatmonthname(self, theyear, themonth, withyear):
"""
Return a month name as a table row.
"""
s = '%s' % month_name[themonth]
return '<span id="monthtitle">%s</span>' % s
def formatweekday(self, day):
"""
Return a weekday name as a table header.
"""
ret = '<td>%s</td>' % day_abbr[day][0:2]
return ret
def formatweekheader(self):
"""
Return a header for a week as a table row.
"""
s = ''.join(self.formatweekday(i) for i in self.iterweekdays())
return '<thead>%s</thead>' % s

View file

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-04-22 10:02
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('sites', '0002_alter_domain_unique'),
('membership', '0002_auto_20160324_2336'),
]
operations = [
migrations.CreateModel(
name='Calendar',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('datebooked', models.DateField()),
],
),
migrations.AddField(
model_name='customuser',
name='site',
field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='sites.Site'),
),
migrations.AddField(
model_name='calendar',
name='user',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]

View file

@ -1,3 +1,5 @@
from datetime import datetime
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import User, AbstractBaseUser, BaseUserManager, AbstractUser from django.contrib.auth.models import User, AbstractBaseUser, BaseUserManager, AbstractUser
@ -5,6 +7,7 @@ from django.contrib.auth.hashers import make_password
from django.core.mail import send_mail from django.core.mail import send_mail
from django.core.validators import RegexValidator from django.core.validators import RegexValidator
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.contrib.sites.models import Site
REGISTRATION_MESSAGE = {'subject': "Validation mail", REGISTRATION_MESSAGE = {'subject': "Validation mail",
'message': 'Please validate Your account under this link http://localhost:8000/en-us/login/validate/{}', 'message': 'Please validate Your account under this link http://localhost:8000/en-us/login/validate/{}',
@ -43,6 +46,7 @@ class MyUserManager(BaseUserManager):
class CustomUser(AbstractBaseUser): class CustomUser(AbstractBaseUser):
VALIDATED_CHOICES = ((0, 'Not validated'), (1, 'Validated')) VALIDATED_CHOICES = ((0, 'Not validated'), (1, 'Validated'))
site = models.ForeignKey(Site, default=1)
name = models.CharField(max_length=50) name = models.CharField(max_length=50)
email = models.EmailField(unique=True) email = models.EmailField(unique=True)
@ -125,3 +129,24 @@ class CreditCards(models.Model):
'Use this pattern(MM/YYYY).'))]) 'Use this pattern(MM/YYYY).'))])
ccv = models.CharField(max_length=4, validators=[RegexValidator(r'\d{3,4}', _('Wrong CCV number.'))]) ccv = models.CharField(max_length=4, validators=[RegexValidator(r'\d{3,4}', _('Wrong CCV number.'))])
payment_type = models.CharField(max_length=5, default='N') payment_type = models.CharField(max_length=5, default='N')
class Calendar(models.Model):
datebooked = models.DateField()
user = models.ForeignKey(CustomUser)
def __init__(self, *args, **kwargs):
if kwargs.get('datebooked'):
user = kwargs.get('user')
kwargs['datebooked'] = datetime.strptime(kwargs.get('datebooked', ''), '%d,%m,%Y')
self.user_id = user.id
super(Calendar, self).__init__(*args, **kwargs)
@classmethod
def add_dates(cls,dates,user):
old_dates = Calendar.objects.filter(user_id=user.id)
if old_dates:
old_dates.delete()
for date in dates:
Calendar.objects.create(datebooked=date,user=user)

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,168 @@
@charset "utf-8";
/* CSS Document */
/* ---------- FONTAWESOME ---------- */
/* ---------- http://fortawesome.github.com/Font-Awesome/ ---------- */
/* ---------- http://weloveiconfonts.com/ ---------- */
@import url(http://weloveiconfonts.com/api/?family=fontawesome);
*[class*="fontawesome-"]:before {
font-family: 'FontAwesome', sans-serif;
}
/* ---------- GENERAL ---------- */
/*body {*/
/*background: #f9f9f9;*/
/*color: #0e171c;*/
/*font: 300 100%/1em 'Lato', sans-serif;*/
/*margin: 0;*/
/*}*/
/**/
/*a {*/
/*text-decoration: none;*/
/*}*/
/*Month size*/
#monthtitle {
font-size: 1.2em;
line-height: 1.25em;
margin: .25em 0;
font-weight: 600;
}
h3 {
font-size: 1.5em;
line-height: 1em;
margin: .33em 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
margin:auto;
}
/*.container {*/
/*height: 358px;*/
/*left: 50%;*/
/*margin: -255px 0 0 -245px;*/
/*position: absolute;*/
/*top: 50%;*/
/*width: 340px;*/
/*}*/
/* ---------- CALENDAR ---------- */
.calendar {
text-align: center;
}
.calendar header {
position: relative;
}
.calendar #monthtitle {
text-transform: uppercase;
color: #1A6687;
}
#datesbooked{
color:#1a6687;
padding-top: 2px;
}
/*Title*/
.calendar thead {
font-weight: 500;
/*text-transform: uppercase;*/
color: #8BC4C9;
/*margin-bottom:1px;*/
}
/*Body text*/
.calendar tbody {
color: #7c8a95;
}
/*select date*/
.calendar tbody td:hover {
background: #8BC4C9;
color: #f9f9f9;
/*border: .1px solid #8BC4C9;*/
/*border-radius: 50%;*/
}
.selected{
background: #6b9699;
color: #f9f9f9;
}
.calendar thead>tr>td{
border-top:hidden;
border-left:hidden;
border-right: hidden;
}
.calendar td {
border: .1px solid #cbd1d2;
/*border-radius: 50%;*/
display: inline-block;
height: 2.5em;
line-height: 2.5em;
text-align: center;
width: 2.5em;
}
.calendar .prev-month,
.calendar .next-month {
/*border: .1px solid #cbd1d2;*/
color: #cbd1d2;
}
.calendar .prev-month:hover,
.calendar .next-month:hover {
border: .5px solid #cbd1d2;
background: #cbd1d2;
color: #f9f9f9;
}
/*Today*/
.current-day {
color: #8BC4C9;
/*background-color: #8BC4C9;*/
}
/*Next,Prev month*/
.btn-prev,
.btn-next {
border: 1px solid transparent;
color: #8BC4C9;
font-size: 1.5em;
padding: 1em;
/*height: .7em;*/
/*line-height: .3em;*/
/*margin: auto;*/
/*position: absolute;*/
/*top: .1em;*/
/*width: 25em;*/
}
.btn-prev:hover,
.btn-next:hover {
background: none;
color: #1A6687;
}
.btn-prev {
left: 6em;
}
.btn-next {
right: 6em;
}

View file

@ -0,0 +1,112 @@
<script type="text/javascript">
var date = new Date();
var month = date.getMonth() + 1;
var year = date.getFullYear();
var selected_dates = [];
var monthly_selected_dates = [];
$("#myModal").ready(function () {
$.get('/digitalglarus/calendar_api/' + month + '/' + year, function (data) {
$(".calendar").html(data.calendar)
calendar_refresh();
//calendar fields
$(".calendar").on('click', 'td', function () {
if (this.className != 'prev-month' && this.className != 'next-month') {
if ($(this).className == 'selected') {
date_text = this.textContent + "," +//day
(date.getMonth() + 1).toString() + "," +
date.getFullYear().toString();
monthly_selected_dates.splice(monthly_selected_dates.indexOf(date_text), 1);
}
$(this).toggleClass('selected');
}
updateSelectedDates();
})
});
})
</script>
<div class="container">
<div class="calendar">
</div>
<!-- end calendar -->
</div> <!-- end container -->
<script type="text/javascript">
function updateSelectedDates() {
monthly_selected_dates = [];
$("tr>td.selected").each(function () {
date_text = this.textContent + "," +//day
(date.getMonth() + 1).toString() + "," +
date.getFullYear().toString();
if (monthly_selected_dates.indexOf(date_text) == -1)
monthly_selected_dates.push(date_text);
});
console.log("monthly:");
console.log(monthly_selected_dates);
console.log("all:")
console.log(selected_dates);
}
languageCode = $('body').attr('lang')
function updateCurrentSelectedDates() {
$("tbody>tr>td[class='']").each(function (i, el) {
date_text = this.textContent + "," +//day
(date.getMonth() + 1).toString() + "," +
date.getFullYear().toString();
if (selected_dates.indexOf(date_text) != -1) {
$(this).addClass('selected');
}
});
}
function insertUnique() {
selected_dates.push.apply(selected_dates, monthly_selected_dates);
unique = []
$.each(selected_dates, function (i, el) {
if ($.inArray(el, unique) === -1) unique.push(el);
});
selected_dates = unique;
}
function calendar_refresh() {
$("#myModal")
.on('click', 'a.btn-prev,a.btn-next', function () {
if (/btn-prev/i.test(this.className)) {
date.setMonth(date.getMonth() - 1);
} else {
date.setMonth(date.getMonth() + 1)
}
insertUnique();
$.get('/' + languageCode + '/digitalglarus/calendar_api/' + (date.getMonth() + 1) + '/' + date.getFullYear(),
function (data) {
$(".calendar").html(data.calendar);
updateCurrentSelectedDates();
});
})
.on('click', '#bookdate', function () {
insertUnique();
if (selected_dates.length) {
$.ajaxSetup({
beforeSend: function (xhr, settings) {
if (!this.crossDomain) {
xhr.setRequestHeader("X-CSRFToken", '{{ csrf_token }}');
}
}
});
postData = {data: JSON.stringify(selected_dates)}
console.log(postData)
$.post('/' + languageCode + '/digitalglarus/calendar_api/', postData, function (data) {
if (data.status == 'success') {
$('#datesbooked').html("Dates booked!");
setTimeout(function () {
$('#close').click();
location.reload();
}, 800)
}
})
} else {
$('#datesbooked').html("Please select date.");
}
});
}
</script>

View file

@ -36,7 +36,7 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<a class="btn btn-primary" href="{% url 'login' %}">Back</a> <a class="btn btn-primary" href="{% url 'login_glarus' %}">Back</a>
</div> </div>
</div> </div>
<a hrefhelp@digitalglarus.ch<="" p=""> <a hrefhelp@digitalglarus.ch<="" p="">

View file

@ -20,15 +20,15 @@
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
</button> </button>
<a class="navbar-brand" href="#"><span>Brand</span></a> <a class="navbar-brand" href="#"><span>Digital Glarus</span></a>
</div> </div>
<div class="collapse navbar-collapse" id="navbar-ex-collapse"> <div class="collapse navbar-collapse" id="navbar-ex-collapse">
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li class="active"> <li class="active">
<a href="#">Home</a> <a href="{% url 'digitalglarus:index' %}">Home</a>
</li> </li>
<li> <li>
<a href="#">Contacts</a> <a href="{% url 'digitalglarus:contact' %}">Contacts</a>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -1,17 +1,33 @@
<html><head> <html>
<head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> <script type="text/javascript"
<script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> src="http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet" type="text/css"> <script type="text/javascript"
src="http://netdna.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<link href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css"
rel="stylesheet" type="text/css">
{% load static %} {% load static %}
<link href="{% get_static_prefix %}membership.css" rel="stylesheet" type="text/css"> <link href="{% get_static_prefix %}membership.css" rel="stylesheet" type="text/css">
</head><body> <link href="{% get_static_prefix %}stylesheet.css" rel="stylesheet" type="text/css">
</head>
<body lang="{{ language_code }}">
<div class="cover"> <div class="cover">
<div class="navbar"> <div class="navbar">
<div class="pull-right u_P user">
{% if request.user.is_authenticated %}
<div class="user"><i class="fa fa-2x fa-user"
aria-hidden="true"></i>{{ request.user.name }} (<a href="{% url 'logout_glarus' %}">Logout</a>)</div>
{% else %}
<a href="{% url 'login_glarus' %}"> Login </a>
{% endif %}
</div>
<div class="container"> <div class="container">
<div class="navbar-header"> <div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-ex-collapse"> <button type="button" class="navbar-toggle" data-toggle="collapse"
data-target="#navbar-ex-collapse">
<span class="sr-only">Toggle navigation</span> <span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
<span class="icon-bar"></span> <span class="icon-bar"></span>
@ -22,10 +38,14 @@
<div class="collapse navbar-collapse" id="navbar-ex-collapse"> <div class="collapse navbar-collapse" id="navbar-ex-collapse">
<ul class="nav navbar-nav navbar-right"> <ul class="nav navbar-nav navbar-right">
<li class="active"> <li class="active">
<a href="#">Home</a> <a href="{% url 'digitalglarus:index' %}">Home</a>
</li> </li>
<li> <li>
<a href="#">Contacts</a> <a href="{% url 'digitalglarus:contact' %}">Contacts</a>
</li>
<li>
</li> </li>
</ul> </ul>
</div> </div>
@ -33,13 +53,39 @@
</div> </div>
{% load static %} {% load static %}
<div class="cover-image" style="background-image : url('{% get_static_prefix %}photo-1418479631014-8cbf89db3431 2.jpg')"></div> <div class="cover-image"
style="background-image : url('{% get_static_prefix %}photo-1418479631014-8cbf89db3431 2.jpg')"></div>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<h2 class="text-inverse">When do you want to cowork?</h2> <h2 class="text-inverse">When do you want to cowork?</h2>
<p class="text-inverse">Pick a date!</p> <p class="text-inverse">Pick a date!</p>
<a class="btn btn-lg btn-primary">Calender</a> <button class="btn btn-lg btn-primary" data-toggle="modal" data-target="#myModal">Calender
</button>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Pick coworking date.</h4>
</div>
<div class="modal-body">
{% include 'calendar/calendar.html' %}
</div>
<div class="modal-footer">
<button type="button" id="close" class="btn btn-default"
data-dismiss="modal">Close
</button>
<button type="button" id='bookdate' class="btn btn-primary">Book date
</button>
</div>
</div>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -62,11 +108,14 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<img src="https://ununsplash.imgix.net/photo-1423753623104-718aaace6772?w=1024&amp;q=50&amp;fm=jpg&amp;s=1ffa61419561b5c796bca3158e7c704c" class="img-responsive"> <img src="https://ununsplash.imgix.net/photo-1423753623104-718aaace6772?w=1024&amp;q=50&amp;fm=jpg&amp;s=1ffa61419561b5c796bca3158e7c704c"
class="img-responsive">
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<h2 class="text-muted">The Spontaneous</h2> <h2 class="text-muted">The Spontaneous</h2>
<h3>35CHF/Month (1 day pass included)</h3> <h3>35CHF/Month (1 day pass included)</h3>
<p>Do you dream of having a place to be inspired in the middle of the Alps? <p>Do you dream of having a place to be inspired in the middle of the Alps?
With only 35CHF a month, you can enjoy the full benefit of a Digital Chalet With only 35CHF a month, you can enjoy the full benefit of a Digital Chalet
Schwanden membership! You can enjoy high speed network connection and comfortable Schwanden membership! You can enjoy high speed network connection and comfortable
@ -89,7 +138,9 @@
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-6">
<h2 class="text-muted">The Committed</h2> <h2 class="text-muted">The Committed</h2>
<h3>360CHF/Year (2 free day per month included)</h3> <h3>360CHF/Year (2 free day per month included)</h3>
<p>Be a regular coworker in our Digital Chalet Schwanden! With only 360CHF, <p>Be a regular coworker in our Digital Chalet Schwanden! With only 360CHF,
you can enjoy the full coworking space for the whole year, with additional you can enjoy the full coworking space for the whole year, with additional
2 free day passes for each month. It is an ideal deal for our busy and 2 free day passes for each month. It is an ideal deal for our busy and
@ -101,7 +152,8 @@
<a class="btn btn-primary" href="/login/buy/year/">Buy Now</a> <a class="btn btn-primary" href="/login/buy/year/">Buy Now</a>
</div> </div>
<div class="col-md-6"> <div class="col-md-6">
<img src="https://unsplash.imgix.net/photo-1413834932717-29e7d4714192?w=1024&amp;q=50&amp;fm=jpg&amp;s=d9d6cbc32dd4968d0c21e331436a6af6" class="img-responsive"> <img src="https://unsplash.imgix.net/photo-1413834932717-29e7d4714192?w=1024&amp;q=50&amp;fm=jpg&amp;s=d9d6cbc32dd4968d0c21e331436a6af6"
class="img-responsive">
</div> </div>
</div> </div>
</div> </div>
@ -111,6 +163,7 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<h2 class="text-center text-primary">A Quick Glance..</h2> <h2 class="text-center text-primary">A Quick Glance..</h2>
<p class="text-center">A short guide for membership features.</p> <p class="text-center">A short guide for membership features.</p>
</div> </div>
</div> </div>
@ -161,6 +214,7 @@
<div class="row"> <div class="row">
<div class="col-sm-6"> <div class="col-sm-6">
<h1>Digital Glarus</h1> <h1>Digital Glarus</h1>
<p>In der Au 7 8762 Schwanden <p>In der Au 7 8762 Schwanden
<br>Copyright © ungleich GmbH 2016</p> <br>Copyright © ungleich GmbH 2016</p>
</div> </div>
@ -169,6 +223,7 @@
<br> <br>
<br> <br>
</p> </p>
<div class="row"> <div class="row">
<div class="col-md-12 hidden-lg hidden-md hidden-sm text-left"> <div class="col-md-12 hidden-lg hidden-md hidden-sm text-left">
<a href="#"><i class="fa fa-3x fa-fw fa-instagram text-inverse"></i></a> <a href="#"><i class="fa fa-3x fa-fw fa-instagram text-inverse"></i></a>
@ -193,4 +248,5 @@
</footer> </footer>
</body></html> </body>
</html>

View file

@ -19,7 +19,7 @@
<br>Check your email to activate your account.</p> <br>Check your email to activate your account.</p>
<div class="row"> <div class="row">
<div class="col-md-12 text-center"> <div class="col-md-12 text-center">
<a class="btn btn-primary" href="{% url 'login' %}">Back</a> <a class="btn btn-primary" href="{% url 'login_glarus' %}">Back</a>
</div> </div>
</div> </div>
</div> </div>

View file

@ -5,9 +5,10 @@ from django.contrib.auth.decorators import login_required
from . import views from . import views
urlpatterns = ( urlpatterns = (
url(r"^$", views.LoginRegistrationView.as_view(), name='login'), url(r"^$", views.LoginRegistrationView.as_view(), name='login_glarus'),
url(r"^validate/(?P<validate_slug>.*)/$", views.validate_email), url(r"^validate/(?P<validate_slug>.*)/$", views.validate_email),
url(r"^membership/$", login_required(views.MembershipView.as_view()), name='membership'), url(r"^membership/$", login_required(views.MembershipView.as_view()), name='membership'),
url(r'logout/?$',views.logout_glarus,name='logout_glarus'),
url(r"^buy/(?P<time>\w+)/$", login_required(views.CreditCardView.as_view()), name='payment'), url(r"^buy/(?P<time>\w+)/$", login_required(views.CreditCardView.as_view()), name='payment'),
url(r'^buy/(?P<time>\w+)/reset',login_required(views.reset),name='reset') url(r'^buy/(?P<time>\w+)/reset',login_required(views.reset),name='reset')
) )

View file

@ -4,6 +4,10 @@ from django.contrib.auth import authenticate, login
from django.views.decorators.cache import cache_control from django.views.decorators.cache import cache_control
from django.conf import settings from django.conf import settings
from django.db.models import Q from django.db.models import Q
from django.utils.translation import get_language
from django.contrib.auth import logout
from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse_lazy,reverse
from .models import CustomUser from .models import CustomUser
from .forms import (LoginForm, RegisterForm, PaymentForm) from .forms import (LoginForm, RegisterForm, PaymentForm)
@ -105,9 +109,14 @@ class LoginRegistrationView(View):
class MembershipView(View): class MembershipView(View):
def get(self, request): def get(self, request):
#if the user has payed allready #if the user has payed already
member_payed = request.user.creditcards_set.filter(Q(payment_type='month') | Q(payment_type='year')) member_payed = request.user.creditcards_set.filter(Q(payment_type='month') | Q(payment_type='year'))
if member_payed: if member_payed:
return redirect('/') return redirect('/')
request.session['next'] = 0 request.session['next'] = 0
return render(request, 'templates/membership.html') language = get_language()
return render(request, 'templates/membership.html',context={'language_code':language})
def logout_glarus(request):
logout(request)
return HttpResponseRedirect('/digitalglarus')