Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Templatetag for newman frontend toolbar, template, css (draft).
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
div.fe-admin-toolbar { | ||
background-color: rgba(0,0,0,.85); color: #fff;padding: 6px; font: normal normal 10px Tahoma, Verdana, sans-serif; position: fixed; top:0;left:0;right:0;z-index:3000 | ||
} | ||
div.fe-admin-toolbar strong, div.fe-admin-toolbar b { font-weight: bold; } | ||
button.icn { padding: 3px; } | ||
button.icn span { | ||
padding: 3px 3px 3px 20px; | ||
background: url(../ico/16/ok.png) 0 50% no-repeat; | ||
} | ||
button.icn.logout span { | ||
background-image: url(../ico/16/logout.png); | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions
33
ella/newman/templates/newman/tpl_tags/newman_frontend_admin.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<div class="fe-admin-toolbar" style="background-color: rgba(0,0,0,.85); color: #fff;padding: 6px; font: normal normal 10px Tahoma, Verdana, sans-serif; position: fixed; top:0;left:0;right:0;z-index:3000"> | ||
<p>Přihlášen/a jako admin: <strong style="font-weight:bold">{{ user.get_full_name }}</strong> (<a href="http://localhost:3001/logout/?next=http://localhost:3000/">odhlásit</a>)</p> | ||
<p> | ||
{% if object %} | ||
{% trans object.content_type.name %}: | ||
<strong style="font-weight:bold">{{ object }}</strong>, | ||
návštěv: <strong style="font-weight:bold">{{ hitcount.hits }}</strong>, | ||
publikováno od: <strong style="font-weight:bold">{{ object.publish_from|date:"d.m.Y H:i:s" }}</strong> | ||
|
||
{% if placement.listing_set.count %} | ||
<select> | ||
<option>výčty...</option> | ||
{% for l in placement.listing_set.all %} | ||
<option>{{ l.publish_from|date:"d.m.Y H:i:s" }} | {{ l.category }}</option> | ||
{% endfor %} | ||
</select> | ||
{% endif %} | ||
|
||
<button onclick="location.href='{{ newman_object_url }}'"><span>Edituj</span></button> | ||
{% endif %} | ||
|
||
|
||
{% if positions %} | ||
<a href="http://localhost:3001/#/positions/position/category/{{ category.pk }}/" title="Upravit pozice">Pozice v kategorii {{ category.title }}</a>: | ||
{% for p in positions %} | ||
{{ p.name }}: {{ p.target }}, | ||
{% endfor %} | ||
{% endif %} | ||
</p> | ||
|
||
{{ NEWMAN_MEDIA_URL }} | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from django import template | ||
from ella.newman.utils import get_newman_url | ||
from ella.core.models.publishable import HitCount | ||
from ella.positions.models import Position | ||
|
||
register = template.Library() | ||
|
||
@register.inclusion_tag('newman/newman_frontend_admin.html', takes_context=True) | ||
def newman_frontend_admin(context): | ||
user = context['user'] | ||
vars = {} | ||
|
||
if not user.is_staff: | ||
return vars | ||
|
||
#vars['logout_url'] = reverse('newman:logout') | ||
object = context.get('object') | ||
if 'gallery' in context: | ||
object = context.get('gallery') | ||
placement = context.get('placement') | ||
|
||
vars['user'] = user | ||
vars['STATIC_URL'] = context.get('STATIC_URL') | ||
vars['NEWMAN_MEDIA_URL'] = context.get('NEWMAN_MEDIA_URL') | ||
vars['placement'] = placement | ||
vars['category'] = context.get('category') | ||
vars['newman_index_url'] = 'http://localhost:3001/' | ||
|
||
from django.db.models import Q | ||
import datetime | ||
now = datetime.datetime.now() | ||
lookup = (Q(active_from__isnull=True) | Q(active_from__lte=now)) & (Q(active_till__isnull=True) | Q(active_till__gt=now)) | ||
positions = Position.objects.filter(lookup, category=vars['category'].pk, disabled=False, target_id__isnull=False) | ||
print positions.query | ||
vars['positions'] = positions | ||
|
||
if object: | ||
vars['object'] = object | ||
vars['newman_object_url'] = get_newman_url(object) | ||
vars['hitcount'] = HitCount.objects.get(placement=placement.pk) | ||
|
||
return vars |