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

new minjus #53

Merged
merged 4 commits into from
Oct 22, 2016
Merged
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
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ files:
"DB_NAME": "manolo",
"DB_PORT": "5432",
"DB_HOST": "localhost"
"premium_institutions": [
"minjus"
]
}

.. |Pypi index| image:: https://badge.fury.io/py/django-manolo.svg
Expand Down
11 changes: 11 additions & 0 deletions config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"SECRET_KEY": "secret key",
"DB_USER": "postgres",
"DB_PASS": "db pass",
"DB_NAME": "manolo",
"DB_PORT": "5432",
"DB_HOST": "localhost",
"premium_institutions": [
"minjus"
]
}
2 changes: 1 addition & 1 deletion manolo/apps/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def setUp(self):

data = []
for i in range(500):
m = Visitor(full_name='Romulo', id=i, date=datetime.date.today())
m = Visitor(full_name='Romulo', id=i, date=datetime.date(2015, 1, 1))
data.append(m)
Visitor.objects.bulk_create(data)

Expand Down
4 changes: 4 additions & 0 deletions manolo/apps/visitors/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

from haystack.forms import HighlightedSearchForm

from manolo.settings.production import PREMIUM_INSTITUTIONS


class ManoloForm(HighlightedSearchForm):
def search(self, premium):
Expand All @@ -18,6 +20,8 @@ def search(self, premium):
today = datetime.datetime.today()
six_months_ago = today - datetime.timedelta(days=180)
sqs = sqs.filter(date__lte=six_months_ago)
for institution in PREMIUM_INSTITUTIONS:
sqs = sqs.exclude(institution=institution)

if self.load_all:
sqs = sqs.load_all()
Expand Down
1 change: 1 addition & 0 deletions manolo/apps/visitors/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
class VisitorIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
date = indexes.DateField(model_attr='date', null=True)
institution = indexes.CharField(model_attr="institution", null=True)

def get_model(self):
return Visitor
Expand Down
2 changes: 1 addition & 1 deletion manolo/apps/visitors/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_search(self):
def test_pagination(self):
data = []
for i in range(500):
m = Visitor(full_name='Romulo', id=i, date=datetime.date.today())
m = Visitor(full_name='Romulo', id=i, date=datetime.date(2015, 1, 1))
data.append(m)
Visitor.objects.bulk_create(data)

Expand Down
3 changes: 2 additions & 1 deletion manolo/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def get_secret(setting, secrets=secrets):
raise ImproperlyConfigured(error_msg)

SECRET_KEY = get_secret('SECRET_KEY')
PREMIUM_INSTITUTIONS = get_secret('premium_institutions')

DATABASES = {
'default': {
Expand All @@ -42,5 +43,5 @@ def get_secret(setting, secrets=secrets):
'PASSWORD': get_secret('DB_PASS'),
'HOST': get_secret('DB_HOST'),
'PORT': get_secret('DB_PORT'),
}
}
}
10 changes: 6 additions & 4 deletions manolo/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ <h3 class="text-left">La base de datos de Manolo <i class="fa fa-database"></i><

<p class="text-left">Contiene <span class="label label-primary"><b>{{ count|intcomma }}</b></span> registros de visitas de las siguientes instituciones:</p>
<ol class="list-group text-left">
<li class="list-group-item">14. <a href="/search/?q=congreso">Congreso de la República</a>
<span class="label label-danger"><b>Nuevo</b></span></li>
<li class="list-group-item">13. Ministerio de <a href="/search/?q=minsa">Salud</a>
<span class="label label-danger"><b>Nuevo</b></span></li>
<li class="list-group-item">15. <a href="/search/?q=minjus">Ministerio de Justicia</a>
<span class="label label-danger"><b>Nuevo</b></span>
<span class="label label-info"><b>Premium users: <a href="/accounts/login/">Login</a></b></span>
</li>
<li class="list-group-item">14. <a href="/search/?q=congreso">Congreso de la República</a></li>
<li class="list-group-item">13. Ministerio de <a href="/search/?q=minsa">Salud</a></li>
<li class="list-group-item">12. Ministerio de <a href="/search/?q=minedu">Educación</a></li>
<li class="list-group-item">11. Ministerio de <a href="/search/?q=mincu">Cultura (MINCU)</a></li>
<li class="list-group-item">10. Ministerio de <a href="/search/?q=minagr">Agricultura (MINAGR)</a></li>
Expand Down