Skip to content

Commit

Permalink
* możliwość przejścia do panelu redagowania z każdej strony serwisu, …
Browse files Browse the repository at this point in the history
…gdzie

  tylko ma to sens (jednostki, autorzy, artykuły, wydziały),

* kosmetyczne poprawki wyświetla raportów
  • Loading branch information
mpasternak committed Nov 14, 2017
1 parent 1e96bbf commit 4dccf78
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 9 deletions.
9 changes: 9 additions & 0 deletions HISTORY.rst
Expand Up @@ -2,6 +2,15 @@
Historia zmian
==============

0.11.109 (2017-11-14)
---------------------

* możliwość przejścia do panelu redagowania z każdej strony serwisu, gdzie
tylko ma to sens (jednostki, autorzy, artykuły, wydziały),

* kosmetyczne poprawki wyświetla raportów


0.11.107 (2017-11-12)
---------------------

Expand Down
2 changes: 1 addition & 1 deletion src/bpp/templates/browse/autor.html
Expand Up @@ -12,7 +12,7 @@

{% block content %}
<h1>{{ autor }}</h1>
{% include "browse/edit_if_logged_in.html" with url="admin:bpp_autor_change" pk=autor.pk %}
{% include "browse/go_to_admin_change.html" with url="admin:bpp_autor_change" pk=autor.pk group="wprowadzanie danych" %}

{% if autor.praca_doktorska %}
<p>
Expand Down
1 change: 1 addition & 0 deletions src/bpp/templates/browse/autorzy.html
Expand Up @@ -21,6 +21,7 @@
{% block content %}
{% url "bpp:browse_autorzy" as browse_autorzy %}
{% include "browse/literki.html" with pierwszy_tab="wszyscy" url=browse_autorzy %}
{% include "browse/go_to_admin_list.html" with url="admin:bpp_autor_changelist" group="wprowadzanie danych" text="wyświetl w module redagowania" %}

{% url "bpp:browse_autorzy" as browse_autorzy %}

Expand Down
5 changes: 5 additions & 0 deletions src/bpp/templates/browse/go_to_admin_change.html
@@ -0,0 +1,5 @@
{% load user_in_group %}{% if request.user.is_superuser or request.user|has_group:group %}
<div class="panel hide-on-print">
<a target="_blank" href="{% url url pk %}">{{ text|default:"otwórz do edycji" }}</a>
</div>
{% endif %}
5 changes: 5 additions & 0 deletions src/bpp/templates/browse/go_to_admin_list.html
@@ -0,0 +1,5 @@
{% load user_in_group %}{% if request.user.is_superuser or request.user|has_group:group %}
<div class="panel hide-on-print">
<a target="_blank" href="{% url url %}">{{ text|default:"pokaż w module redagowania" }}</a>
</div>
{% endif %}
2 changes: 1 addition & 1 deletion src/bpp/templates/browse/jednostka.html
Expand Up @@ -15,7 +15,7 @@

{% block content %}
<h1>{{ jednostka }}</h1>
{% include "browse/edit_if_logged_in.html" with url="admin:bpp_jednostka_change" pk=jednostka.pk %}
{% include "browse/go_to_admin_change.html" with url="admin:bpp_jednostka_change" pk=jednostka.pk group="struktura" %}

{# <h2><a href="{% url "bpp:browse_wydzial" jednostka.wydzial.slug %}">#}
{# {{ jednostka.wydzial }}</a></h2>#}
Expand Down
1 change: 1 addition & 0 deletions src/bpp/templates/browse/jednostki.html
Expand Up @@ -16,6 +16,7 @@
{% block content %}
{% url "bpp:browse_jednostki" as browse_jednostki %}
{% include "browse/literki.html" with pierwszy_tab="wszystkie" url=browse_jednostki %}
{% include "browse/go_to_admin_list.html" with url="admin:bpp_jednostka_changelist" group="struktura" text="wyświetl w module redagowania" %}

{% url "bpp:browse_jednostki" as browse_jednostki %}

Expand Down
5 changes: 3 additions & 2 deletions src/bpp/templates/browse/praca.html
Expand Up @@ -9,15 +9,16 @@
{% block breadcrumbs %}
{{ block.super }}
<li><a href="{% url "multiseek:index" %}">Wyszukiwanie</a></li>
<li class="current">{{ rekord.tytul_oryginalny|truncatewords:10|safe|close_tags}}</li>
<li class="current">{{ rekord.tytul_oryginalny|truncatewords:10|close_tags|safe}}</li>
{% endblock %}


{% block content %}
{% include "browse/praca_tabela.html" with praca=rekord.original links="normal"%}

{% with rekord as r %}
{% include "browse/edit_if_logged_in.html" with url="admin:"|add:r.content_type.app_label|add:"_"|add:r.content_type.model|add:"_change" pk=r.object_id %}
{% include "browse/go_to_admin_change.html" with url="admin:"|add:r.content_type.app_label|add:"_"|add:r.content_type.model|add:"_change" pk=r.object_id group="wprowadzanie danych" %}
{% include "browse/go_to_admin_list.html" with url="admin:"|add:r.content_type.app_label|add:"_"|add:r.content_type.model|add:"_add" pk=r.object_id group="wprowadzanie danych" text="dodaj nowy rekord" %}
{% endwith %}

{% endblock %}
9 changes: 7 additions & 2 deletions src/bpp/templates/browse/uczelnia.html
@@ -1,4 +1,5 @@
{% extends "base.html" %}
{% load user_in_group %}

{% block extratitle %}
Uczelnia
Expand All @@ -16,14 +17,17 @@
{% if article %}
<div class="small-12 large-6 column">
<h2>{{ article.title }}</h2>
{% include "browse/go_to_admin_change.html" with group="web" url="admin:miniblog_article_change" pk=article.pk text="otwórz do edycji" %}
<p>opublikowano {{ article.published_on|naturalday }}</p>
<p>{{ article.article_body.content|safe }}</p>
<a href="..">wstecz</a>
</div>
{% else %}
{% if miniblog.exists %}
{% if miniblog.exists or request.user.is_superuser or request.user|has_group:"web" %}
<div class="small-12 large-6 column">
<h2>Aktualności</h2>
{% include "browse/go_to_admin_list.html" with group="web" url="admin:miniblog_article_changelist" %}
{% include "browse/go_to_admin_list.html" with group="web" url="admin:miniblog_article_add" text="dodaj artykuł" %}
{% for article in miniblog %}
<h3><strong>{{ article.title }}</strong></h3>
<p>
Expand All @@ -43,7 +47,8 @@ <h3><strong>{{ article.title }}</strong></h3>
<div class="small-12 large-6 column">

<h2>Wybierz wydział</h2>
{% include "browse/edit_if_logged_in.html" with url="admin:bpp_uczelnia_change" pk=uczelnia.pk %}
{% include "browse/go_to_admin_list.html" with group="struktura" url="admin:bpp_wydzial_changelist" %}
{% include "browse/go_to_admin_change.html" with url="admin:bpp_uczelnia_change" pk=uczelnia.pk group="struktura" text="ustawienia dla Uczelni" %}
<ul class="no-bullet" style="line-height: 250%;">
{% for wydzial in uczelnia.wydzialy %}
<li>
Expand Down
2 changes: 1 addition & 1 deletion src/bpp/templates/browse/wydzial.html
Expand Up @@ -13,7 +13,7 @@

{% block content %}
<h1>{{ wydzial }}</h1>
{% include "browse/edit_if_logged_in.html" with url="admin:bpp_wydzial_change" pk=wydzial.pk %}
{% include "browse/go_to_admin_change.html" with url="admin:bpp_wydzial_change" pk=wydzial.pk group="struktura" %}
{# <h2><a href="{% url "bpp:browse_uczelnia" wydzial.uczelnia.slug %}">#}
{# {{ wydzial.uczelnia }}#}
{# </a></h2>#}
Expand Down
1 change: 1 addition & 0 deletions src/bpp/templates/browse/zrodla.html
Expand Up @@ -18,6 +18,7 @@
{% block content %}
{% url "bpp:browse_zrodla" as browse_zrodla %}
{% include "browse/literki.html" with pierwszy_tab="wszystkie" url=browse_zrodla %}
{% include "browse/go_to_admin_list.html" with url="admin:bpp_zrodlo_changelist" group="wprowadzanie danych" text="wyświetl w module redagowania" %}

{% url "bpp:browse_zrodlo" as browse_zrodlo %}

Expand Down
3 changes: 2 additions & 1 deletion src/bpp/templates/browse/zrodlo.html
Expand Up @@ -12,7 +12,8 @@

{% block content %}
<h1>{{ zrodlo.nazwa }}</h1>
{% include "browse/edit_if_logged_in.html" with url="admin:bpp_zrodlo_change" pk=zrodlo.pk %}
{% include "browse/go_to_admin_change.html" with url="admin:bpp_zrodlo_change" pk=zrodlo.pk group="wprowadzanie danych" %}
{% include "browse/go_to_admin_list.html" with url="admin:bpp_zrodlo_add" group="wprowadzanie danych" text="dodaj nowy rekord" %}

<form method="post"
action="{% url "bpp:browse_build_search" %}" class="browserForm">
Expand Down
1 change: 0 additions & 1 deletion src/bpp/templates/raporty/strona_raportow/podstrona.html
Expand Up @@ -11,7 +11,6 @@
{% endblock %}

{% block content %}
<h1>Raporty</h1>
<h2>{{ nazwa_raportu }}</h2>
{% crispy form %}
{{ form.media }}
Expand Down
12 changes: 12 additions & 0 deletions src/miniblog/models.py
@@ -1,5 +1,6 @@
from django.conf import settings
from django.db import models
from django.urls.base import reverse

from django.utils import timezone
from django.utils.html import escape
Expand All @@ -9,6 +10,8 @@
from model_utils.fields import SplitField
from model_utils.models import StatusModel, TimeStampedModel

from bpp.models.struktura import Uczelnia

SPLIT_MARKER = getattr(settings, "SPLIT_MARKER", "WTF")


Expand All @@ -30,3 +33,12 @@ class Meta:
verbose_name_plural = _("Articles")
verbose_name = _("Article")
ordering = ('-published_on', 'title')

def get_absolute_url(self):
if self.status != self.STATUS.published:
return reverse("admin:miniblog_article_change", args=(self.pk,))
# TODO: co gdy będzie wiele uczelni w systemie?
uczelnia = Uczelnia.objects.all().first()
if self.article_body.has_more:
return reverse("bpp:browse_artykul", args=(uczelnia.slug, self.slug))
return reverse("bpp:browse_uczelnia", args=(uczelnia.slug,))
7 changes: 7 additions & 0 deletions src/nowe_raporty/templates/nowe_raporty/formularz.html
Expand Up @@ -10,6 +10,13 @@
{% endblock %}

{% block content %}
<h2>{{ title }}</h2>
{# go_to_admin_change.html #}
{% load user_in_group %}{% if request.user.is_superuser or request.user|has_group:"raporty" %}
<div class="panel hide-on-print">
<a target="_blank" href="{% url "admin:flexible_reports_report_change" report.pk %}">{{ text|default:"otwórz do edycji" }}</a>
</div>
{% endif %}
{% load crispy_forms_tags %}
{% crispy form %}
{% endblock %}
7 changes: 7 additions & 0 deletions src/nowe_raporty/views.py
Expand Up @@ -5,10 +5,12 @@
from django.conf import settings
from django.http.response import HttpResponse, FileResponse
from django.http.response import HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.template.context import RequestContext
from django.views.generic import FormView, TemplateView
from django.views.generic.detail import DetailView
from django_tables2.export.export import TableExport
from flexible_reports.models.report import Report

from bpp.models.autor import Autor
from bpp.models.cache import Rekord
Expand All @@ -31,12 +33,15 @@ def form_valid(self, form):

def get_context_data(self, **kwargs):
kwargs['title'] = self.title
kwargs['report'] = get_object_or_404(
Report, slug=self.report_slug)
return super(BaseFormView, self).get_context_data(**kwargs)


class AutorRaportFormView(BaseFormView):
form_class = AutorRaportForm
title = "Raport autorów"
report_slug = "raport-autorow"

def form_valid(self, form):
d = form.cleaned_data
Expand All @@ -46,11 +51,13 @@ def form_valid(self, form):
f"_tzju={ d['tylko_z_jednostek_uczelni'] }")

class JednostkaRaportFormView(BaseFormView):
report_slug = "raport-jednostek"
form_class = JednostkaRaportForm
title = "Raport jednostek"


class WydzialRaportFormView(BaseFormView):
report_slug = "raport-wydzialow"
form_class = WydzialRaportForm
title = "Raport wydziałów"

Expand Down

0 comments on commit 4dccf78

Please sign in to comment.