示例#1
0
def blog(request):
    archives = Comic.archives()
    blogs = []
    for comic in archives:
        for blog_post in comic.blog_posts:
            blogs.append(blog_post)
    return render(request, "comics/blog.html", {'blogs':blogs})
示例#2
0
def page(request, slug):
    # this is redundant but I just want to make sure
    slug = slugify(slug)

    try:
        return render(request, "pages/"+slug+".html")
    except TemplateDoesNotExist:
        raise Http404("Page not found!")
示例#3
0
def manage_tag(request, slug):
    backlog = Comic.backlog().filter(tags__contains=[slug])
    archives = Comic.archives().filter(tags__contains=[slug])
    tags = Comic.all_tags()
    return render(request, "comics/manage.html", {
        'tags': tags,
        'active_tag': slug,
        'backlog': backlog,
        'archives': archives})
示例#4
0
def manage(request):
    backlog = Comic.backlog()
    archives = Comic.archives()
    hero = Comic.hero()
    tags = Comic.all_tags()
    return render(request, "comics/manage.html", {
        'tags': tags,
        'backlog': backlog,
        'archives': archives,
        'hero': hero})
示例#5
0
def search(request):
    try:
        search_term = request.GET['search']
    except KeyError:
        return HttpResponseRedirect(reverse("comics.views.archives"))
    comics = Comic.objects.search(search_term).filter(hidden=False)
    tags = Comic.all_tags()
    return render(request, "comics/archives.html", {'comics':comics,
                                                    'search_term': search_term,
                                                    'tags': tags})
示例#6
0
def manage_event(request, event_slug):
    event = get_object_or_404(Event, slug=event_slug)
    locations = event.locationandtime_set.all().order_by('start_datetime')
    invitations = event.invitation_set.all().order_by('status', 'title')
    questions = event.question_set.all()
    return render(request,
                  'events/manage_event.html',
                  {'event': event,
                   'locations':locations,
                   'invitations':invitations,
                   'questions':questions})
示例#7
0
def single(request, comic_slug):
    comic = get_object_or_404(Comic, slug=comic_slug)
    if comic.hidden:
        raise Http404("For whatever reason, I've removed this comic from circulation.")
    if timezone.now() < comic.posted:
        raise Http404("This comic hasn't been posted yet!")
    permalink = _permalink(request, comic_slug)
    return render(request, "comics/single.html", {'preview': False,
                                                  'slug': comic_slug,
                                                  'permalink': permalink,
                                                  'comic': comic})
示例#8
0
def create(request):
    now = datetime.datetime.now()
    if request.method == 'POST':
        form = ComicForm(request.POST)
        if form.is_valid():
            form.save()
            messages.add_message(request, messages.SUCCESS, 'Comic Created!')
            return HttpResponseRedirect(reverse("comics.views.manage"))
    else:
        form = ComicForm(initial={'posted':now})

    return render(request, 'comics/create.html', {'form': form})
示例#9
0
def create_event(request):
    if request.method == 'POST':
        form = EventForm(request.POST)
        if form.is_valid():
            event = form.save(commit=False)
            event.owner = request.user
            event.save()
            messages.add_message(request, messages.SUCCESS, 'Event Created!')
            return HttpResponseRedirect(reverse(manage_event, kwargs={'event_slug':event.slug}))
    else:
        form = EventForm()
    return render(request, 'events/create_event.html', {'form': form})
示例#10
0
def create_image(request, comic_slug):
    comic = get_object_or_404(Comic, slug=comic_slug)
    if request.method == 'POST':
        form = ImageForm(request.POST)
        if form.is_valid():
            form.save()
            messages.add_message(request, messages.SUCCESS, 'Image Created!')
            return HttpResponseRedirect(reverse("comics.views.manage"))
    else:
        form = ImageForm(initial={'comic':comic})

    return render(request, 'comics/create_image.html', {'form': form, 'comic_slug': comic_slug})
示例#11
0
def update_event(request, event_slug):
    event = get_object_or_404(Event, slug=event_slug)
    if request.method == 'POST':
        form = EditEventForm(request.POST, instance=event)
        if form.is_valid():
            form.save()
            messages.add_message(request, messages.SUCCESS, 'Event Updated!')
            return HttpResponseRedirect(reverse(manage_event, kwargs={'event_slug':event.slug}))
    else:
        form = EditEventForm(instance=event)

    return render(request, 'events/update_event.html', {'form': form, 'event':event})
示例#12
0
def update(request, comic_slug):
    comic = get_object_or_404(Comic, slug=comic_slug)
    print("Updating comic!")
    if request.method == 'POST':
        form = ComicForm(request.POST, instance=comic)
        if form.is_valid():
            form.save()
            messages.add_message(request, messages.SUCCESS, 'Comic Updated!')
            return HttpResponseRedirect(reverse("comics.views.manage"))
    else:
        form = ComicForm(instance=comic)

    return render(request, 'comics/update.html', {'form': form, 'slug': comic_slug, 'comic':comic})
示例#13
0
def update_blog(request, comic_slug, slug):
    blog = get_object_or_404(Blog, comic__slug=comic_slug, slug=slug)
    print("Blog {} Updated".format(blog))
    if request.method == 'POST':
        form = BlogForm(request.POST, instance=blog)
        if form.is_valid():
            form.save()
            messages.add_message(request, messages.SUCCESS, 'Blog Updated!')
            return HttpResponseRedirect(reverse("comics.views.manage"))
    else:
        form = BlogForm(instance=blog)

    return render(request, 'comics/update_blog.html', {'form': form, 'comic_slug': comic_slug, 'slug': slug})
示例#14
0
def update_video(request, comic_slug, slug):
    video = get_object_or_404(Video, comic__slug=comic_slug, slug=slug)
    print("Video {} Updated".format(video))
    if request.method == 'POST':
        form = VideoForm(request.POST, instance=video)
        if form.is_valid():
            form.save()
            messages.add_message(request, messages.SUCCESS, 'Video Updated!')
            return HttpResponseRedirect(reverse("comics.views.manage"))
    else:
        form = VideoForm(instance=video)

    return render(request, 'comics/update_video.html', {'form': form, 'comic_slug': comic_slug, 'slug': slug})
示例#15
0
def update_image(request, comic_slug, slug):
    image = get_object_or_404(Image, comic__slug=comic_slug, slug=slug)
    print("Image {} Updated".format(image))
    if request.method == 'POST':
        form = ImageForm(request.POST, instance=image)
        if form.is_valid():
            form.save()
            messages.add_message(request, messages.SUCCESS, 'Image Updated!')
            return HttpResponseRedirect(reverse("comics.views.manage"))
    else:
        form = ImageForm(instance=image)

    return render(request, 'comics/update_image.html', {'form': form, 'comic_slug': comic_slug, 'slug': slug})
示例#16
0
def create_location(request, event_slug):
    event = get_object_or_404(Event, slug=event_slug)
    if request.method == 'POST':
        form = LocationAndTimeForm(request.POST)
        if form.is_valid():
            loc = form.save(commit=False)
            loc.event = event
            loc.save()
            messages.add_message(request, messages.SUCCESS, 'Location Created!')
            return HttpResponseRedirect(reverse(manage_event, kwargs={'event_slug':event.slug}))
    else:
        form = LocationAndTimeForm()

    return render(request, 'events/create_location.html', {'form': form, 'event': event})
示例#17
0
def home(request):
    hero = Comic.hero()
    if not hero:
        c = Comic(title="Hello World",
                  image_url="http://curtis.lassam.net/comics/cube_drone/misc_assets/mail.png",
                  posted = timezone.now(),
                  published = True,
                  secret_text = "There aren't any comics on this site, yet!")
        c.save()
        hero = Comic.hero()
    permalink = _permalink(request, hero.slug)
    return render(request,
                  "comics/single.html",
                  {'slug': hero.slug,
                   'permalink': permalink,
                   'comic':hero})
示例#18
0
def update_invitation(request, event_slug, invitation_slug):
    event = get_object_or_404(Event, slug=event_slug)
    invitation = get_object_or_404(Invitation, slug=invitation_slug)

    if request.method == 'POST':
        form = getInvitationForm(event)(request.POST, instance=invitation)
        if form.is_valid():
            form.save()
            messages.add_message(request, messages.SUCCESS, 'Invitation Updated!')
            return HttpResponseRedirect(reverse(manage_event, kwargs={'event_slug':event.slug}))
    else:
        form = getInvitationForm(event)(instance=invitation)

    return render(request,
                  'events/update_invitation.html',
                  {'form': form,
                   'event':event,
                   'invitation':invitation})
示例#19
0
def update_location(request, event_slug, location_slug):
    event = get_object_or_404(Event, slug=event_slug)
    location = get_object_or_404(LocationAndTime, slug=location_slug)

    if request.method == 'POST':
        form = LocationAndTimeForm(request.POST, instance=location)
        if form.is_valid():
            form.save()
            messages.add_message(request, messages.SUCCESS, 'Location Updated!')
            return HttpResponseRedirect(reverse(manage_event, kwargs={'event_slug':event.slug}))
    else:
        form = LocationAndTimeForm(instance=location)

    return render(request,
                  'events/update_location.html',
                  {'form': form,
                   'event':event,
                   'location':location})
示例#20
0
def trash(request):
    trash = Comic.trash()
    return render(request, "comics/manage_trash.html", {
        'trash': trash,
    })
示例#21
0
def archives(request):
    archives = Comic.archives()
    tags = Comic.all_tags()
    return render(request, "comics/archives.html", {'comics': archives,
                                                    'tags': tags})
示例#22
0
def preview(request, comic_slug):
    comic = get_object_or_404(Comic, slug=comic_slug)
    return render(request, "comics/single.html", {'preview': True,
                                                  'slug': comic_slug,
                                                  'comic': comic})
示例#23
0
def tag(request, slug):
    archives = Comic.archives().filter(tags__contains=[slug])
    tags = Comic.all_tags()
    return render(request, "comics/archives.html", {'comics': archives,
                                                    'active_tag': slug,
                                                    'tags': tags})
示例#24
0
def home(request):
    events = Event.objects.filter(hidden=False)
    return render(request, "events/home.html", {'events':events})
示例#25
0
def view_event(request, event_slug):
    event = get_object_or_404(Event, slug=event_slug)
    dashboard = {'page_title': event.title, 'site_title': event.title}
    return render(request,
                  "events/view_event.html",
                  {'event':event, 'dashboard':dashboard})
示例#26
0
def manage(request):
    my_events = Event.objects.filter(owner__username=request.user)
    return render(request,
                  "events/manage.html",
                  {'events':my_events})