コード例 #1
0
 def test_occurrences_after(self):
     eml = EventListManager([self.event1, self.event2])
     occurrences = eml.occurrences_after(datetime.datetime(2009, 4, 1, 0, 0, tzinfo=self.default_tzinfo))
     self.assertEqual(next(occurrences).event, self.event1)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event1)
     occurrences = eml.occurrences_after()
     self.assertEqual(list(occurrences), [])
コード例 #2
0
 def test_occurrences_after(self):
     eml = EventListManager([self.event1, self.event2])
     occurrences = eml.occurrences_after(
         datetime.datetime(2009, 4, 1, 0, 0, tzinfo=self.default_tzinfo))
     self.assertEqual(next(occurrences).event, self.event1)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event2)
     self.assertEqual(next(occurrences).event, self.event1)
     occurrences = eml.occurrences_after()
     self.assertEqual(list(occurrences), [])
コード例 #3
0
def index(request):
    if request.method == 'POST':
        try:
            email = forms.EmailField().clean(request.POST['email'])
            news_email = NewsletterEmail(email=email)
            news_email.save()
        except KeyError:
            messages.error(request, 'Uh oh')
        except ValidationError:
            messages.error(request, 'Invalid email format!')
        except IntegrityError:
            messages.error(request, 'Email already signed up!')
        else:
            messages.success(request,
                             'Woo ho, your email was submitted succesfully!')
            # Add user to the mailing list
            try:
                send_mail('',
                          'add csclub %s' % email,
                          '*****@*****.**', ['*****@*****.**'],
                          fail_silently=False)
            except SMTPException:
                FailedSignup(failed_email=email).save()
        finally:
            response = HttpResponseRedirect(reverse('index'))
            return response
    eventManager = EventListManager(Event.objects.all())
    context = {
        'upcoming_occurences':
        itertools.islice(eventManager.occurrences_after(timezone.now()), 3),
        'carousel':
        Carousel.objects.all()
    }
    response = render(request, 'dcsc_website/index.html', context)
    return response
コード例 #4
0
 def test_occurrences_after(self):
     eml = EventListManager([self.event1, self.event2])
     occurrences = eml.occurrences_after(datetime.datetime(2009, 4, 1, 0, 0))
     self.assertEqual(occurrences.next().event, self.event1)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event1)
コード例 #5
0
 def test_occurrences_after(self):
     eml = EventListManager([self.event1, self.event2])
     occurrences = eml.occurrences_after(datetime.datetime(2009,4,1,0,0))
     self.assertEqual(occurrences.next().event, self.event1)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event2)
     self.assertEqual(occurrences.next().event, self.event1)
コード例 #6
0
ファイル: views.py プロジェクト: abpoms/DCSC-Website
def index(request):
    if request.method == 'POST':
        try:
            email = forms.EmailField().clean(request.POST['email'])
            news_email = NewsletterEmail(email=email)
            news_email.save()
        except KeyError:
            messages.error(request, 'Uh oh')
        except ValidationError:
            messages.error(request, 'Invalid email format!')
        except IntegrityError:
            messages.error(request, 'Email already signed up!')
        else:
            messages.success(
                request,
                'Woo ho, your email was submitted succesfully!')
            # Add user to the mailing list
            try:
                send_mail('',
                          'add csclub %s' % email,
                          '*****@*****.**',
                          ['*****@*****.**'],
                          fail_silently=False)
            except SMTPException:
                FailedSignup(failed_email=email).save()
        finally:
            response = HttpResponseRedirect(reverse('index'))
            return response
    eventManager = EventListManager(Event.objects.all())
    context = {
        'upcoming_occurences': itertools.islice(
            eventManager.occurrences_after(timezone.now()),
            3),
        'carousel': Carousel.objects.all()
    }
    response = render(request, 'dcsc_website/index.html', context)
    return response