Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SHA1 and SHA256 #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ This way there shouldn't be any errors when trying to authenticate against Faceb
Additionally, if you need Twilio account information you'll need to setup your own or ask for the account information from someone at Local Projects or University of Florida.

### Webassets

Make sure to install node-less (lessc).
This project takes advantage of the Python webassets library. However, compiling and processing CSS and JS files must still be done manually before deploying to an environment that does not run in debug mode. Whenever it comes time to deploy or commit changes to JS and/or CSS files, be sure to run them through the assets manager:

$ python manage.py assets rebuild
Expand Down
14 changes: 14 additions & 0 deletions auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,20 @@ def encrypt(self, password):
seasoned = "%s%s" % (password, self.salt)
return hashlib.md5(seasoned.encode('utf-8')).hexdigest()

class SHA1PasswordEncryptor(PasswordEncryptor):
"""SHA1 password encryptor
"""
def encrypt(self, password):
seasoned = "%s%s" % (password, self.salt)
return hashlib.sha1(seasoned.encode('utf-8')).hexdigest()

class SHA256PasswordEncryptor(PasswordEncryptor):
"""SHA256 password encryptor
"""
def encrypt(self, password):
seasoned = "%s%s" % (password, self.salt)
return hashlib.sha256(seasoned.encode('utf-8')).hexdigest()

class UserService(object):
"""User service base class
"""
Expand Down
4 changes: 2 additions & 2 deletions cdw/templates/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<div class="container">
<div class="share span-20">
<div><img class="share-icon" src="{{ media_root }}/images/share_icon.jpg"/></div>
<div class="like-btn"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.civildebatewall.com&amp;send=false&amp;layout=button_count&amp;width=255&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21&amp;appId={{ facebook_app_id }}" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:255px; height:21px;" allowTransparency="true"></iframe></div>
<div class="tweet-btn"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.civildebatewall.com">Tweet</a>
<div class="like-btn"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fthewall.illinoisstate.edu&amp;send=false&amp;layout=button_count&amp;width=255&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21&amp;appId={{ facebook_app_id }}" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:255px; height:21px;" allowTransparency="true"></iframe></div>
<div class="tweet-btn"><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://thewall.illinoisstate.edu">Tweet</a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script></div>
</div>
<div class="util span-27">
Expand Down
45 changes: 25 additions & 20 deletions cdwapi/views/questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,31 +76,36 @@ def questions_threads_get(id):
break;
i += 1


# Organize them into a list with the offset in the middle
# to give the website a never ending 'loop' feel
organized = []

# most items to each side possible without overlap
rl = min(30, (total - 1) / 2)

for n in range(i, i+rl):
if n >= total:
ni = n - total
else:
ni = n
if total < 3:
for n in range(0, total):
organized.insert(0, threads[n])
else:
# most items to each side possible without overlap
rl = min(30, (total - 1) / 2)

if threads[ni] not in organized:
organized.append(threads[ni])


for n in range(i-1, i-1-rl, -1):
if n < 0:
ni = total + n
else:
ni = n
for n in range(i, i+rl):
if n >= total:
ni = n - total
else:
ni = n

if threads[ni] not in organized:
organized.append(threads[ni])

if threads[ni] not in organized:
organized.insert(0, threads[ni])

for n in range(i-1, i-1-rl, -1):
if n < 0:
ni = total + n
else:
ni = n

if threads[ni] not in organized:
organized.insert(0, threads[ni])

#current_app.logger.debug(organized)
return jsonify(organized)
Expand Down Expand Up @@ -145,4 +150,4 @@ def questions_current():
@blueprint.route('/questions/categories', methods=['GET'])
def questions_categories():
return jsonify(cdw.categories.all())


2 changes: 1 addition & 1 deletion fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# Generate conventional server values
env.server_user_home_dir = "%(server_home_dir)s/%(user)s" % env
#env.server_sites_dir = "%(server_user_home_dir)s/sites" % env
env.server_sites_dir = "%(server_user_home_dir)s/sites" % env
env.server_virtualenv_dir = "%(server_user_home_dir)s/.virtualenv" % env

# Generate conventional application values
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ blinker==1.1
boto==2.1.1
cropresize==0.1.6
cssmin==0.1.4
factory-boy==1.0.0
httplib2==0.7.1
factory_boy==1.0.0
httplib2==0.7.4
lorem-ipsum-generator==0.3
mongoengine==0.5.2
nose==1.1.2
Expand Down