Commit 59e8eea1 authored by lizonr1's avatar lizonr1

Add new views with .html

parent b3d10a77
from django import forms
from django.contrib.auth import authenticate
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist
from django.core.exceptions import ValidationError
from App.loyaltyMe.models import Place, Beacon
from App.promotion.models import Promotion
class EmailAuthenticationForm(AuthenticationForm):
def clean_username(self):
username = self.data['username']
if '@' in username:
try:
username = User.objects.get(email=username).username
except ObjectDoesNotExist:
raise ValidationError(
self.error_messages['invalid_login'],
code='invalid_login',
params={'username': self.username_field.verbose_name},
)
return username
class PlaceForm(forms.ModelForm):
class Meta:
model = Place
fields = '__all__'
exclude = ['owners', 'promotion', 'offer', 'screen_img', 'logo_img', 'localization']
def __init__(self, user, *args, **kwargs):
super(PlaceForm, self).__init__(*args, **kwargs)
self.fields['beacon'].queryset = Beacon.objects.filter(user=user)
class PromotionForm(forms.ModelForm):
class Meta:
model = Promotion
exclude = ['status', 'code']
\ No newline at end of file
{% extends 'panel/base.html' %}
{% block content %}
Witaj {{ user }} w panelu Kawowego Dzienniczka.
<hr>
{{ beacon.name }} <BR>
{{ beacon.description }} <BR>
{{ beacon.uuid }} <BR>
{{ beacon.major }} <BR>
{{ beacon.minor }} <BR>
<BR><hr>
<a href="/beacon">Wróć</a><BR>
<a href="/panel">Panel</a>
<BR>
{% endblock content %}
\ No newline at end of file
{% extends 'panel/base.html' %}
{% block content %}
Witaj {{ user }} w panelu dodawania beacona
<hr>
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save" />
</form>
<BR><hr>
<a href="/place">Wróć</a><BR>
<a href="/panel">Panel</a>
<BR>
{% endblock content %}
\ No newline at end of file
{% extends 'panel/base.html' %}
{% block content %}
Witaj {{ user }} w panelu Kawowego Dzienniczka.
<hr>
{% for beacon in object_list %}
<a href="/beacon/{{ beacon.id }}">{{ beacon }}</a><BR>
{% endfor %}
<BR><hr>
<a href="/beacon/add">Dodaj beacon</a><BR>
<a href="/panel">Panel</a>
<BR>
{% endblock content %}
\ No newline at end of file
<form action="" method="post">{% csrf_token %}
<p>Are you sure you want to delete "{{ object }}"?</p>
<input type="submit" value="Confirm" />
</form>
\ No newline at end of file
{% extends 'panel/base.html' %}
{% block content %}
Witaj {{ user }} w panelu Kawowego Dzienniczka.
<hr>
Promotion name: {{ promotion.name }} <BR>
{{ promotion.description }} <BR>
{{ promotion.code }} <BR>
{{ promotion.img }} <BR>
{{ promotion.status }} <BR>
{{ promotion.task }} <BR>
{{ promotion.left_number }} <BR>
{{ promotion.start_date }} <BR>
{{ promotion.end_date }} <BR>
<BR><hr>
<a href="/panel">Panel</a>
<BR>
{% endblock content %}
\ No newline at end of file
{% extends 'panel/base.html' %}
{% block content %}
Witaj {{ user }} w panelu dodawania promocji
<hr>
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save" />
</form>
<BR><hr>
<a href="/place">Wróć</a><BR>
<a href="/panel">Panel</a>
<BR>
{% endblock content %}
\ No newline at end of file
{% extends 'panel/base.html' %}
{% block content %}
Witaj {{ user }} w panelu Kawowego Dzienniczka.
<hr>
Promotion Set Name: {{ promotionset.name }} <BR>
{% for promotion in promotionset.promotions.all %}
Promocja: <a href="/promotion/{{ promotion.id }}">{{ promotion }}</a><BR>
<a href="/promotion/{{ promotion.id }}/delete">Usun</a><BR>
{% endfor %}
<BR><hr>
<a href="./promotion/add">Dodaj promocje</a><BR>
<a href="/panel">Panel</a>
<BR>
{% endblock content %}
\ No newline at end of file
{% extends 'panel/base.html' %}
{% block content %}
Witaj {{ user }} w panelu Kawowego Dzienniczka.
<hr>
{{ userprofile.user.username }} <BR>
{{ userprofile.user.email }} <BR>
<img src="{{ userprofile.photo }}"> <BR>
<BR><hr>
<a href="/panel">Panel</a>
<BR>
{% endblock content %}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment