add file icons
This commit is contained in:
parent
abf0abfb93
commit
2a9abc8a54
3 changed files with 15 additions and 1 deletions
6
build
6
build
|
@ -26,4 +26,10 @@ env/bin/pip install -r requirements.txt
|
||||||
npm install
|
npm install
|
||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
|
echo "Getting icons..."
|
||||||
|
git clone git@github.com:teambox/Free-file-icons static/build/img/temp || echo "already exists"
|
||||||
|
cp static/build/img/temp/512px/* static/build/img/icons/
|
||||||
|
rm -rf static/build/img/temp
|
||||||
|
|
||||||
|
|
||||||
env/bin/python manage.py collectstatic --noinput
|
env/bin/python manage.py collectstatic --noinput
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run lint",
|
"test": "npm run lint",
|
||||||
"lint": "eslint 'static/src/js/'",
|
"lint": "eslint 'static/src/js/'",
|
||||||
"create-build-dirs": "mkdir -p static/build/js static/build/css static/build/fonts static/build/img",
|
"create-build-dirs": "mkdir -p static/build/js static/build/css static/build/fonts static/build/img/icons",
|
||||||
"build-scss": "bash scripts/build-scss.sh",
|
"build-scss": "bash scripts/build-scss.sh",
|
||||||
"build-js": "bash scripts/build-js.sh",
|
"build-js": "bash scripts/build-js.sh",
|
||||||
"build-fonts": "cp -R node_modules/bootstrap-sass/assets/fonts/bootstrap/* static/build/fonts/ && cp -R node_modules/font-awesome/fonts static/build",
|
"build-fonts": "cp -R node_modules/bootstrap-sass/assets/fonts/bootstrap/* static/build/fonts/ && cp -R node_modules/font-awesome/fonts static/build",
|
||||||
|
|
|
@ -4,6 +4,8 @@ from admin_resumable.fields import ModelAdminResumableFileField
|
||||||
from shortuuidfield import ShortUUIDField
|
from shortuuidfield import ShortUUIDField
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
|
import os.path
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
class SharedFile(models.Model):
|
class SharedFile(models.Model):
|
||||||
|
@ -23,6 +25,12 @@ class SharedFile(models.Model):
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse('files:file', args=(self.short_id,))
|
return reverse('files:file', args=(self.short_id,))
|
||||||
|
|
||||||
|
def get_type_image(self):
|
||||||
|
extension = self.get_original_filename().split('.')[-1]
|
||||||
|
icon_file = os.path.join(settings.STATICFILES_DIRS[0], 'img', 'icons', "{0}.png".format(extension))
|
||||||
|
filename = extension if os.path.exists(icon_file) else "_page"
|
||||||
|
return os.path.join(settings.STATIC_URL, 'img', 'icons', "{0}.png".format(filename))
|
||||||
|
|
||||||
|
|
||||||
class FileToken(models.Model):
|
class FileToken(models.Model):
|
||||||
valid_time = timedelta(minutes=5)
|
valid_time = timedelta(minutes=5)
|
||||||
|
|
Reference in a new issue