示例#1
0
def edit_comment(request, comment_id):
    comment = get_object_or_404(EventComment, id=comment_id)
    if (
        not request.user.profile.can_edit_event(comment.event)
        and request.user.profile.id != comment.author.id
    ):
        messages.add_message(
            request,
            messages.WARNING,
            message=_("You can not edit a comment that is not yours."),
        )
        return redirect(comment.event.get_absolute_url())

    if request.method == "POST":
        comment_form = EventCommentForm(request.POST, instance=comment)
        if comment_form.is_valid():
            comment_form.save()
            return redirect(
                comment.event.get_absolute_url() + "#comment-%s" % comment.id
            )
        else:
            messages.add_message(
                request, messages.ERROR, message=_("Error updating comment.")
            )

    return redirect(comment.event.get_absolute_url())
示例#2
0
    def post(self, request, *args, **kwargs):
        self.comment_obj = get_object_or_404(Comment, id=request.POST.get("commentid"))
        if request.user == self.comment_obj.commented_by:
            form = EventCommentForm(request.POST, instance=self.comment_obj)
            if form.is_valid():
                return self.form_valid(form)

            return self.form_invalid(form)

        data = {"error": "You don't have permission to edit this comment."}
        return JsonResponse(data)
示例#3
0
def comment_event(request, event_id):
    event = Event.objects.get(id=event_id)
    if request.user.is_anonymous:
        messages.add_message(request, messages.WARNING, message=_("You must be logged in to comment."))
        return redirect(event.get_absolute_url())

    if request.method == 'POST':
        new_comment = EventComment(author=request.user.profile, event=event)
        comment_form = EventCommentForm(request.POST, instance=new_comment)
        if comment_form.is_valid():
            new_comment = comment_form.save()
            send_comment_emails(new_comment)
            return redirect(event.get_absolute_url()+'#comment-%s'%new_comment.id)

    return redirect(event.get_absolute_url())
示例#4
0
def show_event(request, event_id, event_slug):
    event = get_object_or_404(Event, id=event_id)
    comment_form = EventCommentForm()
    context = {
        'team':
        event.team,
        'event':
        event,
        'comment_form':
        comment_form,
        'sponsor_count':
        event.sponsors.count(),
        'sponsor_list':
        event.sponsors.all(),
        'is_attending':
        request.user.profile in event.attendees.all(),
        'attendee_list':
        Attendee.objects.filter(event=event).order_by('-status'),
        'attendee_count':
        Attendee.objects.filter(event=event, status=Attendee.YES).count(),
        'presentation_list':
        event.presentations.filter(
            status=Presentation.ACCEPTED).order_by('start_time'),
        'pending_presentations':
        event.presentations.filter(status=Presentation.PROPOSED).count(),
        'can_edit_event':
        request.user.profile.can_edit_event(event),
        'can_edit_team':
        request.user.profile.can_edit_team(event.team),
        'is_email_confirmed':
        request.user.account.is_email_confirmed,
    }
    return render(request, 'get_together/events/show_event.html', context)
示例#5
0
def show_event(request, event_id, event_slug):
    event = get_object_or_404(Event, id=event_id)
    comment_form = EventCommentForm()
    context = {
        "team":
        event.team,
        "event":
        event,
        "comment_form":
        comment_form,
        "sponsor_count":
        event.sponsors.count(),
        "sponsor_list":
        event.sponsors.all(),
        "is_attending":
        request.user.profile in event.attendees.all(),
        "attendee_list":
        Attendee.objects.filter(event=event).order_by("-role", "-status"),
        "attendee_count":
        Attendee.objects.filter(event=event, status=Attendee.YES).count(),
        "presentation_list":
        event.presentations.filter(
            status=Presentation.ACCEPTED).order_by("start_time"),
        "pending_presentations":
        event.presentations.filter(status=Presentation.PROPOSED).count(),
        "can_edit_event":
        request.user.profile.can_edit_event(event),
        "can_edit_team":
        request.user.profile.can_edit_team(event.team),
        "is_in_team":
        request.user.profile.is_in_team(event.team),
        "is_email_confirmed":
        request.user.account.is_email_confirmed,
    }
    return render(request, "get_together/events/show_event.html", context)
示例#6
0
def show_event(request, event_id, event_slug):
    event = Event.objects.get(id=event_id)
    comment_form = EventCommentForm()
    context = {
        'team': event.team,
        'event': event,
        'comment_form': comment_form,
        'is_attending': request.user.profile in event.attendees.all(),
        'attendee_list': Attendee.objects.filter(event=event),
        'can_edit_event': request.user.profile.can_edit_event(event),
    }
    return render(request, 'get_together/events/show_event.html', context)