Fix/implement image uploads
This commit is contained in:
parent
f0e53b56a5
commit
c691a7cff2
1
.gitignore
vendored
1
.gitignore
vendored
@ -4,3 +4,4 @@ __pycache__
|
|||||||
|
|
||||||
settings.py
|
settings.py
|
||||||
migrations
|
migrations
|
||||||
|
promo_uploads
|
||||||
|
@ -18,6 +18,7 @@ import markdown
|
|||||||
|
|
||||||
from django.contrib.staticfiles.storage import staticfiles_storage
|
from django.contrib.staticfiles.storage import staticfiles_storage
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
@ -32,6 +33,7 @@ def environment(**options):
|
|||||||
'localtime': lambda dt: timezone.localtime(dt).strftime('%Y-%m-%d %H:%M'),
|
'localtime': lambda dt: timezone.localtime(dt).strftime('%Y-%m-%d %H:%M'),
|
||||||
'static': staticfiles_storage.url,
|
'static': staticfiles_storage.url,
|
||||||
'url': reverse,
|
'url': reverse,
|
||||||
|
'MEDIA_URL': settings.MEDIA_URL,
|
||||||
})
|
})
|
||||||
env.filters.update({
|
env.filters.update({
|
||||||
'markdown': lambda x: Markup(markdown.markdown(x))
|
'markdown': lambda x: Markup(markdown.markdown(x))
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.conf.urls.static import static
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
|
|
||||||
@ -23,4 +25,4 @@ urlpatterns = [
|
|||||||
path('treasury/', include('sstreasury.urls')),
|
path('treasury/', include('sstreasury.urls')),
|
||||||
path('promotions/', include('sspromotions.urls')),
|
path('promotions/', include('sspromotions.urls')),
|
||||||
path('', include('ssmain.urls')),
|
path('', include('ssmain.urls')),
|
||||||
]
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
{% block maincontent %}
|
{% block maincontent %}
|
||||||
<h1>{% if request.resolver_match.url_name == 'bulletin_new' %}New{% else %}Edit{% endif %} bulletin item</h1>
|
<h1>{% if request.resolver_match.url_name == 'bulletin_new' %}New{% else %}Edit{% endif %} bulletin item</h1>
|
||||||
|
|
||||||
<form class="ui form" method="POST">
|
<form class="ui form" method="POST" enctype="multipart/form-data">
|
||||||
<div class="ui disabled inline grid field">
|
<div class="ui disabled inline grid field">
|
||||||
<label class="three wide column">ID</label>
|
<label class="three wide column">ID</label>
|
||||||
<input class="eleven wide column" type="text" name="id" value="{{ item.id if item.id != None else '' }}">
|
<input class="eleven wide column" type="text" name="id" value="{{ item.id if item.id != None else '' }}">
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<a href="#"><img src="{{ item.image }}" alt="{{ item.title }}"></a>
|
{% if item.link %}<a href="{{ item.link }}">{% endif %}<img src="{{ MEDIA_URL }}{{ item.image }}" alt="{{ item.title }}">{% if item.link %}</a>{% endif %}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -71,7 +71,7 @@
|
|||||||
<th>
|
<th>
|
||||||
<b><h5>{{ item.title }}</h5></b>
|
<b><h5>{{ item.title }}</h5></b>
|
||||||
<p>{{ item.content | markdown }}</p>
|
<p>{{ item.content | markdown }}</p>
|
||||||
{% if item.link %}<p><a href="{{ item.link }}">Click Here ›</a></p>{% endif %}
|
{% if item.link %}<p><a href="{{ item.link }}">Read more ›</a></p>{% endif %}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
@ -99,10 +99,10 @@
|
|||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
{% if item.image %}{% if item.link %}<a href="{{ item.link }}">{% endif %}<img src="{{ item.image }}" alt="{{ item.title }}">{% if item.link %}</a>{% endif %}<br>{% endif %}
|
{% if item.image %}{% if item.link %}<a href="{{ item.link }}">{% endif %}<img src="{{ MEDIA_URL }}{{ item.image }}" alt="{{ item.title }}">{% if item.link %}</a>{% endif %}<br>{% endif %}
|
||||||
<b><h5>{{ item.title }}</h5></b>
|
<b><h5>{{ item.title }}</h5></b>
|
||||||
<p>{{ item.content }}</p>
|
<p>{{ item.content }}</p>
|
||||||
{% if item.link %}<p><a href="{{ item.link }}">Click Here ›</a></p>{% endif %}
|
{% if item.link %}<p><a href="{{ item.link }}">Read more ›</a></p>{% endif %}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
Loading…
Reference in New Issue
Block a user