Skip to content

Commit

Permalink
update structure and add captcha
Browse files Browse the repository at this point in the history
  • Loading branch information
alishirmohammadi committed Nov 30, 2019
1 parent 7308d92 commit fa7de6b
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 51 deletions.
5 changes: 4 additions & 1 deletion apps/base/templates/charge_cash.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h2 class="mb-4 mx-2 px-4 text-white border-right-white">افزایش اعتبا
{% if completed == False %}
<label for="rules" class="font-weight-bold">اطلاعات را وارد کنید</label>
<div class="row text-black-50 justify-content-md-center">
<div class="col-6">
<div class="col-md-7">
<div class="row">
<div class="col">
<div class="card">
Expand All @@ -71,6 +71,9 @@ <h5 class="card-title">شارژ نقدی</h5>
<input type="number" class="form-control" id="amount"
name="amount">
</div>
<div class="form-group">
{{ form.as_p }}
</div>
<div class="form-group">
<input type="submit" class="btn btn-block btn-warning"
value="شارژ"/>
Expand Down
134 changes: 98 additions & 36 deletions apps/base/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,57 +111,119 @@ <h5 class="text-white mr-4">رزرو اتاق مطالعه</h5>
<!-- Members -->
<section class="bg-navy-blue py-5" id="members">
<div class="container">
<h2 class="mb-4 mx-2 px-4 text-white border-right-white">اعضای شورا</h2>
<div class="row" style="justify-content: space-evenly">
<div class="col-md-3 my-3 memberHidden">
<img src="{% static "img/members/mohammad_s.jpg" %}" class="rounded-top">
<h5 class="bg-primary text-white p-2 mb-0 text-center rounded-bottom">محمد شهیدی <span
class="badge badge-light">دبیر</span></h5>
</div>
<h2 class="mb-4 mx-2 px-4 text-white border-right-white">ساختار شورا</h2>

<h3 class="font-weight-bold text-white text-lg">دبیر</h3>
<div class="row">
<div class="col-md-3 my-3 memberHidden">
<img src="{% static "img/members/arshia.jpg" %}" class="rounded-top">
<h5 class="bg-primary text-white p-2 mb-0 text-center rounded-bottom">ارشیا مقیمی <span
class="badge badge-light">دبیر داخلی و عضو کمیتهٔ آموزش</span></h5>
<img src="{% static "img/members/amirhossein_h.jpg" %}" class="rounded">
<div class="carousel-caption">
<h4><span class="badge text-lg badge-light">امیرحسین هادیان
<span class="badge text-lg badge-dark">دبیر</span>
</span></h4>
</div>
</div>
<div class="col-md-3 my-3 memberHidden">
<img src="{% static "img/members/amirhossein_h.jpg" %}" class="rounded-top">
<h5 class="bg-primary text-white p-2 mb-0 text-center rounded-bottom">امیرحسین هادیان <span
class="badge badge-light">نائب دبیر</span></h5>
<img src="{% static "img/members/sorush.jpg" %}" class="rounded">
<div class="carousel-caption">
<h4><span class="badge text-lg badge-light">سروش وفایی‌تبار
<span class="badge text-lg badge-dark">نائب دبیر</span>
</span></h4>
</div>
</div>
</div>
<div class="row" style="justify-content: space-between">
<h3 class="font-weight-bold text-white text-lg" style="margin-top: 30px;">کمیتهٔ آموزش</h3>
<div class="row">
<div class="col-md-3 my-3 memberHidden">
<img src="{% static "img/members/amirhossein_a.jpg" %}" class="rounded-top">
<h5 class="bg-primary text-white p-2 mb-0 text-center rounded-bottom">امیرحسین عاصم یوسفی <span
class="badge badge-light">مسئول تأسیسات</span></h5>
<img src="{% static "img/members/hossein.jpg" %}" class="rounded">
<div class="carousel-caption">
<h4><span class="badge text-lg badge-light">حسین آقامحمدی
<span class="badge text-lg badge-dark">سرپرست</span>
</span></h4>
</div>
</div>
<div class="col-md-3 my-3 memberHidden">
<img src="{% static "img/members/ali.jpg" %}" class="rounded-top">
<h5 class="bg-primary text-white p-2 mb-0 text-center rounded-bottom">علی شیرمحمدی <span
class="badge badge-light">مسئول کمیتهٔ فنی</span></h5>
<img src="{% static "img/members/mohammad_a.jpg" %}" class="rounded">
<div class="carousel-caption">
<h4><span class="badge text-lg badge-light">محمد آذری
</span></h4>
</div>
</div>
<div class="col-md-3 my-3 memberHidden">
<img src="{% static "img/members/mohammad_a.jpg" %}" class="rounded-top">
<h5 class="bg-primary text-white p-2 mb-0 text-center rounded-bottom">محمد آذری<span
class="badge badge-light">مسئول کمیتهٔ آموزش </span></h5>
<img src="{% static "img/members/amirhossein_a.jpg" %}" class="rounded">
<div class="carousel-caption">
<h4><span class="badge text-lg badge-light">امیرحسین عاصم یوسفی
</span></h4>
</div>
</div>
</div>
<div class="row" style="justify-content: space-evenly">
<div class="col-md-3 my-3 memberHidden">
<img src="{% static "img/members/mahdi.jpg" %}" class="rounded-top">
<h5 class="bg-primary text-white p-2 mb-0 text-center rounded-bottom">مهدی حاجی‌محمدعلی <span
class="badge badge-light">مسئول مالی و عضو کمیتهٔ آموزش</span></h5>
<div class="row">
<div class="col-md-3">
<h3 class="font-weight-bold text-white text-lg" style="margin-top: 30px;">مسئول فنی</h3>
<div class="row">
<div class="col-md-12 my-6 memberHidden">
<img src="{% static "img/members/ali.jpg" %}" class="rounded">
<div class="carousel-caption">
<h4><span class="badge text-lg badge-light">علی شیرمحمدی
</span></h4>
</div>
</div>
</div>
</div>
<div class="col-md-3 my-3 memberHidden">
<img src="{% static "img/members/sorush.jpg" %}" class="rounded-top">
<h5 class="bg-primary text-white p-2 mb-0 text-center rounded-bottom">سروش وفایی‌تبار <span
class="badge badge-light">مسئول اموال و عضو کمیتهٔ فنی</span></h5>
<div class="col-md-3">
<h3 class="font-weight-bold text-white text-lg" style="margin-top: 30px;">مسئول تأسیسات</h3>
<div class="row">
<div class="col-md-12 my-6 memberHidden">
<img src="{% static "img/members/amirhossein_a.jpg" %}" class="rounded">
<div class="carousel-caption">
<h4><span class="badge text-lg badge-light">امیرحسین عاصم یوسفی
</span></h4>
</div>
</div>
</div>
</div>
<div class="col-md-3 my-3 memberHidden">
<img src="{% static "img/members/hossein.jpg" %}" class="rounded-top">
<h5 class="bg-primary text-white p-2 mb-0 text-center rounded-bottom">حسین آقامحمدی<span
class="badge badge-light">عضو کمیتهٔ فنی و آموزش</span></h5>
<div class="col-md-6">
<h3 class="font-weight-bold text-white text-lg" style="margin-top: 30px;">کمیتهٔ اموال</h3>
<div class="row">
<div class="col-md-6 my-6 memberHidden">
<img src="{% static "img/members/sorush.jpg" %}" class="rounded">
<div class="carousel-caption">
<h4><span class="badge text-lg badge-light">سروش وفایی‌تبار
<span class="badge text-lg badge-dark">سرپرست</span>
</span></h4>
</div>
</div>
<div class="col-md-6 my-6 memberHidden">
<img src="{% static "img/members/arshia.jpg" %}" class="rounded">
<div class="carousel-caption">
<h4><span class="badge text-lg badge-light">ارشیا مقیمی</span></h4>
</div>
</div>
</div>
</div>

</div>
<div class="row">
<div class="col-md-6">
<h3 class="font-weight-bold text-white text-lg" style="margin-top: 30px;">روابط عمومی</h3>
<div class="row">
<div class="col-md-6 my-6 memberHidden">
<img src="{% static "img/members/hossein.jpg" %}" class="rounded">
<div class="carousel-caption">
<h4><span class="badge text-lg badge-light">حسین آقامحمدی
<span class="badge text-lg badge-dark">سرپرست</span>
</span></h4>
</div>
</div>
<div class="col-md-6 my-6 memberHidden">
<img src="{% static "img/members/mohammad_s.jpg" %}" class="rounded">
<div class="carousel-caption">
<h4><span class="badge text-lg badge-light">محمد شهیدی</span></h4>
</div>
</div>
</div>
</div>

</div>
<div class="mt-4 text-center ">
<a href="#" class="btn btn-outline-light mx-auto" data-toggle="modal"
Expand Down
27 changes: 16 additions & 11 deletions apps/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,26 @@ def checkout_view(request):


@login_required
@user_passes_test(lambda u: u.is_staff)
def charge_cash(request):
if not request.user.is_staff:
return render(request, "charge_cash.html", {
"error": "شما دسترسی به این قسمت ندارید.",
"completed": True
})

amount = None
student_number = None

if request.POST:
form = FormWithCaptcha(request.POST)
if not form.is_valid():
return render(request, "charge_cash.html", {
"completed": False,
"error": "لطفا تیک من ربات نیستم را بزنید.",
"form": FormWithCaptcha()
})
try:
amount = int(request.POST.get("amount"))
student_number = int(request.POST.get("student_number"))
except:
return render(request, "charge_cash.html", {
"completed": False,
"error": "فرمت اطلاعات فرستاده شده درست نیست."
"error": "فرمت اطلاعات فرستاده شده درست نیست.",
"form": FormWithCaptcha()
})

if amount is not None and student_number is not None:
Expand All @@ -227,16 +229,19 @@ def charge_cash(request):

return render(request, "charge_cash.html", {
"completed": False,
"success": "اعتبار %s به میزان %d تومان افزایش یافت." % (member.get_full_name(), amount)
"success": "اعتبار %s به میزان %d تومان افزایش یافت." % (member.get_full_name(), amount),
"form": FormWithCaptcha()
})

return render(request, "charge_cash.html", {
"completed": False,
"error": "دانشجو با شمارهٔ دانشجویی وارد شده یافت نشد."
"error": "دانشجو با شمارهٔ دانشجویی وارد شده یافت نشد.",
"form": FormWithCaptcha(),
})

return render(request, "charge_cash.html", {
"completed": False
"completed": False,
"form": FormWithCaptcha()
})


Expand Down
4 changes: 2 additions & 2 deletions static/css/bootstrap.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion static/css/bootstrap.min.css

Large diffs are not rendered by default.

Binary file modified static/img/members/sorush.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fa7de6b

Please sign in to comment.