Skip to content

Commit

Permalink
scieloorg#254 - Remover ícones de rede sociais dos periódico temporar…
Browse files Browse the repository at this point in the history
…iamente

FIX: scieloorg#254
  • Loading branch information
jfunez committed Jul 21, 2016
1 parent a47019b commit 7e6cc97
Show file tree
Hide file tree
Showing 7 changed files with 245 additions and 32 deletions.
162 changes: 162 additions & 0 deletions opac/tests/test_interface_journal_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,165 @@ def test_journal_detail_mission_with_EN_language(self):

self.assertIn(u"This journal is aiming xpto",
response.data.decode('utf-8'))

def test_journal_without_social_networks_show_no_links(self):
"""
COM:
- Periódico sem redes socials
QUANDO:
- Acessarmos a home do periódico
VERIFICAMOS:
- Que não aparece a seção de redes sociais
- O div com class="journalLinks" deve aparecer
"""

with current_app.app_context():
# with
collection = utils.makeOneCollection()
journal = utils.makeOneJournal({'collection': collection})
with self.client as c:
# when
response = c.get(url_for('main.journal_detail', journal_id=journal.jid))
# then
self.assertEqual(journal.social_networks, [])
self.assertStatus(response, 200)
social_networks_class = u"journalLinks"
self.assertIn(social_networks_class, response.data.decode('utf-8'))
twitter_btn_class = u"bigTwitter"
self.assertNotIn(twitter_btn_class, response.data.decode('utf-8'))
facebook_btn_class = u"bigFacebook"
self.assertNotIn(facebook_btn_class, response.data.decode('utf-8'))
google_btn_class = u"bigGooglePlus"
self.assertNotIn(google_btn_class, response.data.decode('utf-8'))

def test_journal_with_twitter_social_networks_show_links(self):
"""
COM:
- Periódico COM redes socials
QUANDO:
- Acessarmos a home do periódico
VERIFICAMOS:
- Que SIM aparece a seção de redes sociais
- O div com class="journalLinks" deve aparecer
"""

with current_app.app_context():
# with
collection = utils.makeOneCollection()
journal_data = {
'collection': collection,
'social_networks': [
{
'network': u'twitter',
'account': u'http://twitter.com/@foo'
}
]
}
journal = utils.makeOneJournal(journal_data)
with self.client as c:
# when
response = c.get(url_for('main.journal_detail', journal_id=journal.jid))
# then
self.assertStatus(response, 200)
social_networks_class = u"journalLinks"
self.assertIn(social_networks_class, response.data.decode('utf-8'))
twitter_btn_class = u"bigTwitter"
self.assertIn(twitter_btn_class, response.data.decode('utf-8'))
facebook_btn_class = u"bigFacebook"
self.assertNotIn(facebook_btn_class, response.data.decode('utf-8'))
google_btn_class = u"bigGooglePlus"
self.assertNotIn(google_btn_class, response.data.decode('utf-8'))

expected_social_link = u'<a href="{account}" data-toggle="tooltip" title="{network}">'.format(
account=journal_data['social_networks'][0]['account'],
network=journal_data['social_networks'][0]['network'].title(),
)
self.assertIn(expected_social_link, response.data.decode('utf-8'))

def test_journal_with_facebook_social_networks_show_links(self):
"""
COM:
- Periódico COM redes socials
QUANDO:
- Acessarmos a home do periódico
VERIFICAMOS:
- Que SIM aparece a seção de redes sociais
- O div com class="journalLinks" deve aparecer
"""

with current_app.app_context():
# with
collection = utils.makeOneCollection()
journal_data = {
'collection': collection,
'social_networks': [
{
'network': u'facebook',
'account': u'http://facebook.com/foo'
}
]
}
journal = utils.makeOneJournal(journal_data)
with self.client as c:
# when
response = c.get(url_for('main.journal_detail', journal_id=journal.jid))
# then
self.assertStatus(response, 200)
social_networks_class = u"journalLinks"
self.assertIn(social_networks_class, response.data.decode('utf-8'))
twitter_btn_class = u"bigTwitter"
self.assertNotIn(twitter_btn_class, response.data.decode('utf-8'))
facebook_btn_class = u"bigFacebook"
self.assertIn(facebook_btn_class, response.data.decode('utf-8'))
google_btn_class = u"bigGooglePlus"
self.assertNotIn(google_btn_class, response.data.decode('utf-8'))

expected_social_link = u'<a href="{account}" data-toggle="tooltip" title="{network}">'.format(
account=journal_data['social_networks'][0]['account'],
network=journal_data['social_networks'][0]['network'].title(),
)
self.assertIn(expected_social_link, response.data.decode('utf-8'))

def test_journal_with_googleplus_social_networks_show_links(self):
"""
COM:
- Periódico COM redes socials
QUANDO:
- Acessarmos a home do periódico
VERIFICAMOS:
- Que SIM aparece a seção de redes sociais
- O div com class="journalLinks" deve aparecer
"""

with current_app.app_context():
# with
collection = utils.makeOneCollection()
journal_data = {
'collection': collection,
'social_networks': [
{
'network': u'google',
'account': u'http://plus.google.com/+foo'
}
]
}
journal = utils.makeOneJournal(journal_data)
with self.client as c:
# when
response = c.get(url_for('main.journal_detail', journal_id=journal.jid))
# then
self.assertStatus(response, 200)
social_networks_class = u"journalLinks"
self.assertIn(social_networks_class, response.data.decode('utf-8'))
twitter_btn_class = u"bigTwitter"
self.assertNotIn(twitter_btn_class, response.data.decode('utf-8'))
facebook_btn_class = u"bigFacebook"
self.assertNotIn(facebook_btn_class, response.data.decode('utf-8'))
google_btn_class = u"bigGooglePlus"
self.assertIn(google_btn_class, response.data.decode('utf-8'))

expected_social_link = u'<a href="{account}" data-toggle="tooltip" title="{network}">'.format(
account=journal_data['social_networks'][0]['account'],
network=journal_data['social_networks'][0]['network'].title(),
)
self.assertIn(expected_social_link, response.data.decode('utf-8'))
12 changes: 7 additions & 5 deletions opac/tests/test_interface_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ def test_about_link_is_selected_for_about_view(self):
Verficamos que o link do menú "Sobre o Scielo" tem o css:
"selected" quando acessamos a view "about"
"""
response = self.client.get(url_for('main.about_collection'))
with current_app.app_context():
collection = utils.makeOneCollection({'name': 'dummy collection'})
response = self.client.get(url_for('main.about_collection'))

self.assertStatus(response, 200)
self.assertTemplateUsed('collection/about.html')
expected_anchor = u'<a href="/collection/about"\n class="btn single dropdown-toggle selected">\n <span class="glyphBtn infoMenu"></span>\n <span class="hidden-sm">Sobre o SciELO</span>'
self.assertIn(expected_anchor, response.data.decode('utf-8'))
self.assertStatus(response, 200)
self.assertTemplateUsed('collection/about.html')
expected_anchor = u'<a href="/collection/about"\n class="btn single dropdown-toggle selected">\n <span class="glyphBtn infoMenu"></span>\n <span class="hidden-sm">Sobre o SciELO</span>'
self.assertIn(expected_anchor, response.data.decode('utf-8'))

# Hamburger Menu
def test_links_in_hamburger_menu(self):
Expand Down
9 changes: 9 additions & 0 deletions opac/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,15 @@ def makeOneJournal(attrib=None):
default_id = attrib.get('_id', str(uuid4().hex))
default_title = "journal-%s" % default_id

if 'social_networks' in attrib.keys():
social_networks = []
for sn in attrib['social_networks']:
social_account = models.SocialNetwork(
account=sn['account'],
network=sn['network'])
social_networks.append(social_account)
attrib['social_networks'] = social_networks

journal = {
'_id': default_id,
'jid': attrib.get('jid', default_id),
Expand Down
14 changes: 7 additions & 7 deletions opac/webapp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@
import jinja_filters
from opac_schema.v1.models import Collection, Sponsor, Journal, Issue, Article, Resource, News, Pages


login_manager = LoginManager()
assets = Environment()
dbmongo = MongoEngine()
dbsql = SQLAlchemy()
mail = Mail()
babel = Babel()

login_manager = LoginManager()
login_manager.session_protection = 'strong'
login_manager.login_view = 'admin.login_view'


def create_app():
app = Flask(__name__,
Expand All @@ -36,6 +34,10 @@ def create_app():
# Configurações
app.config.from_object('webapp.config.default') # Configuração basica
app.config.from_envvar('OPAC_CONFIG', silent=True) # configuração do ambiente
# login
login_manager.session_protection = 'strong'
login_manager.login_view = 'admin.login_view'
login_manager.init_app(app)

# Minificando o HTML
if not app.config['DEBUG']:
Expand All @@ -62,9 +64,7 @@ def create_app():
assets.init_app(app)
# i18n
babel.init_app(app)
# login
login_manager.init_app(app)

# Debug Toolbar
if app.config['DEBUG']:
# Toolbar
from flask_debugtoolbar import DebugToolbarExtension
Expand Down
18 changes: 18 additions & 0 deletions opac/webapp/config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,21 @@
'url': 'http://blog.scielo.org/en/feed/',
},
}

# paineis do flask-debug-toolbar somente ativos quando DEBUG = True

DEBUG_TB_PANELS = [
# default:
'flask_debugtoolbar.panels.versions.VersionDebugPanel',
'flask_debugtoolbar.panels.timer.TimerDebugPanel',
'flask_debugtoolbar.panels.headers.HeaderDebugPanel',
'flask_debugtoolbar.panels.request_vars.RequestVarsDebugPanel',
'flask_debugtoolbar.panels.config_vars.ConfigVarsDebugPanel',
'flask_debugtoolbar.panels.template.TemplateDebugPanel',
'flask_debugtoolbar.panels.sqlalchemy.SQLAlchemyDebugPanel',
'flask_debugtoolbar.panels.logger.LoggingPanel',
'flask_debugtoolbar.panels.route_list.RouteListDebugPanel',
'flask_debugtoolbar.panels.profiler.ProfilerDebugPanel',
# Mongo:
'flask_mongoengine.panels.MongoDebugPanel'
]
7 changes: 4 additions & 3 deletions opac/webapp/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ def url_external(endpoint, **kwargs):
def add_collection_to_g():
if not hasattr(g, 'collection'):
try:
g.collection = controllers.get_current_collection()
collection = controllers.get_current_collection()
setattr(g, 'collection', collection)
except Exception, e:
# discutir o que fazer aqui
g.collection = {}
setattr(g, 'collection', {})


@babel.localeselector
Expand Down Expand Up @@ -515,7 +516,7 @@ def about_collection():

context = {}

for page in g.collection.get('about', []):
for page in getattr(g.collection, 'about', []):
if page.language == language:
context = {'content': page.content}

Expand Down
55 changes: 38 additions & 17 deletions opac/webapp/templates/journal/includes/contact_footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,54 @@
<span class="glyphBtn pin"></span>
</div>
<div class="col-md-10 col-sm-9">
<strong>{{ journal['publisher_name'] }}</strong>
{% if journal['publisher_address'] %}
{{ journal['publisher_address'] }} -
<strong>{{ journal.publisher_name }}</strong>
{% if journal.publisher_address %}
{{ journal.publisher_address }} -
{% endif %}
{% if journal['publisher_city'] %}
{{ journal['publisher_city'] }} -
{% if journal.publisher_city %}
{{ journal.publisher_city }} -
{% endif %}
{% if journal['publisher_state'] %}
{{ journal['publisher_state'] }} -
{% if journal.publisher_state %}
{{ journal.publisher_state }} -
{% endif %}
{% if journal['publisher_country'] %}
{{ journal['publisher_country'] }} <br/>
{% if journal.publisher_country %}
{{ journal.publisher_country }} <br/>
{% endif %}
{% if journal['publisher_telephone'] %}
Tel/Fax: {{ journal['publisher_telephone'] }}
{% if journal.publisher_telephone %}
Tel/Fax: {{ journal.publisher_telephone }}
{% endif %}
</div>
</div>
<div class="col-md-4 col-sm-4 journalLinks">
<a href="#" class="showTooltip" title="Facebook"><span class="glyphBtn bigFacebook"></span></a>
<a href="#" class="showTooltip" title="Twitter"><span class="glyphBtn bigTwitter"></span></a>
<a href="#" class="showTooltip" title="Google+"><span class="glyphBtn bigGooglePlus"></span></a>
<span class="text">{% trans %}Siga este periódico nas redes sociais{% endtrans %}</span>
{% for sn in journal.social_networks %}
<a href="{{sn.account}}" data-toggle="tooltip" title="{{sn.network|title}}">
<span
{% with network = sn.network|lower %}
{% if network == 'twitter' %}
class="glyphBtn bigTwitter"
{% elif network == 'facebook' %}
class="glyphBtn bigFacebook"
{% elif network == 'google+' or network == 'google' %}
class="glyphBtn bigGooglePlus"
{% else %}
class="glyphBtn"
{% endif %}
{% endwith %}
>
</span>
</a>
{% if loop.last %}
<span class="text">{% trans %}Siga este periódico nas redes sociais{% endtrans %}</span>
{% endif %}
{% endfor %}
</div>
<div class="col-md-3 col-sm-3 journalLinks">
<a href="{{ url_for('main.journal_feed', journal_id=journal.jid)}}" class="showTooltip" title="Atom" target="_blank"><span class="glyphBtn bigRSS"></span></a>
<span class="text" style="width: 70%;">{% trans %}Acompanhe os números deste periódico no seu leitor de RSS{% endtrans %}</span>
<a href="{{ url_for('main.journal_feed', journal_id=journal.jid)}}" data-toggle="tooltip" title="Atom" target="_blank">
<span class="glyphBtn bigRSS"></span>
</a>
<span class="text" style="width: 70%;">
{% trans %}Acompanhe os números deste periódico no seu leitor de RSS{% endtrans %}
</span>
</div>
<div class="clearfix"></div>
</div>
Expand Down

0 comments on commit 7e6cc97

Please sign in to comment.