Commit fb27dacb authored by Troy Grandy's avatar Troy Grandy

bug fixes.

parent 80a3db87
......@@ -51,7 +51,8 @@ def group_perms(user, group_id=None):
'can_edit_permissions': False
}
group = get_object_or_404(ContentGroup, pk=group_id)
if group.owner == user or user.is_superuser:
# Removing superuser from below for now...
if group.owner == user:
perms = dict.fromkeys(perms, True)
else:
groupmembership = GroupMembership.objects.filter(contentgroup=group, user=user).first()
......@@ -66,3 +67,33 @@ def group_perms(user, group_id=None):
'can_edit_permissions': groupmembership.can_edit_permissions,
}
return perms
""" def groups_perms(user, groups):
if groups:
perms = {}
perms_temp = {
'can_add_users': False,
'can_remove_users': False,
'can_use_items': False,
'can_add_items': False,
'can_remove_items': False,
'can_edit_items': False,
'can_edit_permissions': False
}
for group in groups:
perms[group.id] = {}
if group.owner == user:
perms[group.id] = dict.fromkeys(perms_temp, True)
else:
groupmembership = GroupMembership.objects.filter(contentgroup=group, user=user).first()
if groupmembership:
perms[group.id] = {
'can_add_users': groupmembership.can_add_users,
'can_remove_users': groupmembership.can_remove_users,
'can_use_items': groupmembership.can_use_items,
'can_add_items': groupmembership.can_add_items,
'can_remove_items': groupmembership.can_remove_items,
'can_edit_items': groupmembership.can_edit_items,
'can_edit_permissions': groupmembership.can_edit_permissions,
}
return perms """
......@@ -5,7 +5,7 @@ from jinja2 import evalcontextfilter, Markup, escape
register = template.Library()
perms_list = ['own', 'edit', 'delete', 'share']
perms_list = ['own', 'edit', 'delete', 'share', 'use']
def determine_perms(item, user):
if item.owner_id == user.id:
return {x: True for x in perms_list}
......
......@@ -1231,6 +1231,8 @@ def editGroup(request, group_id=None):
owner = False
group_owner = False
if group:
# Likely will want to add superuser here, or remove from perm check on list view (slide_tags)
# Point being it should be consistent so we don't run into weird 404s
if not (group.owner == request.user or \
GroupMembership.objects.filter(contentgroup=group, user=request.user).first().can_add_users or \
GroupMembership.objects.filter(contentgroup=group, user=request.user).first().can_remove_users):
......@@ -1331,9 +1333,9 @@ def transferOwnership(request, item, pk):
if request.method == 'POST':
# Check that we have a valid recipient:
recipient = request.POST.get('recipient', None)
if recipient is not None:
if recipient is not None and recipient != '':
recipient = User.objects.filter(username=recipient.lower()).first()
if recipient is not None and recipient != request.user:
if recipient is not None and recipient != '' and recipient != request.user:
# If this is a group we need to do some fancy finagling...
if itemtype == 'group':
# If the recipient is already in the group, remove their current ownership...
......
......@@ -154,7 +154,8 @@ body {
padding: 50px 30px 0 30px;
/* // fixing slide editor; these might need to be specific to that view */
height: 100%;
/* width: 100%; */
width: 100%;
max-width: 1170px;
}
.navbar-inverse {
......@@ -285,6 +286,9 @@ table .checkbox input[type="checkbox"] {
display: flex;
flex-wrap: wrap; }
.list.in {
display: flex;}
.list .itemContainer {
height: 100%; }
......@@ -309,10 +313,15 @@ table .checkbox input[type="checkbox"] {
.modal .list .slideItem,
.modal .list .slideshowItem {
min-height: 160px;
min-width: 145px;
max-width: 50%; }
.modal .list .slideItem{
min-height: 210px; }
.modal .list .slideshowItem{
min-height: 250px; }
.modal .itemContainerLayer,
.modal .itemContainerSlide,
.modal .itemContainerSlideshow {
......
......@@ -27,7 +27,8 @@ body {
padding: 50px 30px 0 30px;
// fixing slide editor; these might need to be specific to that view
height: 100%;
/* width: 100%; */
width: 100%;
max-width: 1170px;
}
.navbar-inverse {
......@@ -203,6 +204,9 @@ table .checkbox input[type="checkbox"] {
flex-wrap: wrap;
}
.list.in {
display: flex;}
.list .itemContainer {
height: 100%;
}
......@@ -232,11 +236,18 @@ table .checkbox input[type="checkbox"] {
.modal .list .slideItem,
.modal .list .slideshowItem {
min-height: 160px;
min-width: 145px;
max-width: 50%;
}
.modal .list .slideItem{
min-height: 210px;
}
.modal .list .slideshowItem{
min-height: 250px;
}
.modal .itemContainerLayer,
.modal .itemContainerSlide,
.modal .itemContainerSlideshow {
......
......@@ -33,6 +33,9 @@ button:disabled {
border-left: solid 1px #DDDDDD;
{% endif %}
}
.username .textinput{
min-width: 100px;
}
</style>
{% endblock %}
......
......@@ -25,6 +25,7 @@
<div class="col-xs-4">
<div class="btn-group-vertical btn-block" role="group" aria-label="...">
<a href="{% url 'view_group' group.id %}" class="btn btn-primary btn-sm">View</a>
{{perms2}}
{% if perms.can_add_users == True or perms.can_remove_users == True %}<a href="{% url 'edit_group' group.id %}" class="btn btn-primary btn-sm">Edit</a>{% endif %}
{% if group.owner == user %}
<button class="transferbutton btn btn-primary btn-sm" data-itempk="{{group.id}}">Transfer</button>
......@@ -35,13 +36,14 @@
{% else %}
</div>
{% endif %}
{# The below is unneeded...why would you share a group? just add any user you want to "share" the group with... #}
<div class="col-xs-12 sharebuttoncontainer">
{% if mode == "use" or mode == "edit"%}
<div class="col-xs-12 sharegroupbuttoncontainer">
{% if perms.can_add_items == True %}
<button type="button" class=" btn btn-block btn-primary sharegroupbutton">Share</button>
{% else %}
<button type="button" class=" btn btn-block btn-primary disabled">Cannot Share</button>
{% endif %}
</div>
{% endif %}
</div>
</div>
......@@ -7,9 +7,9 @@
<span class="transferissue"></span>
{% if itemtype == "group" %}
<br>
<input type="checkbox" id="transfer_all_items" value="true"> Transfer all items (Slides, Slideshows, Screens etc.) which I own that are shared with this group as well.
<input type="checkbox" id="transfer_all_items" value="false" name="transfer_all_items"> Transfer all items (Slides, Slideshows, Screens etc.) which I own that are shared with this group as well.
{% else %}
<input type="hidden" id="transfer_all_items" value=''>
<input type="hidden" id="transfer_all_items_hidden" value=''>
{% endif %}
<script>
$(function(){
......@@ -17,7 +17,7 @@
$("#dotransfer").unbind();
$("#dotransfer").click(function(){
// Get the IDs for all the added groups...
var data = {'recipient': $('#transferrecipient').val(), 'transfer_all_items': $('#transfer_all_items').val(), 'csrfmiddlewaretoken': "{{csrf_token}}"}
var data = {'recipient': $('#transferrecipient').val(), 'transfer_all_items': $('#transfer_all_items').is(':checked'), 'csrfmiddlewaretoken': "{{csrf_token}}"}
// Post this information
$.post('/transfer/{{itemtype}}/{{item.id}}/', data, function(resp){
if(resp=="SUCCESS"){
......
......@@ -49,7 +49,7 @@
</div>
<div class="col-xs-4">
<div class="btn-group-vertical btn-block" role="group" aria-label="...">
{% if perms.share == True %}<button class="sharebutton btn btn-primary btn-sm" data-type="layer" data-itempk="{{layer.id}}" data-itemtitle="{{layer.title}}">Share</button>{% endif %}
{% if perms.share == True %}<button class="sharewidgetbutton btn btn-primary btn-sm" data-type="layer" data-itempk="{{layer.id}}" data-itemtitle="{{layer.title}}">Share</button>{% endif %}
{% if perms.edit == True %}<a href="{% url 'edit_layer' layer.id %}" class="btn btn-primary btn-sm">Edit</a>{% endif %}
{% if perms.delete == True %}<button type="button" class="btn layer-delete-button btn-default btn-sm" data-deleteurl="{% url 'delete_layer' layer.id%}">Delete</a>{% endif %}
</div>
......
......@@ -12,13 +12,16 @@
.container {
padding-top: 50px;
}
#inner-main{
width: 100%;
}
</style>
{% endblock %}
{% block body %}
<div class="container">
<div id="inner-main" class="container">
<div class="row">
<info-panel title="New and Updated">
<ul class="fa-ul">
......
......@@ -52,7 +52,7 @@
{% block script %}
<script>
$('#listLayersLoader').load('{% url "list_layers" mode="manage" %}')
$('#listLayersLoader').on('click', '.sharebutton', function(){
$('#listLayersLoader').on('click', '.sharewidgetbutton', function(){
$('#shareModalBody').load('/share/layer/'+$(this).data('itempk')+'/', function(){
$('#shareModal').modal('show');
})
......
......@@ -25,7 +25,7 @@
</div>
<div class="col-xs-4">
<div class="btn-group-vertical btn-block" role="group" aria-label="...">
{% if perms.share == True %}<button class="sharebutton btn btn-primary btn-sm" data-type="screen" data-itempk="{{screen.id}}" data-itemtitle="{{screen.title}}">Share</button>{% endif %}
{% if perms.share == True %}<button class="sharescreenbutton btn btn-primary btn-sm" data-type="screen" data-itempk="{{screen.id}}" data-itemtitle="{{screen.title}}">Share</button>{% endif %}
{% if perms.edit == True %}<a href="{% url 'edit_screen' screen.id %}" class="btn btn-primary btn-sm">Edit</a>{% endif %}
<a href="{% url 'view_screen' screen.id %}?preview=true" class="btn btn-primary btn-sm">View</a>
{% if user == screen.owner %}
......
......@@ -72,7 +72,7 @@
{% block script %}
<script>
$('#listScreenLoader').load('{% url "list_screens" %}')
$('#listScreenLoader').on('click', '.sharebutton', function(){
$('#listScreenLoader').on('click', '.sharescreenbutton', function(){
$('#shareModalBody').load('/share/screen/'+$(this).data('itempk')+'/', function(){
$('#shareModal').modal('show');
})
......
......@@ -330,24 +330,25 @@
<div id="controls-extra"></div>
<div id="version-feedback">
<div id="feedbackmodal" style="z-index:30000;" class="modal fade">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
<div id="version-feedback">
<div id="feedbackmodal" style="z-index:30000;" class="modal fade">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
<div id="widget-documentation">
<div id="documentationmodal" style="z-index:30000;" class="modal fade">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
<div id="widget-documentation">
<div id="documentationmodal" style="z-index:30000;" class="modal fade">
<div class="modal-dialog">
<div class="modal-content"></div>
</div>
</div>
</div>
<div id="layersModal" class="modal fade" style="z-index:2000;">
<div class="modal-dialog modal-lg">
<div class="modal-content" style="padding: 10px;">
<div class="modal-content">
<div id="listLayersLoader" class="modal-body"></div>
</div>
<!-- /.modal-content -->
......@@ -365,6 +366,7 @@
window.onload = function() {
window.addEventListener("beforeunload", function (e) {
console.log('arg')
if (formSubmitting || !formUpdated) {
return undefined;
}
......@@ -372,6 +374,10 @@
});
};
$('#slideform').submit(
setFormSubmitting
)
window.addEventListener("load", windowLoadHandler, false);
function iframeCheck(status=false){
}
......
......@@ -39,7 +39,7 @@
</div>
<div class="col-xs-4">
<div class="btn-group-vertical btn-block" role="group" aria-label="...">
{% if perms.share == True %}<button type="button" class="sharebutton btn btn-primary btn-sm" data-type="slide" data-itempk="{{slide.id}}" data-itemtitle="{{slide.title}}">Share</button>{% endif %}
{% if perms.share == True %}<button type="button" class="shareslidebutton btn btn-primary btn-sm" data-type="slide" data-itempk="{{slide.id}}" data-itemtitle="{{slide.title}}">Share</button>{% endif %}
{% if perms.edit == True %}<a href="{% url 'edit_slide' slide.id %}" class="btn btn-primary btn-sm">Edit</a>{% endif %}
{% if perms.use == True %}<a href="{% url 'view_slide' slide.id %}?preview=true" class="btn btn-primary btn-sm">View</a>{% endif %}
{% if slide.owner == user %}
......
......@@ -69,7 +69,7 @@
{% block script %}
<script>
$('#listSlidesLoader').load('{% url "list_slides" mode="manage" %}')
$('#listSlidesLoader').on('click', '.sharebutton', function(){
$('#listSlidesLoader').on('click', '.shareslidebutton', function(){
$('#shareModalBody').load('/share/slide/'+$(this).data('itempk')+'/', function(){
$('#shareModal').modal('show');
})
......
......@@ -88,16 +88,16 @@
</form>
<div id="slideOverlayModal" class="modal fade" style="z-index:2000;">
<!-- <div id="slideOverlayModal" class="modal fade" style="z-index:2000;">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</div>
</div>
</div> -->
<div id="slidesModal" class="modal fade" style="z-index:2000;">
<div class="modal-dialog modal-lg">
......
......@@ -30,7 +30,7 @@
</div>
<div class="col-xs-4">
<div class="btn-group-vertical btn-block" role="group" aria-label="...">
{% if perms.share == True %}<button type="button" class="sharebutton btn btn-primary btn-sm" data-type="slideshow" data-itempk="{{slideshow.id}}" data-itemtitle="{{slideshow.title}}">Share</button>{% endif %}
{% if perms.share == True %}<button type="button" class="shareslideshowbutton btn btn-primary btn-sm" data-type="slideshow" data-itempk="{{slideshow.id}}" data-itemtitle="{{slideshow.title}}">Share</button>{% endif %}
{% if perms.edit == True %}<a href="{% url 'edit_slideshow' slideshow.id %}" class="btn btn-primary btn-sm">Edit</a>{% endif %}
<a href="{% url 'view_slideshow' slideshow.id %}?preview=true" class="btn btn-primary btn-sm">View</a>
{% if slideshow.owner == user %}
......@@ -42,6 +42,7 @@
{% else %}
</div>
{% endif %}
{% if mode == "edit" %}
<div class="col-xs-12 addbuttoncontainer">
{% if perms.use == True %}
<button type="button" class=" btn btn-block btn-primary addslideshowbutton">Add</button>
......@@ -49,6 +50,7 @@
<button type="button" class=" btn btn-block btn-primary disabled">Cannot add this item</button>
{% endif %}
</div>
{% endif %}
</div>
</div>
......
......@@ -70,7 +70,7 @@
{% block script %}
<script>
$('#listSlideshowsLoader').load('{% url "list_slideshows" mode="manage" %}')
$('#listSlideshowsLoader').on('click', '.sharebutton', function(){
$('#listSlideshowsLoader').on('click', '.shareslideshowbutton', function(){
$('#shareModalBody').load('/share/slideshow/'+$(this).data('itempk')+'/', function(){
$('#shareModal').modal('show');
})
......
......@@ -172,7 +172,7 @@
<td>
<a href="{% url 'restore' 'layer' layer.id%}">Restore</a>
</td>
<td><span class="alert-danger">Layer is in use</span></td>
<td><span class="alert-danger">Widget is in use</span></td>
{% else %}
</tr>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment