-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1069 from scieloorg/beta
Incorporação de códigos estáveis
- Loading branch information
Showing
50 changed files
with
2,633 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,4 @@ Celery | |
django-celery | ||
django-kombu | ||
defusedxml==0.4.1 | ||
django-countries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
87 changes: 87 additions & 0 deletions
87
scielomanager/accounts/management/commands/anonymize_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# coding: utf-8 | ||
from django.core.management.base import BaseCommand | ||
from django.contrib.auth.models import User | ||
from django.db.models import Q | ||
|
||
def display_users(users_list): | ||
print "-" * 80 | ||
print "| pk | username | first_name | last_name | email |" | ||
for user in users_list: | ||
print "| %s | %s | %s | %s | %s |" % (user.pk, user.username, user.first_name, user.last_name, user.email) | ||
print "-" * 80 | ||
print "total: %s users" % users_list.count() | ||
print "-" * 80 | ||
|
||
|
||
class Command(BaseCommand): | ||
help = 'replace sensible data to be anonymized, such as first_name, last_name, email, api tokens, etc' | ||
|
||
def handle(self, *args, **options): | ||
print "#" * 80 | ||
print "# THIS COMMAND WILL MODIFY USER DATA, AND SHOULD AFFECT THE LOGIN CREDENTIALS! #" | ||
print "# ----------- PLEASE BE SURE YOU HAVE A BACKUP TO AVOID DATA LOSS ------------ #" | ||
print "#" * 80 | ||
prompt_backup = raw_input('the database has a back up? [y/N]: ') | ||
if prompt_backup.lower() == 'y': | ||
users = User.objects.all() | ||
print "Found %s users!" % users.count() | ||
prompt_show_all_users = raw_input('want to list all these users? [y/N]: ') | ||
if prompt_show_all_users.lower() == 'y': | ||
display_users(users) | ||
|
||
# exclude non-scielo users | ||
non_scielo_users = users.exclude(email__endswith="@scielo.org") | ||
print "Found %s NON-scielo users!" % non_scielo_users.count() | ||
prompt_show_non_scielo_users = raw_input('want to list all these users? [y/N]: ') | ||
if prompt_show_non_scielo_users.lower() == 'y': | ||
display_users(non_scielo_users) | ||
|
||
# lookup to know if exists particular users to be excludes, such as: QAL1, QAL2, Produtor, etc | ||
has_special_users = non_scielo_users.filter( | ||
Q(first_name__iexact="Produtor") | Q(first_name__iexact="QAL1") | Q(first_name__iexact="QAL2") | ||
).exists() | ||
|
||
if has_special_users: | ||
prompt_to_exclude_special_users = raw_input( | ||
'Found at least one special user (QAL1 or QAL2 or Produtor). Do you want to ignore this users from modifications? [y/N]: ' | ||
) | ||
if prompt_to_exclude_special_users.lower() == 'y': | ||
non_scielo_users = non_scielo_users.exclude( | ||
Q(first_name__iexact="Produtor") | Q(first_name__iexact="QAL1") | Q(first_name__iexact="QAL2") | ||
) | ||
print "Now the list of NON-scielo users to be modified has %s users" % non_scielo_users.count() | ||
prompt_show_non_scielo_users = raw_input('want to list all these users? [y/N]: ') | ||
if prompt_show_non_scielo_users.lower() == 'y': | ||
display_users(non_scielo_users) | ||
|
||
print "#" * 80 | ||
print "# NOW WILL MODIFY USER DATA! #" | ||
print "# user.username will be set to user_<user.pk> #" | ||
print "# user.first_name will be set to user_fn_<user.pk> #" | ||
print "# user.last_name will be set to user_ln_<user.pk> #" | ||
print "# user.email will be set to user_<user.pk>@example.com #" | ||
print "# user.password will be set to 'test.scielo' [hashed] #" | ||
print "# user.api_key will be regenerated with a random uuid using tastypie.models > ApiKey > generate_key #" | ||
print "# ----------- BE SURE YOU HAVE A BACKUP TO AVOID DATA LOSS ------------ #" | ||
print "#" * 80 | ||
prompt_confirm_modify = raw_input('Are you sure? the process CAN NOT BE UNDONE [y/N]: ') | ||
if prompt_confirm_modify.lower() == 'y': | ||
print "Updating users ... (hold on, may take a while) ..." | ||
for user in non_scielo_users: | ||
user.username = "user_%s" % user.pk | ||
user.first_name = "user_fn_%s" % user.pk | ||
user.last_name = "user_ln_%s" % user.pk | ||
user.email = "user_%[email protected]" % user.pk | ||
user.set_password('test.scielo') | ||
# save new user field | ||
user.save() | ||
# generate a new api_key | ||
user.api_key.key = None | ||
user.api_key.save() | ||
# show updated user info | ||
display_users(non_scielo_users) | ||
print "done!" | ||
else: | ||
print "Nothing to do here! NON-scielo users were NOT changed!" | ||
else: | ||
print "Nothing to do here! Go and make a backup." |
164 changes: 142 additions & 22 deletions
164
scielomanager/accounts/templates/accounts/my_account.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,148 @@ | ||
{% extends "base_lv1.html" %} | ||
{% load i18n %} | ||
{% load user_avatar %} | ||
{% block content %} | ||
<style> | ||
#accountTabContent { min-height: 470px; } | ||
.avatar-rounded{ border-radius: 6px 6px 0 0; } | ||
</style> | ||
|
||
{% block breadcrumb %} | ||
<ul class="breadcrumb"> | ||
<li><a href="{% url index %}">{% trans 'Home' %}</a> <span class="divider">/</span></li> | ||
<li class="active">{% trans 'My Account' %}</li> | ||
</ul> | ||
<div class="row-fluid"> | ||
<div class="span9 offset2"> | ||
<div class="row-fluid"> | ||
<div class="span12"> | ||
<h4>{% trans "User information" %}:</h4> | ||
<div class="span8 well"> | ||
<dl> | ||
<dt>{% trans "First name" %}:</dt> | ||
<dd>{{ user.first_name }}</dd> | ||
<dt>{% trans "Last name" %}:</dt> | ||
<dd>{{ user.last_name }}</dd> | ||
<dt>{% trans "Username" %}:</dt> | ||
<dd>{{ user.username }}</dd> | ||
<dt>{% trans "Email" %}:</dt> | ||
<dd>{{ user.email }}</dd> | ||
</dl> | ||
<br> | ||
</div> | ||
<div class="span3"> | ||
<img class="avatar-rounded" src="{% user_avatar_url request.user '192' %}" alt=""> | ||
<div class="alert alert-info"> | ||
<small> | ||
<em> | ||
Change your avatar at: | ||
<a href="https://secure.gravatar.com"> | ||
https://secure.gravatar.com | ||
</a> | ||
</em> | ||
</small> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<ul class="nav nav-tabs" id="accountTab"> | ||
<li class="active"> | ||
<a data-toggle="tab" href="#profile"> | ||
<i class="icon icon-user"></i> {% trans "Profile" %}: | ||
</a> | ||
</li> | ||
<li> | ||
<a data-toggle="tab" href="#collections"> | ||
<i class="icon icon-book"></i> {% trans "My Collections" %}: | ||
</a> | ||
</li> | ||
<li> | ||
<a data-toggle="tab" href="#api_keys"> | ||
<i class="icon icon-lock"></i> {% trans "API token" %}: | ||
</a> | ||
</li> | ||
</ul> | ||
<div class="tab-content" id="accountTabContent"> | ||
<div id="profile" class="tab-pane in active"> | ||
<div class="span6"> | ||
<h4>{% trans "Change Password" %}:</h4> | ||
<div class="well"> | ||
<form id="change_password_form" action="{% url journalmanager.password_change %}" method="POST"> | ||
{% with password_form as form %} | ||
{% include "articletrack/includes/form_snippet.html" %} | ||
{% endwith %} | ||
</form> | ||
<br> | ||
</div> | ||
</div> | ||
<div class="span6"> | ||
<h4>{% trans "Notifications & Other preferences" %}:</h4> | ||
<div class="well"> | ||
<form id="profile_form" action="." method="POST"> | ||
{% with profile_form as form %} | ||
{% include "articletrack/includes/form_snippet.html" %} | ||
{% endwith %} | ||
</form> | ||
<br> | ||
</div> | ||
</div> | ||
</div> | ||
<div id="collections" class="tab-pane"> | ||
<div class="span12"> | ||
<h4>{% trans "My collections" %}:</h4> | ||
<div class="well"> | ||
<table class="table table-condensed table-hover"> | ||
<thead> | ||
<tr> | ||
<th class="span1">#</th> | ||
<th>{% trans "Collection" %}:</th> | ||
<th class="span2">{% trans "Am I manager?" %}</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for collection in my_collecttions %} | ||
<tr> | ||
<td>{{ forloop.counter }}</td> | ||
<td>{{ collection.name }}</td> | ||
<td> | ||
{% if collection.is_manager %} | ||
<i class="icon icon-ok"></i> | ||
{% else %} | ||
<i class="icon icon-remove"></i> | ||
{% endif %} | ||
</td> | ||
</tr> | ||
{% empty %} | ||
<tr> | ||
<td colspan="2">{% trans "No collections related yet!" %}</td> | ||
</tr> | ||
{% endfor %} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
<div id="api_keys" class="tab-pane"> | ||
<div class="span12"> | ||
<h4>{% trans "API Token" %}:</h4> | ||
<div class="well"> | ||
<p>{% trans "This is your token" %}: <code>{{user.api_key.key}}</code></p> | ||
<p> | ||
<a href="http://docs.scielo.org/projects/scielo-manager/en/latest/dev/api.html" target="_blank"> | ||
{% trans 'Read more about the API usage' %} | ||
</a> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
<div class="span8"> | ||
<ul> | ||
<li><a href="{% url journalmanager.password_change %}">Change my password</a></li> | ||
<li>Update my personal information</li> | ||
</ul> | ||
</div> | ||
<div class="span4 alert alert-info"> | ||
<h4>API Token</h4> | ||
<p>{{user.api_key.key}}</p> | ||
<p> | ||
<a href="http://docs.scielo.org/projects/scielo-manager/en/latest/dev/api.html" | ||
target="_blank"> | ||
{% trans 'Read more about the API usage' %} | ||
</a> | ||
</p> | ||
</div> | ||
{% block extrafooter %} | ||
{{ block.super }} | ||
<script> | ||
$(document).ready(function() { | ||
$('input', '#change_password_form').removeClass('span3').addClass('span12'); | ||
$('select', '#profile_form').addClass('span12').chosen(); | ||
}); | ||
</script> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.