Skip to content

Commit

Permalink
Killing of jCourse. :( Goodbye old friend
Browse files Browse the repository at this point in the history
  • Loading branch information
dhasegan committed Sep 5, 2014
1 parent ef4806f commit 9913dd9
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 54 deletions.
45 changes: 31 additions & 14 deletions app/campusnet_login.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
import sys
import os
import requests

from twill import commands
_UNIVERSITY_LOGINS = [
{
"name": "Jacobs University Bremen",
"url": 'https://campusnet.jacobs-university.de/scripts/mgrqispi.dll',
"domain": 'jacobs-university.de',
"payload": {
'usrname': "",
'pass': "",
"APPNAME": "CampusNet",
"PRGNAME": "LOGINCHECK",
"ARGUMENTS": "clino,usrname,pass,menuno,persno,browser,platform",
"clino": "000000000000001",
"menuno": "000084",
"persno": "00000000",
"browser": "",
"platform": ""
}
}

def login_success(login_user, login_pass):
commands.go('https://campusnet.jacobs-university.de/scripts/mgrqispi.dll?APPNAME=CampusNet&PRGNAME=ACTION&ARGUMENTS=-A9PnS7.Eby4LCWWmmtOcbYKUQ-so-sF48wtHtVNWX9aIeYmoSh5mej--SCbT.jubdlAouHy3dHzwyr-O.ufj3NVAYCNiJr0CFcBNwA3xADclRCTyqC0Oip8drT0F=')
commands.fv('1', 'usrname', login_user)
commands.fv('1', 'pass', login_pass)
commands.submit('3')
]

out = sys.stdout
bin = open(os.devnull, 'w')
sys.stdout = bin
login_result = commands.show()
sys.stdout = out

return (login_result.find('Wrong username or password') == -1)
def login_success(username, password):
for university in _UNIVERSITY_LOGINS:
payload = university['payload']
payload["usrname"] = username
payload["pass"] = password
response = requests.post(university['url'], data=payload)

if response.content.find('Wrong username or password') == -1 and response.content.find('Access denied') == -1:
return True

return False
6 changes: 3 additions & 3 deletions app/templates/objects/comment_section.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
{% csrf_token %}
<div class="row">
<div class="col-md-9">
<textarea class="form-control comment-submit" rows="3" max-length="1000" placeholder="Write a review..." name="comment"></textarea>
<textarea class="form-control comment-submit" rows="3" max-length="1000" placeholder="Don't write a review! The website is closed!" name="comment" disabled></textarea>
</div>
<div class="col-md-3">
<button type="submit" class="btn btn-default">Submit</button>
<button type="submit" class="btn btn-default" disabled>Submit</button>
<div class="checkbox">
<small> <input type="checkbox" name="anonymous" value="true" checked> Anonymous </small>
</div>
Expand All @@ -26,7 +26,7 @@
</form>
{% else %}
<div class="auth-to-rate">
To submit reviews, please log in!
This website is closed! Check out the better and improved version <a href='http://www.connect.academy'>connect.academy</a> at: <a href='http://www.connect.academy'>www.connect.academy</a>
</div>
{% endif %}

Expand Down
5 changes: 5 additions & 0 deletions app/templates/pages/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
{% include 'objects/navbar.html' %}
<div class="container">
<div class="main-content" id="main_content_padding">

<div class="alert alert-danger">
This website is closed! Check out the better and improved version <a href='http://www.connect.academy'>connect.academy</a> at: <a href='http://www.connect.academy'>www.connect.academy</a>
</div>

{% block content %}
{% endblock %}
</div>
Expand Down
Binary file modified jCourse/db/database.db
Binary file not shown.
79 changes: 44 additions & 35 deletions jCourse/static/js/jcourse.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ $(function() {
var score = form.find('input[name="old_score"]').val();
form.find('.rating-my-score').text(score);
},
noRatedMsg: "To rate please log in!",
noRatedMsg: "Check www.connect.academy!",
score: function() {
var form = $(this).parents('form');
form.find('input[name="rating_value"]')
Expand All @@ -249,7 +249,8 @@ $(function() {
form.find('input[name="rating_value"]').val(score)
var user = form.find('input[name="username"]')
if (user.length > 0) {
form.submit();
alertAboutConnect();
// form.submit();
}
},
readOnly: function() {
Expand All @@ -275,6 +276,7 @@ $(function() {
placement: 'top',
title: function() {
var type = $(this).parents('form').find('input[name="rating_type"]').val();
return "Don't bother! Check connect.academy"
if (type == 'ALL') {
return "How do you rate the course in general?"
} else if (type == 'WKL') {
Expand Down Expand Up @@ -305,46 +307,48 @@ $(function() {
}
)
$('.comment-rate-form').submit( function(event) {
var form = $(this);
$.ajax( {
type: "POST",
url: form.attr( 'action' ),
data: form.serialize(),
success: function( response ) {
if ($('.compare-course-link').parent().hasClass("active")) {
var url = form.find('input[name="url"]').val();
window.location = url;
}
alertAboutConnect();
// var form = $(this);
// $.ajax( {
// type: "POST",
// url: form.attr( 'action' ),
// data: form.serialize(),
// success: function( response ) {
// if ($('.compare-course-link').parent().hasClass("active")) {
// var url = form.find('input[name="url"]').val();
// window.location = url;
// }

var badge = form.parents('.course-comment').find('.comment-score-badge');
var score = badge.text();
var vote = form.find('input[name="type"]').val();
var vote_nr = 0;
if (vote == "upvote") {
vote_nr = 1;
}
if (score != "") {
var scores = score.split("/");
var upvotes = parseInt(scores[0]);
var total = parseInt(scores[1]);
badge.html("" + (upvotes + vote_nr).toString() + "/" + (total + 1).toString());
} else {
badge.html("" + vote_nr.toString() + "/1");
}
// var badge = form.parents('.course-comment').find('.comment-score-badge');
// var score = badge.text();
// var vote = form.find('input[name="type"]').val();
// var vote_nr = 0;
// if (vote == "upvote") {
// vote_nr = 1;
// }
// if (score != "") {
// var scores = score.split("/");
// var upvotes = parseInt(scores[0]);
// var total = parseInt(scores[1]);
// badge.html("" + (upvotes + vote_nr).toString() + "/" + (total + 1).toString());
// } else {
// badge.html("" + vote_nr.toString() + "/1");
// }

form.parents('.course-comment').find('.comment-rate').hide();
}
} );
// form.parents('.course-comment').find('.comment-rate').hide();
// }
// } );
event.preventDefault();
});
$('.comment-flag').each( function() {
$(this).parent().find(".course-comment").hide();
});
$('.comment-flag').click( function(event) {
$(this).parent().find(".course-comment").show();
if ($(this).parent().find(".course-comment").length > 0) {
$(this).hide();
}
alertAboutConnect();
// $(this).parent().find(".course-comment").show();
// if ($(this).parent().find(".course-comment").length > 0) {
// $(this).hide();
// }
event.preventDefault();
});

Expand All @@ -353,5 +357,10 @@ $(function() {
});

// Tooltip for CampusNet
$("#campusnet-popover").tooltip({title: 'Please log in with your CampusNet credentials!'})
$("#campusnet-popover").tooltip({title: 'Please log in with your CampusNet credentials!'});


alertAboutConnect = function() {
alert("This website is closed! Check out the better and improved version at www.connect.academy")
};
});
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
Django==1.6.1
PIL==1.1.7
Pillow==2.3.0
South==0.8.4
argparse==1.2.1
boto==2.23.0
certifi==14.05.14
dj-database-url==0.2.2
dj-static==0.0.5
django-storages==1.1.8
django-toolbelt==0.0.1
gunicorn==18.0
psycopg2==2.5.2
pystache==0.5.3
requests==2.4.0
static==1.0.2
twill==0.9
wsgiref==0.1.2

0 comments on commit 9913dd9

Please sign in to comment.