Navigation Menu

Skip to content

Commit

Permalink
removed el-pagination b/c of timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Lou Wolford committed Jul 13, 2016
1 parent 141aded commit 05e1544
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 92 deletions.
2 changes: 1 addition & 1 deletion adl_lrs/settings.py
Expand Up @@ -104,6 +104,7 @@
ALLOW_EMPTY_HTTP_AUTH = False
OAUTH_ENABLED = True

AUTH_USER_MODEL = "auth.User"
# OAuth1 callback views
OAUTH_AUTHORIZE_VIEW = 'oauth_provider.views.authorize_client'
OAUTH_CALLBACK_VIEW = 'oauth_provider.views.callback_view'
Expand Down Expand Up @@ -252,7 +253,6 @@
'oauth_provider',
'django.contrib.admin',
'jsonify',
'el_pagination',
'corsheaders',
]

Expand Down
58 changes: 48 additions & 10 deletions adl_lrs/templates/my_activity_states.html
Expand Up @@ -41,7 +41,54 @@ <h2>My Activity States</h2>
<br>
<br>
<div>
{% include page_template %}
{% if activity_states %}
<div class="email-item">
{% for as in activity_states %}
<div class="datacontainer pure-u">
<h4 class="email-name"><span class="as-actid">{{ as.activity_id }}</span> - <span class="as-stid">{{ as.state_id }}</span></h4>
<h5 class="email-subject"><i>Last Updated: {{ as.updated }}</i></h5>
<p class="email-desc">
{% if as.json_state %}
<pre class="jsonpre">{{ as.json_state }}</pre>
<input class="hidden" type="hidden" value="{{ as.json_state }}">
{% else %}
{% if as.content_type == "application/octect-stream" or as.content_type == "text/plain" %}
<pre class="jsonpre">Non-JSON</pre>
<input class="hidden" type="hidden" value="Not JSON">
{% else %}
Cannot display state (non-text and non-JSON)
<input class="hidden" type="hidden" value="">
{% endif %}
{% endif %}
{% if as.state_id == "https://w3id.org/xapi/adl/profiles/scorm/activity-state" %}
<br>
<button class="scormbutton pure-button pure-button-primary" type="button">Show Attempts</button>
<br>
<br>
<div class="attemptarray"></div>
{% endif %}
</p>
</div>
<br>
<br>
{% endfor %}
</div>
<div class="pagination">
<span class="step-links">
{% if activity_states.has_previous %}
<a href="?page={{ activity_states.previous_page_number }}">Previous</a>
{% endif %}
<span class="current">
Page {{ activity_states.number }} of {{ activity_states.paginator.num_pages }}
</span>
{% if activity_states.has_next %}
<a href="?page={{ activity_states.next_page_number }}">Next</a>
{% endif %}
</span>
</div>
{% else %}
No activity states to display
{% endif %}
</div>
</div>
</div>
Expand All @@ -68,13 +115,4 @@ <h2>My Activity States</h2>
}
</script>
<script type="text/javascript" src="{{ STATIC_URL }}scripts/extra-data.js"></script>
<script src="django-el-pagination-2.1.1"></script>
<script>
$.endlessPaginate({
paginateOnScroll: true,
onCompleted: function(context, fragment){
styleData();
}
});
</script>
{% endblock extra_js %}
38 changes: 0 additions & 38 deletions adl_lrs/templates/my_activity_states_holder.html

This file was deleted.

42 changes: 32 additions & 10 deletions adl_lrs/templates/my_statements.html
@@ -1,4 +1,5 @@
{% extends "base.html" %}
{% load jsonify %}
{% block extra_css %}
<link rel="stylesheet" href="{{ STATIC_URL }}css/extra.css">
<style>
Expand Down Expand Up @@ -39,7 +40,37 @@
<h2>My Statements</h2>
<br>
<br>
{% include page_template %}
{% if statements %}
<div class="email-item">
{% for stmt in statements %}
<div class="datacontainer pure-u">
<h4 class="email-name"><span class="actor">{{ stmt.actor.get_a_name }}</span> <span class="verb">{{ stmt.verb.get_a_name }}</span> <span class="object">{% if stmt.object_statementref %}{{ stmt.get_object.id }}{% else %}{{ stmt.get_object.get_a_name }}{% endif %}</span></h4>
<h5 class="email-subject">{{ stmt.timestamp }}</h5>
<h5 class="email-subject">{{ stmt.statement_id }}</h5>
<p class="email-desc">
<pre id="stmt" class="jsonpre">{{ stmt.to_dict|jsonify }}</pre>
</p>
</div>
<br>
<br>
{% endfor %}
</div>
<div class="pagination">
<span class="step-links">
{% if statements.has_previous %}
<a href="?page={{ statements.previous_page_number }}">Previous</a>
{% endif %}
<span class="current">
Page {{ statements.number }} of {{ statements.paginator.num_pages }}
</span>
{% if statements.has_next %}
<a href="?page={{ statements.next_page_number }}">Next</a>
{% endif %}
</span>
</div>
{% else %}
No statements to display
{% endif %}
</div>
</div>
<div class="pure-u-1-6 pure-u-md-1-6 pure-u-lg-1-6"></div>
Expand All @@ -49,13 +80,4 @@ <h2>My Statements</h2>
{% block extra_js %}
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}scripts/extra-data.js"></script>
<script src="{{ STATIC_URL }}el-pagination/js/el-pagination.js"></script>
<script>
$.endlessPaginate({
paginateOnScroll: true,
onCompleted: function(context, fragment){
styleData();
}
});
</script>
{% endblock extra_js %}
22 changes: 0 additions & 22 deletions adl_lrs/templates/my_statements_holder.html

This file was deleted.

37 changes: 27 additions & 10 deletions adl_lrs/views.py
Expand Up @@ -4,6 +4,7 @@
from django.contrib.auth import logout, login, authenticate
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.core.urlresolvers import reverse
from django.conf import settings
from django.db import transaction, IntegrityError
Expand Down Expand Up @@ -165,29 +166,45 @@ def regclient(request):

@login_required()
@require_http_methods(["GET"])
def my_statements(request, template="my_statements.html", page_template="my_statements_holder.html"):
stmts = Statement.objects.filter(user=request.user).order_by('-timestamp')
context = {'statements': stmts, 'page_template': page_template}
if request.is_ajax():
template = page_template
def my_statements(request, template="my_statements.html"):
stmt_list = Statement.objects.filter(user=request.user).order_by('-timestamp')
paginator = Paginator(stmt_list, 25)
page = request.GET.get('page')

try:
stmts = paginator.page(page)
except PageNotAnInteger:
stmts = paginator.page(1)
except EmptyPage:
stmts = paginator.page(paginator.num_pages)

context = {'statements': stmts}
return render(request, template, context)


@login_required()
@require_http_methods(["GET"])
def my_activity_states(request, template="my_activity_states.html", page_template="my_activity_states_holder.html"):
def my_activity_states(request, template="my_activity_states.html"):
try:
ag = Agent.objects.get(mbox="mailto:" + request.user.email)
except Agent.DoesNotExist:
ag = Agent.objects.create(mbox="mailto:" + request.user.email)
except Agent.MultipleObjectsReturned:
return HttpResponseBadRequest("More than one agent returned with email")

context = {'activity_states': ActivityState.objects.filter(agent=ag).order_by(
'-updated', 'activity_id'), 'page_template': page_template}
as_list = ActivityState.objects.filter(agent=ag).order_by(
'-updated', 'activity_id')
paginator = Paginator(as_list, 25)
page = request.GET.get('page')

try:
act_sts = paginator.page(page)
except PageNotAnInteger:
act_sts = paginator.page(1)
except EmptyPage:
act_sts = paginator.page(paginator.num_pages)

if request.is_ajax():
template = page_template
context = {'activity_states': act_sts}
return render(request, template, context)


Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Expand Up @@ -3,7 +3,6 @@ amqp==1.4.9
bencode==1.0
celery==3.1.19
django-cors-headers==1.1.0
django-el-pagination==2.1.1
django-jsonify==0.3.0
importlib==1.0.3
isodate==0.5.4
Expand Down

0 comments on commit 05e1544

Please sign in to comment.