Ejemplo n.º 1
0
def create_project_status(request, project_id):
    project = get_object_or_404(Project, id=project_id)
    if project.category == Project.CHALLENGE:
        url = reverse('projects_discussion_area',
                      kwargs=dict(slug=project.slug))
    else:
        url = project.get_absolute_url()
    if request.method != 'POST' or 'status' not in request.POST:
        return HttpResponseRedirect(url)
    if not project.is_participating(request.user):
        return HttpResponseRedirect(url)
    if project.is_organizing(request.user):
        form = ImportantStatusForm(data=request.POST)
    else:
        form = StatusForm(data=request.POST)
    if form.is_valid():
        status = form.save(commit=False)
        status.author = request.user.get_profile()
        status.project = project
        status.save()
        log.debug("Saved status by user (%d) to study group (%d): %s" %
                  (status.author.id, project.id, status))
    else:
        log.debug("form error: %s" % (str(form.errors)))
        messages.error(request,
                       _('There was an error posting '
                         'your status update'))
    return HttpResponseRedirect(url)
Ejemplo n.º 2
0
def create_project_status(request, project_id):
    project = get_object_or_404(Project, id=project_id)
    if project.category == Project.CHALLENGE:
        url = reverse('projects_discussion_area',
            kwargs=dict(slug=project.slug))
    else:
        url = project.get_absolute_url()
    if request.method != 'POST' or 'status' not in request.POST:
        return HttpResponseRedirect(url)
    if not project.is_participating(request.user):
        return HttpResponseRedirect(url)
    if project.is_organizing(request.user):
        form = ImportantStatusForm(data=request.POST)
    else:
        form = StatusForm(data=request.POST)
    if form.is_valid():
        status = form.save(commit=False)
        status.author = request.user.get_profile()
        status.project = project
        status.save()
        log.debug("Saved status by user (%d) to study group (%d): %s" % (
        status.author.id, project.id, status))
    else:
        log.debug("form error: %s" % (str(form.errors)))
        messages.error(request, _('There was an error posting '
                                  'your status update'))
    return HttpResponseRedirect(url)
Ejemplo n.º 3
0
def create_project_status(request, project_id):
    if request.method != 'POST' or 'status' not in request.POST:
        return HttpResponseRedirect(reverse('dashboard_index'))
    project = get_object_or_404(Project, id=project_id)
    profile = request.user.get_profile()
    if profile != project.created_by and not profile.user.is_superuser \
            and not project.participants().filter(user=profile).exists():
        return HttpResponseRedirect(reverse('dashboard_index'))
    if profile == project.created_by or profile.user.is_superuser:
        form = ImportantStatusForm(data=request.POST)
    else:
        form = StatusForm(data=request.POST)
    if form.is_valid():
        status = form.save(commit=False)
        status.author = request.user.get_profile()
        status.project = project
        status.save()
        log.debug("Saved status by user (%d) to study group (%d): %s" % (
        profile.id, project.id, status))
    else:
        log.debug("form error: %s" % (str(form.errors)))
        messages.error(request, _('There was an error posting '
                                  'your status update'))
    return HttpResponseRedirect(
        reverse('projects_show', kwargs=dict(slug=project.slug)))
Ejemplo n.º 4
0
def create_project_status(request, project_id):
    project = get_object_or_404(Project, id=project_id)
    if request.method != "POST" or "status" not in request.POST:
        return HttpResponseRedirect(project.get_absolute_url())
    if not project.is_participating(request.user):
        return HttpResponseRedirect(project.get_absolute_url())
    if project.is_organizing(request.user):
        form = ImportantStatusForm(data=request.POST)
    else:
        form = StatusForm(data=request.POST)
    if form.is_valid():
        status = form.save(commit=False)
        status.author = request.user.get_profile()
        status.project = project
        status.save()
        log.debug("Saved status by user (%d) to study group (%d): %s" % (status.author.id, project.id, status))
    else:
        log.debug("form error: %s" % (str(form.errors)))
        messages.error(request, _("There was an error posting " "your status update"))
    return HttpResponseRedirect(reverse("projects_show", kwargs=dict(slug=project.slug)))