Skip to content

Commit

Permalink
annoucement handled in just one commit! :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Khedesh committed Aug 4, 2016
1 parent af89d30 commit 5f680d5
Show file tree
Hide file tree
Showing 6 changed files with 93 additions and 6 deletions.
3 changes: 2 additions & 1 deletion announcements/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
from . import views

urlpatterns = [
url(r"^/?$", views.show_announcements, name='show-announcements')
url(r"^/?$", views.all_announcements, name='all-announcements'),
url(r"^(?P<announcement_id>[0-9]+)/show/$", views.show_announcement, name='show-announcement')
]
28 changes: 25 additions & 3 deletions announcements/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
from django.shortcuts import render
from django.http import HttpResponse
from django.http import HttpResponse, Http404
from shamsi.templatetags.shamsi_template_tags import pdatetime

from .models import Announcement


# Create your views here.

def show_announcements(request):
return HttpResponse("Annoucments is under construction...")
def all_announcements(request):
announcements = Announcement.objects.order_by('-id')
for an in announcements:
an.date = pdatetime(an.date)

return render(request, 'announcements/announcements.html', {
'announcements': announcements,
})


def show_announcement(request, announcement_id):
try:
announcement = Announcement.objects.get(pk=announcement_id)
announcement.date = pdatetime(announcement.date)

except Announcement.DoesNotExist:
raise Http404("Announcement does not exist")

return render(request, 'announcements/announcement.html', {
'announcement': announcement,
})
2 changes: 1 addition & 1 deletion shamsi/date/shamsi_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ def exp(self, num, zf=2):
:param zf:
:return:
"""
return unicode(num).zfill(zf)
return str(num).zfill(zf)

def __eq__(self, other):
return (self.year, self.month, self.day, self.hour, self.minute, self.second, self.jd) == (
Expand Down
29 changes: 29 additions & 0 deletions templates/announcements/announcement.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends 'base.html' %}
{% load static %}
{% load gravatar %}
{% load shamsi_template_tags %}
{% block title %} اطلاعیه - {{ announcement.title }}{% endblock title %}

{% block size0 %}col-lg-10 col-md-10{% endblock %}
{% block size1 %}col-lg-6 col-md-6{% endblock %}
{% block size2 %}col-lg-6 col-md-6{% endblock %}
{% block size3 %}col-lg-6 col-md-6{% endblock %}

{% block body %}
<div class="panel panel-default panel-background-color">
<div class="panel-heading dir-rtl">
<span class="request-id glyphicon glyphicon-tag"></span>
<span class="panel-title"> {{ announcement.title }} </span>
<span id="announcement-countdown-{{ announcement.id }}" class="pull-left poll-countdown">
{{ announcement.date }}
</span>
</div>

<div class="panel-body dir-rtl">
{{ announcement.body|safe }}

</div>


</div>
{% endblock %}
35 changes: 35 additions & 0 deletions templates/announcements/announcements.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% extends 'base.html' %}
{% load static %}
{% load gravatar %}
{% load shamsi_template_tags %}
{% block title %} اطلاعیه‌ها {% endblock title %}

{% block size0 %}col-lg-10 col-md-10{% endblock %}
{% block size1 %}col-lg-6 col-md-6{% endblock %}
{% block size2 %}col-lg-6 col-md-6{% endblock %}
{% block size3 %}col-lg-6 col-md-6{% endblock %}

{% block body %}
<div class="panel panel-primary panel-background-color">
<div class="panel-heading dir-rtl"> اطلاعیه‌ها</div>
<div class="panel-body">
{% for announcement in announcements %}
<div class="panel panel-default dir-rtl">
<div class="panel-heading">
<a href="{% url 'show-announcement' announcement.id %}" target="_self" class="permanent link event-link"
data-id={{ announcement.id }}>
<span class="request-id glyphicon glyphicon-tag"></span>
<span class="panel-title">
{{ announcement.title }}
</span>
</a>
<span id="announcement-countdown-{{ announcement.id }}" class="pull-left poll-countdown">
{{ announcement.date }}
</span>

</div>
</div>
{% endfor %}
</div>
</div>
{% endblock %}
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
<li><a href="{% url 'requests' %}">رسیدگی به مشکلات برنامه درسی</a></li>
</ul>
</li>
<li><a href="{% url 'show-announcements' %}">اطلاعیه‌ها</a></li>
<li><a href="{% url 'all-announcements' %}">اطلاعیه‌ها</a></li>
<li><a href="{% url 'home' %}">اعضا</a></li>
<li><a href="{% url 'all-events' %}">رویداد‌ها</a></li>

Expand Down

0 comments on commit 5f680d5

Please sign in to comment.