Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Various fixes to offers, meals, etc (#88)
* slack fixes

* fixing flake errors

* Enabling sponsors etc to be QR scanned

* reenable HW

* resetting app deadline

* on the fly fixes

* flake fixes

* added newline
  • Loading branch information
faix committed Oct 10, 2019
1 parent 9bd371f commit a152da2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
17 changes: 11 additions & 6 deletions applications/templates/offers.html
@@ -1,20 +1,25 @@
{% extends 'base_tabs.html' %}

{% load bootstrap3 %}
{% block head_title %}Offers{% endblock %}

{% block panel %}
<style>
.code a{
color: black !important;
}
</style>
<div class="row">
<div class="col-md-12" style="text-align: center;">
{% for code in codes %}
<img style="max-width: 250px;" alt="{{ code.offer.name }} logo" src="{{ code.offer.logo.url }}" />
<img style="max-width: 250px;display: block;" alt="{{ code.offer.name }} logo" src="{{ code.offer.logo.url }}" />
<p style="margin-top: 10px;">{{ code.offer.description | safe }}</p>
<span style="background-color: #C2BEBE;padding: 10px 15px;font-size: 22px;display: inline-block;margin-top: 10px;margin-bottom: 1rem;">{{ code.code }}</span>
<span class="code" style="background-color: #C2BEBE;padding: 10px 15px;font-size: 22px;display: inline-block;margin-top: 10px;margin-bottom: 25px;">{{ code.code | urlize }}</span>
{% endfor %}
{% if not codes %}
<h4 style="margin-top: 15px;">Please contact us at {{ h_contact_email | urlize }} if you believe you should have offer codes.</h4>
{% endif %}
</div>
</div>

{% endblock %}
{% endblock %}
6 changes: 3 additions & 3 deletions checkin/models.py
Expand Up @@ -27,11 +27,11 @@ def save(self, force_insert=False, force_update=False, using=None,
app.check_in()

# Assign one code per available offer to the user
if not self.user.is_sponsor and not self.user.is_mentor and not self.user.is_judge and not \
self.user.is_volunteer:
if not self.application_user.is_sponsor and not self.application_user.is_mentor and not \
self.application_user.is_judge and not self.application_user.is_volunteer:
codes = {c["offer"]: c["id"] for c in
Code.objects.filter(user__isnull=True).order_by("-id").values("id", "offer")}
Code.objects.filter(id__in=list(codes.values())).update(user_id=self.user.id)
Code.objects.filter(id__in=list(codes.values())).update(user_id=self.application_user.id)

def delete(self, using=None, keep_parents=False):
app = Application.objects.filter(user=self.application_user).first()
Expand Down
2 changes: 1 addition & 1 deletion checkin/tables.py
Expand Up @@ -10,7 +10,7 @@ class ApplicationCheckinFilter(django_filters.FilterSet):

def search_filter(self, queryset, name, value):
return queryset.filter(Q(email__icontains=value) | Q(name__icontains=value) |
Q(uuid__icontains=value.replace('-', '')))
Q(id__icontains=value.replace('-', '')))

class Meta:
model = User
Expand Down
9 changes: 6 additions & 3 deletions meals/views.py
Expand Up @@ -19,6 +19,7 @@
from app.mixins import TabsViewMixin
from app.views import TabsView
from applications import models as models_app
from applications.models import Application
from checkin.models import CheckIn
from meals.models import Meal, Eaten, MEAL_TYPE
from meals.tables import MealsListTable, MealsListFilter, MealsUsersTable, MealsUsersFilter
Expand Down Expand Up @@ -262,12 +263,14 @@ def post(self, request, format=None):
obj_checkin = CheckIn.objects.filter(qr_identifier=var_user).first()
if obj_checkin is None:
return HttpResponse(json.dumps({'code': 1, 'message': 'Invalid user'}), content_type='application/json')
obj_application = obj_checkin.application
obj_user = obj_application.user
obj_user = obj_checkin.application_user
obj_application = Application.objects.filter(user=obj_user).first()
if obj_user.diet:
var_diet = obj_user.diet
else:
elif obj_application:
var_diet = obj_application.diet
else:
var_diet = "UNKNOWN"
var_eatens = Eaten.objects.filter(meal=obj_meal, user=obj_user).count()
if var_eatens >= var_repetitions:
return HttpResponse(json.dumps({'code': 2, 'message': 'Hacker alreay ate'}),
Expand Down

0 comments on commit a152da2

Please sign in to comment.