Skip to content

Commit

Permalink
Merge pull request #13 from FutureProofGames/release/1.1.1
Browse files Browse the repository at this point in the history
Release 1.1.1
  • Loading branch information
averymd committed Apr 2, 2019
2 parents 76317db + 0a1386a commit 7ea318e
Show file tree
Hide file tree
Showing 10 changed files with 729 additions and 83 deletions.
695 changes: 674 additions & 21 deletions LICENSE

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
@@ -1,5 +1,5 @@
# django-presskit
A port of Rami Ismail's presskit()/dopresskit to Django.
A port of Rami Ismail's [presskit()/dopresskit](https://github.com/ramiismail/dopresskit) to Django.

[![Build Status](https://travis-ci.com/FutureProofGames/django-presskit.svg?branch=develop)](https://travis-ci.com/FutureProofGames/django-presskit) [![Coverage Status](https://coveralls.io/repos/github/FutureProofGames/django-presskit/badge.svg?branch=develop)](https://coveralls.io/github/FutureProofGames/django-presskit?branch=develop)

Expand Down Expand Up @@ -69,4 +69,4 @@ If you're using nginx and one of your slugs has more than ten underscores, add a

## Contributing

When submitting issues or pull requests, please adhere to our (Code of Conduct)[CODE_OF_CONDUCT.md].
When submitting issues or pull requests, please adhere to our [Code of Conduct](CODE_OF_CONDUCT.md).
28 changes: 28 additions & 0 deletions django_presskit/migrations/0004_auto_20190123_0157.py
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2019-01-23 01:57
from __future__ import unicode_literals

from django.db import migrations
import django.db.models.deletion
import filer.fields.file


class Migration(migrations.Migration):

dependencies = [
('filer', '0010_auto_20180414_2058'),
('django_presskit', '0003_auto_20181002_1915'),
]

operations = [
migrations.AddField(
model_name='company',
name='asset_archive',
field=filer.fields.file.FilerFileField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='filer.File'),
),
migrations.AddField(
model_name='project',
name='asset_archive',
field=filer.fields.file.FilerFileField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='filer.File'),
),
]
16 changes: 16 additions & 0 deletions django_presskit/migrations/0005_merge_20190402_1106.py
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2019-04-02 11:06
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('django_presskit', '0004_auto_20190202_2017'),
('django_presskit', '0004_auto_20190123_0157'),
]

operations = [
]
2 changes: 2 additions & 0 deletions django_presskit/models.py
Expand Up @@ -73,6 +73,7 @@ class Company(models.Model):
contacts = models.ManyToManyField('Contact', blank=True)
datetime_created = models.DateTimeField(auto_now_add=True)
datetime_updated = models.DateTimeField(auto_now=True)
asset_archive = FilerFileField(blank=True,null=True)

def __unicode__(self):
return self.title
Expand Down Expand Up @@ -238,6 +239,7 @@ class Project(models.Model):
company = models.ForeignKey(Company)
datetime_created = models.DateTimeField(auto_now_add=True)
datetime_updated = models.DateTimeField(auto_now=True)
asset_archive = FilerFileField(blank=True,null=True)
my_order = models.PositiveIntegerField(default=0, blank=False, null=False)

class Meta(object):
Expand Down
5 changes: 3 additions & 2 deletions django_presskit/templates/django_presskit/company.html
Expand Up @@ -306,7 +306,9 @@ <h2>Images</h2>
<a href="{{ image.content.url }}"><img class="attached-image" src="{% thumbnail image.content 250x250 crop %}"></a>
{% endfor %}
<p>Many more images are available for {{company.title}}. <a href="#contact">Contact us</a> if you have a specific request!</p>
<p><a href="{% url 'django_presskit:company_zip' company.slug %}">Download as ZIP archive</a></p>
{% if company.asset_archive %}
<p><a href="{{company.asset_archive.url}}" download>Download Archive</a></p>
{% endif %}
</section>
{% endif %}

Expand All @@ -316,7 +318,6 @@ <h2>Logo &amp; Icon</h2>
{% for image in company.logos.all %}
<a href="{{ image.content.url }}"><img class="attached-image" src="{% thumbnail image.content 250x250 crop %}"></a>
{% endfor %}
<p><a href="{% url 'django_presskit:company_logo_zip' company.slug %}">Download as ZIP archive</a></p>
</section>
{% endif %}

Expand Down
5 changes: 3 additions & 2 deletions django_presskit/templates/django_presskit/project.html
Expand Up @@ -282,7 +282,9 @@ <h2>Images</h2>
{% for image in project.images.all %}
<a href="{{ image.content.url }}"><img class="attached-image" src="{% thumbnail image.content 250x250 crop %}"></a>
{% endfor %}
<p><a href="{% url 'django_presskit:project_zip' project.slug %}">Download as ZIP archive</a></p>
{% if project.asset_archive %}
<p><a href="{{project.asset_archive.url}}" download>Download Archive</a></p>
{% endif %}
</section>
{% endif %}

Expand All @@ -292,7 +294,6 @@ <h2>Logo &amp; Icon</h2>
{% for image in project.logos.all %}
<a href="{{ image.content.url }}"><img class="attached-image" src="{% thumbnail image.content 250x250 crop %}"></a>
{% endfor %}
<p><a href="{% url 'django_presskit:project_logo_zip' project.slug %}">Download as ZIP archive</a></p>
</section>
{% endif %}

Expand Down
4 changes: 0 additions & 4 deletions django_presskit/urls.py
Expand Up @@ -5,11 +5,7 @@
urlpatterns = [
url(r'^$', views.presskit, name='default'),
url(r'^(?P<company_slug>[-\w]+)/$', views.presskit, name='company'),
url(r'^(?P<company_slug>[-\w]+)/images.zip$', views.company_zip, name='company_zip'),
url(r'^(?P<company_slug>[-\w]+)/logos.zip$', views.company_logo_zip, name='company_logo_zip'),
url(r'^projects/(?P<project_slug>[-\w]+)/$', views.project, name='project'),
url(r'^projects/(?P<project_slug>[-\w]+)/data.xml$', views.project_xml, name='project_xml'),
url(r'^projects/(?P<project_slug>[-\w]+)/images/header.png$', views.project_header, name='project_header'),
url(r'^projects/(?P<project_slug>[-\w]+)/images.zip$', views.project_zip, name='project_zip'),
url(r'^projects/(?P<project_slug>[-\w]+)/logos.zip$', views.project_logo_zip, name='project_logo_zip'),
]
51 changes: 0 additions & 51 deletions django_presskit/views.py
Expand Up @@ -58,54 +58,3 @@ def project_header(request, project_slug):
return redirect(project.header_image.url, permanent=True)
else:
raise Http404("No header image for this project.")

## From https://stackoverflow.com/a/51655455
def _zipresponse(filelist, zipfilename):
byte_data = BytesIO()
zip_file = zipfile.ZipFile(byte_data, "w")

for file in filelist:
filename = os.path.basename(os.path.normpath(file))
zip_file.write(file, filename)
zip_file.close()

response = HttpResponse(byte_data.getvalue(), content_type='application/zip')
response['Content-Disposition'] = 'attachment; filename="' + zipfilename + '.zip"'

return response


@cache_page(60 * 15)
def company_zip(request, company_slug):
company = Company.objects.get(slug=company_slug)
return _zipresponse(
(file.content.path for file in company.images.all()),
company.title
)


@cache_page(60 * 15)
def company_logo_zip(request, company_slug):
company = Company.objects.get(slug=company_slug)
return _zipresponse(
(file.content.path for file in company.logos.all()),
company.title
)


@cache_page(60 * 15)
def project_zip(request, project_slug):
project = Project.objects.get(slug=project_slug)
return _zipresponse(
(file.content.path for file in project.images.all()),
project.title
)


@cache_page(60 * 15)
def project_logo_zip(request, project_slug):
project = Project.objects.get(slug=project_slug)
return _zipresponse(
(file.content.path for file in project.logos.all()),
project.title
)
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="django_presskit",
version="1.1.0",
version="1.1.1",
author="Future Proof Games",
author_email="info@futureproofgames.com",
description="A port of presskit() to Django",
Expand Down

0 comments on commit 7ea318e

Please sign in to comment.