Skip to content

Commit

Permalink
Fixed merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
cblignaut committed Jul 7, 2017
2 parents 0980eca + 3992aee commit e987926
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 52 deletions.
13 changes: 13 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Authors
=======

Praekelt.Org
------------
* Saeed Marzban
* Mitso Qalaba

Praekelt Consulting
-------------------
* Cilliers Blignaut


5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,8 @@ CHANGE LOG
0.0.1
-----
- initial release

1.0.0
-----
- Updated README.md
- Disable Recent and Popular Tip Views if no tips have been published.
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

81 changes: 81 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
molo.yourtips
#############
.. image:: https://travis-ci.org/praekeltfoundation/molo.yourtips.svg
:target: https://travis-ci.org/praekeltfoundation/molo.yourtips
.. image:: https://img.shields.io/pypi/v/molo.yourtips.svg
:target: https://pypi.python.org/pypi/molo.yourtips

**This feature enables youth to share short tips with one another.**

.. contents:: Table of Contents
:depth: 1

Requirements
============

#. django >= 1.8

#. molo.core >= 5.5.0

#. django-secretballot >= 0.7.0

#. django-likes >= 1.11

Prerequisite
============
#. Install or add ``django-likes`` to your Python path.

#. Configure ``django-secretballot`` as described `here <http://pypi.python.org/pypi/django-secretballot/>`_.

#. Add ``likes`` to your ``INSTALLED_APPS`` setting.

#. Add likes url include to your project's ``urls.py`` file::

url(r'^likes/',
include('likes.urls',
namespace='likes',
app_name='likes')),

#. Add ``likes.middleware.SecretBallotUserIpUseragentMiddleware`` to your ``MIDDLEWARE_CLASSES`` setting, i.e.::

MIDDLEWARE_CLASSES = (
...other middleware classes...
"likes.middleware.SecretBallotUserIpUseragentMiddleware",
)

#. Add ``django.core.context_processors.request`` to your ``TEMPLATE_CONTEXT_PROCESSORS`` setting, i.e.::

TEMPLATE_CONTEXT_PROCESSORS = (
...other context processors...
"django.core.context_processors.request",
)

Installation
============

#. pip install molo.yourtips

#. Add ``molo.yourtips`` to your ``INSTALLED_APPS`` settings.

#. Add yourtips url include to your project's ``urls.py`` file::

url(r'^yourtips/', include('molo.yourtips.urls',
namespace='molo.yourtips')),

#. Create and publish a YourTips page on the CMS. By adding the YourTips page the

Feature List
============

#. This feature enables youth to share short (twitter length - 140 characters) tips on the platform with one another.
#. User submitted tips are curated by content managers and published on the platform.
#. Users can interact with published tips by liking each others tips or sharing (requires consent from author) on facebook or twitter.

YourTips Settings
=================

#. Homepage Banner Copy
-----------------------
#. By default the homepage banner copy is ``Do you have advice you can share with other youth on relationships?``.
#. The homepage banner copy by adding the copy the yourtips settings.

2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.0.1
1.0.0
1 change: 1 addition & 0 deletions molo/yourtips/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class YourTip(TranslatablePageMixinNotRoutable, Page):

homepage_action_copy = models.CharField(
null=True, blank=True,
verbose_name="Homepage Banner Copy",
max_length=255)

def get_effective_extra_style_hints(self):
Expand Down
41 changes: 23 additions & 18 deletions molo/yourtips/templates/yourtips/your_tip.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,28 @@
</li>
</ul>
</div>
<ul class="yourtips-menu">
<li class="yourtips-menu__item">
<a href="{% url 'molo.yourtips:recent_tips' %}" class="call-to-action__nav-item">
{% trans "Recent Tips" %}
</a>
</li>
<li class="yourtips-menu__item">
<a href="{% url 'molo.yourtips:popular_tips' %}" class="call-to-action__nav-item">
{% trans "Popular Tips" %}
</a>
</li>
<li class="yourtips-menu__item">
<a href="{% url 'molo.yourtips:tip_entry' 'your-tips-page' %}" class="call-to-action__nav-item">
{% trans "Submit a Tip!" %}

</a>
</li>
</ul>
<div class="yourtips">
<ul class="yourtips-menu">
{% if your_tip.get_number_of_tips %}
<li class="yourtips-menu__item">
<a href="{% url 'molo.yourtips:recent_tips' %}" class="call-to-action__nav-item">
{% trans "Recent Tips" %}
</a>
</li>
{% endif %}
{% if your_tip.get_number_of_popular_tips %}
<li class="yourtips-menu__item">
<a href="{% url 'molo.yourtips:popular_tips' %}" class="call-to-action__nav-item">
{% trans "Popular Tips" %}
</a>
</li>
{% endif %}
<li class="yourtips-menu__item">
<a href="{% url 'molo.yourtips:tip_entry' 'your-tips-page' %}" class="call-to-action__nav-item">
{% trans "Submit a Tip!" %}
</a>
</li>
</ul>
</div>
</div>
{% endblock %}
5 changes: 3 additions & 2 deletions molo/yourtips/templates/yourtips/your_tips_on_homepage.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% load wagtailcore_tags wagtailimages_tags static core_tags i18n %}
{% load wagtailcore_tags wagtailimages_tags static core_tags tip_tags i18n %}
{% block content %}
{% if article_tip %}
{% get_your_tip as your_tip %}
{% if article_tip and your_tip.get_number_of_tips %}
<div class="yourtips">
<h1 class="heading heading--yourtips">
{% trans "Tip of the Day" %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{% load wagtailcore_tags wagtailimages_tags static core_tags i18n %}
{% load wagtailcore_tags wagtailimages_tags static tip_tags core_tags i18n %}
{% block content %}
{% get_your_tip as your_tip %}
<div class="yourtips">
{% if most_popular_tip %}
{% if most_popular_tip and your_tip.get_number_of_popular_tips %}
<!--This should only be active when it has a like and more -->
<h2 class="heading heading--yourtips-title heading--line-break">
{% trans "Most popular tip" %}</h2>
Expand All @@ -18,7 +19,7 @@ <h3 class="yourtips__description">{{ block.value }}</h3>
</div>
{% endif %}

{% if most_recent_tip %}
{% if most_recent_tip and your_tip.get_number_of_tips %}
<h2 class="heading heading--yourtips-title">{% trans "Most recent tip" %}</h2>
<div class="yourtips-list">
<div class="yourtips-list__item">
Expand Down
22 changes: 0 additions & 22 deletions molo/yourtips/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,3 @@ def test_yourtips_recent_tip_view(self):
response = self.client.get(reverse('molo.yourtips:recent_tips'))
self.assertContains(response, 'Test')
self.assertContains(response, 'test body')

def test_yourtips_popular_tip_view(self):
self.client.login(
username=self.superuser_name,
password=self.superuser_password
)

entry = YourTipsEntry.objects.create(
optional_name='Test',
tip_text='test body',
allow_share_on_social_media=True,
)

self.client.get(
'/django-admin/yourtips/yourtipsentry/%d/convert/' % entry.id
)
article = YourTipsArticlePage.objects.get(title='Tip-%s' % entry.id)
article.save_revision().publish()

response = self.client.get(reverse('molo.yourtips:popular_tips'))
self.assertContains(response, 'Test')
self.assertContains(response, 'test body')
3 changes: 2 additions & 1 deletion molo/yourtips/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ def get_queryset(self, *args, **kwargs):
main = self.request.site.root_page
context = {'request': self.request}
locale = self.request.LANGUAGE_CODE
articles = YourTipsArticlePage.objects.all(
articles = YourTipsArticlePage.objects.filter(
votes__gte=1
).descendant_of(main).order_by('-total_upvotes')
return get_pages(context, articles, locale)

Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

from setuptools import setup, find_packages

description_files = ["README.rst", "AUTHORS.rst", "CHANGES.rst"]

here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.md')) as f:
readme = f.read()

with open(os.path.join(here, 'requirements.txt')) as f:
requires = filter(None, f.readlines())
Expand All @@ -19,7 +19,7 @@
version=version,
description=('This feature enables youth to share short tips with one '
'another'),
long_description=readme,
long_description="".join([open(f, "r").read() for f in description_files]),
classifiers=[
"Programming Language :: Python",
"Framework :: Django",
Expand Down

0 comments on commit e987926

Please sign in to comment.