Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file added echopen-leaderboard/bootcamp/__init__.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/activities/__init__.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/articles/__init__.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/articles/forms.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/articles/models.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/articles/urls.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/articles/views.pyc
Binary file not shown.
Binary file not shown.
28 changes: 28 additions & 0 deletions echopen-leaderboard/bootcamp/authentication/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,31 @@ def clean(self):
self._errors['password'] = self.error_class(
['Passwords don\'t match'])
return self.cleaned_data





class ResetForm(forms.ModelForm):

email = forms.CharField(
widget=forms.EmailInput(attrs={'class': 'form-control'}),
required=True,
max_length=75,
help_text='Email')

class Meta:
model = User
exclude = ['last_login', 'date_joined']
fields = ['email', ]

def __init__(self, *args, **kwargs):
super(ResetForm, self).__init__(*args, **kwargs)
#self.fields['email'].validators.append(UniqueEmailValidator)
self.fields['email'].validators.append(SignupDomainValidator)
self.email = self.fields['email']

def clean(self):
super(ResetForm, self).clean()
password = self.cleaned_data.get('email')
return self.cleaned_data
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% load i18n %}{% autoescape off %}
{% blocktrans %}Password reset on {{ site_name }}{% endblocktrans %}
{% endautoescape %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{% extends 'base.html' %}
{% load staticfiles %}
{% load i18n %}


{% block head %}
<meta charset="UTF-8">
<title>Sign-Up/Login Form</title>
<link href='http://fonts.googleapis.com/css?family=Titillium+Web:400,300,600' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel="stylesheet" href="../static/form/css/style.css">
{% endblock head %}


{% block body %}
<div class="form">
<h1><img src="../static/form/images/logo2.png"></h1>
<div class="tab-content">

<div id="signup">
<form action="{% url 'reset' %}" method="post" role="form">
{% csrf_token %}

{% for field in form.visible_fields %}
<div class="form-group{% if field.errors %} has-error{% endif %}">

{{ field }}
{% if field.help_text %}
<span class="help-block">{{ field.help_text|safe }}</span>
{% endif %}
{% for error in field.errors %}
<label class="control-label">{{ error }}</label>
{% endfor %}
</div>
{% endfor %}


<button type="submit" class="button button-block"/>Reset Password</button>
</form>

</div>

</div> <!-- /form -->
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>

<script src="../static/form/js/index.js"></script>
</div>
{% endblock body %}
47 changes: 45 additions & 2 deletions echopen-leaderboard/bootcamp/authentication/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login
from bootcamp.authentication.forms import SignUpForm
from bootcamp.authentication.forms import SignUpForm, ResetForm
from django.contrib.auth.models import User
from bootcamp.feeds.models import Feed

from django.conf import settings
from django.contrib.auth.models import User
import random

def signup(request):
if request.method == 'POST':
Expand All @@ -29,3 +31,44 @@ def signup(request):
else:
return render(request, 'authentication/signup.html',
{'form': SignUpForm()})





from django.contrib.auth.tokens import default_token_generator
from django.utils.encoding import force_bytes
from django.utils.http import urlsafe_base64_encode, urlsafe_base64_decode
from django.template import loader
from django.core.validators import validate_email
from django.core.exceptions import ValidationError
from django.core.mail import send_mail
from bootcamp.settings import DEFAULT_FROM_EMAIL
from django.views.generic import *
from forms import ResetForm
from django.contrib import messages
from django.contrib.auth.models import User
from django.db.models.query_utils import Q




def reset_password(request):
if request.method == 'POST':
form = ResetForm(request.POST)
data = form
try:
user = User.objects.get(email=data.data['email'])
print(user, data.data['email'])
password = ''.join(random.choice('0123456789ABCDEF') for i in range(16))
user.set_password(password)
user.save()
send_mail('subject', "your echopen password has been reset %s" % password, DEFAULT_FROM_EMAIL , [data.data["email"]], fail_silently=False)
return render(request, 'authentication/request_password.html', {'form': ResetForm()})

except:

return render(request, 'authentication/request_password.html', {'form': ResetForm()})

else:
return render(request, 'authentication/request_password.html', {'form': ResetForm()})
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/core/__init__.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/core/forms.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/core/models.pyc
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h1><img src="static/form/images/logo2.png"></h1>
<input type="password" class="form-control" id="password" name="password">
</div>

<p class="forgot"><a href="{% url 'signup' %}">Forgot Password?</a></p>
<p class="forgot"><a href="{% url 'reset' %}">Forgot Password?</a></p>
<button type="submit" class="button button-block">{% trans 'Log in' %}</button>
<a href="{% url 'signup' %}" class="btn btn-link">{% trans 'Sign up for Echopen Challenge' %}</a>

Expand Down
Binary file added echopen-leaderboard/bootcamp/core/views.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/decorators.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/feeds/__init__.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/feeds/models.pyc
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ html {
}

body {
background-image:url('../images/base.jpg');
font-family: 'Titillium Web', sans-serif;
}

Expand Down
Binary file added echopen-leaderboard/bootcamp/feeds/urls.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/feeds/views.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/hackIDE/__init__.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/hackIDE/models.pyc
Binary file not shown.
47 changes: 31 additions & 16 deletions echopen-leaderboard/bootcamp/hackIDE/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import uuid

# access config variable
DEBUG = (os.environ.get('HACKIDE_DEBUG') != None)
#DEBUG = (os.environ.get('HACKIDE_DEBUG') != None)
# DEBUG = (os.environ.get('HACKIDE_DEBUG') or "").lower() == "true"
#CLIENT_SECRET = os.environ['HE_CLIENT_SECRET'] if not DEBUG else ""

Expand All @@ -51,8 +51,8 @@
"""
Check if source given with the request is empty
"""
def source_empty_check(source):
if source == "":
def source_empty_check(source):
if source == "":
response = {
"message" : "Source can't be empty!",
}
Expand Down Expand Up @@ -118,10 +118,11 @@ def get_context_data(self, **kwargs):
return context


def get(self, request, *args, **kwargs):
render(request, 'hackIDE/index.html')
def get(self, request, *args, **kwargs):
render(request, 'hackIDE/index.html', {'source_code':'toto'})



def post(self, request):
if request.is_ajax():
source = request.POST['source']
Expand All @@ -131,13 +132,13 @@ def post(self, request):
lang = request.POST['lang']
# Handle Invalid Language Case
lang_valid_check(lang)

proxy = callme.Proxy(server_id='fooserver2',amqp_host='localhost', timeout=3600)

proxy = callme.Proxy(server_id='fooserver',amqp_host='salamander.rmq.cloudamqp.com', amqp_vhost='spwlpmyp', amqp_user='spwlpmyp', amqp_password='_O3u6xA_26r_lGSBpfJY_fJn4Eu_9Sl3')

resp = proxy.enveloppe_extract(source)

model = Algorithm

model = Algorithm
#source = source + '\n' + resp['error_msg']
run_rank = model.objects.filter(score__lte=int(resp['score'])).order_by('rank')
if len(run_rank) > 0:
rankobj = run_rank.last()
Expand All @@ -159,29 +160,43 @@ def post(self, request):
b = Algorithm(username=request.user.username, user=request.user, rank = rank, score=resp['score'], time= resp['duration'], source_code=source, cpu=18)
b.save()
job_post = u'{0} has sent a job score: {1} rank: {2} :'.format(request.user.username,resp['score'], rank)

cop_resp = resp
resp = model.objects.all().order_by('rank')
values = resp.values('id')

for ind, item in enumerate(values) :
if (item['id']) == b.id:
paging = divmod(ind, 5)[0]

feed = Feed(user=request.user, post=job_post, job_link='/leaderboard?q=foo&flop=flip&page='+str(paging+1))
feed.save()

print(cop_resp)
if cop_resp['error_msg'] == 'None':
r={'compile_status':'OK', 'run_status_status':'OK'}
else:
r = {'compile_status': 'OK', 'run_status_status': 'ERROR', 'run_status_error':cop_resp['error_msg']}

#request.user.profile.notify_job_done(b)



feed = Feed(user=request.user, post=job_post, job_link='/leaderboard?q=foo&flop=flip&page='+str(paging+1))
feed.save()
like = Activity(activity_type=Activity.RUN_PROCESSED, feed=feed.pk, user=request.user)
like.save()

user = request.user
user.profile.notify_liked_bis(feed)

print 'Notified'
return HttpResponse(render(request, 'hackIDE/index.html'))
import json
#r['compile_status'] = 'OK'
#r['run_status']['status'] = 'AC'
#r['run_status']['time_used'] = '12'
#r['run_status']['memory_used'] = '12'
#r['run_status']['output_html'] = "dededed"
#r['run_status']['stderr'] = "toto"

#r = json.dumps(r)
#return HttpResponse(r, content_type="application/json")
return JsonResponse(r, safe=False)
#return HttpResponse(render(request, 'hackIDE/index.html'))

else:
print('error')
Expand Down
Binary file added echopen-leaderboard/bootcamp/hackIDE/views.pyc
Binary file not shown.
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/leaderboard/forms.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/messenger/__init__.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/messenger/models.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/messenger/urls.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/messenger/views.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/questions/__init__.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/questions/forms.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/questions/models.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/questions/urls.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/questions/views.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/search/__init__.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/search/models.pyc
Binary file not shown.
Binary file added echopen-leaderboard/bootcamp/search/views.pyc
Binary file not shown.
40 changes: 23 additions & 17 deletions echopen-leaderboard/bootcamp/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,44 @@

#SECRET_KEY = config('SECRET_KEY')

SECRET_KEY = '+h*i@$52+w(_eetvzgnkjq!q0ajz1qpgs-y9%89x4w3nlct=m'
SECRET_KEY = '6iype@&4cy@tru(4)y@mu2+zuqb0$5y4l058vxs!a&vy2adh$3'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = config('DEBUG', default=False, cast=bool)
TEMPLATE_DEBUG = DEBUG

#BASICAUTH_USERNAME = 'HotelDieu00057'
#BASICAUTH_PASSWORD = 'SignalProcessing-18-11-2016'


#DATABASES = {
# 'default': dj_database_url.config(default=config('DATABASE_URL'))
#}

DEBUG = True
DEBUG = False


# settings.py
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': '/var/tmp/django_cache',
}
}

#DATABASES = {
# 'default': {
# 'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': 'demo.db',
# }
#}

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'leaderboard',
'USER': 'postgres',
'PASSWORD': 'postgres',
'USER': 'xxxxxxxx',
'PASSWORD': 'xxxxxxxxx',
'HOST': '127.0.0.1',
'PORT': '5432',
}}


ALLOWED_HOSTS = ['*']




ALLOWED_HOSTS = ['http://xxxxxxxxx', 'xxxxx', '*']

# Application definition

Expand Down Expand Up @@ -139,4 +133,16 @@
FILE_UPLOAD_TEMP_DIR = '/tmp/'
FILE_UPLOAD_PERMISSIONS = 0o644

APPEND_SLASH = True




EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = '
EMAIL_HOST_PASSWORD = ''

DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
SERVER_EMAIL = EMAIL_HOST_USER
Binary file added echopen-leaderboard/bootcamp/settings.pyc
Binary file not shown.
1 change: 0 additions & 1 deletion echopen-leaderboard/bootcamp/static/form/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ html {
}

body {
background-image:url('../images/base.jpg');
font-family: 'Titillium Web', sans-serif;
}

Expand Down
Loading