-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 31f5b05
Showing
55 changed files
with
2,530 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.vscode/ | ||
__pycache__/ | ||
db.sqlite3 | ||
venv/ | ||
env.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<h1 align="center"> | ||
<img alt="Event QR Code" title="Event QR Code" src="setup/static/images/qr-code.png" width="100px" /> | ||
</h1> | ||
|
||
<h4 align="center"> | ||
Event QR Code | ||
</h4> | ||
|
||
## 💻 Projeto | ||
**Projeto para gerar QR Code e registrar participação em eventos. Ideal para usar com celular e ler QR Code. Salva informações dos eventos em que o partcipante esteve presente.** | ||
|
||
|
||
### Run | ||
```sh | ||
# clonar repositório | ||
git clone https://github.com/andre23arruda/event-qr-code | ||
|
||
# Entrar na pasta | ||
cd event-qr-code | ||
|
||
# Renomear env_example.py para env.py | ||
cp setup/env_example.py setup/env.py | ||
|
||
# Criar um ambiente virtual | ||
python -m venv venv | ||
|
||
# Ativar o ambiente virtual | ||
. activate.sh | ||
# ou . venv/Scripts/activate | ||
# ou . venv/bin/activate | ||
# ou source venv/Scripts/activate | ||
|
||
# Instalar os pacotes necessários | ||
pip install -r requirements.txt | ||
|
||
# Executar as migrações | ||
python manage.py migrate | ||
|
||
# Criar superusuário (poderá fazer login e entrar no admin) | ||
. create_su.sh | ||
# username -> teste | ||
# password -> teste1234 | ||
|
||
# Carregar fixtures (exemplo para colocar no banco de dados) | ||
python manage.py loaddata events participants | ||
|
||
# Gerar qr codes | ||
python generate_codes.py | ||
|
||
# Start | ||
. run.sh | ||
``` | ||
|
||
## Agora leia um dos QR Codes gerados e teste a aplicação | ||
|
||
## Acesse __/admin__ para cadastrar __Eventos__ e __Participantes__ | ||
|
||
## Explore ou altere do jeito que achar melhor!! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
# run with `. activate.sh` | ||
PWD=`pwd` | ||
|
||
activate () { | ||
if [ "$(uname)" == "Darwin" ]; then | ||
. $PWD/venv/bin/activate | ||
elif [ "$(expr substr $(uname -s) 1 5)" == "Linux" ]; then | ||
. $PWD/venv/bin/activate | ||
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW32_NT" ]; then | ||
. $PWD/venv/Scripts/activate | ||
elif [ "$(expr substr $(uname -s) 1 10)" == "MINGW64_NT" ]; then | ||
. $PWD/venv/Scripts/activate | ||
fi | ||
|
||
printf "\n Virtual enviroment activated. \n\n Use 'deactivate' to close it. \n\n\n" | ||
} | ||
|
||
activate |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from django.contrib import admin | ||
from django.conf.locale.pt_BR import formats as portuguese | ||
from django.conf.locale.en import formats as english | ||
from .models import Event, Participant | ||
|
||
portuguese.DATE_FORMAT = 'd/m/Y' | ||
portuguese.DATETIME_FORMAT = 'H:i - d/m/Y' | ||
english.DATE_FORMAT = 'd/m/Y' | ||
english.DATETIME_FORMAT = 'H:i - d/m/Y' | ||
|
||
|
||
@admin.register(Event) | ||
class EventRegister(admin.ModelAdmin): | ||
list_display = ['id', 'name', 'date', 'created_at', 'is_active'] | ||
list_display_links = ['id', 'name'] | ||
list_editable = ['is_active'] | ||
ordering = ['id'] | ||
search_fields = ['name',] | ||
|
||
|
||
@admin.register(Participant) | ||
class ParticipantRegister(admin.ModelAdmin): | ||
autocomplete_fields = ['events'] | ||
list_display = ['id', 'name', 'events_count', 'created_at'] | ||
list_display_links = ['id', 'name'] | ||
ordering = ['id'] | ||
search_fields = ['name',] | ||
|
||
def events_count(self, obj): | ||
return obj.events.all().count() | ||
events_count.short_description = 'Events' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class RegisterEventsConfig(AppConfig): | ||
name = 'register_events' | ||
verbose_name = 'Register events' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[ | ||
{ | ||
"model": "register_events.event", | ||
"pk": 1, | ||
"fields": { | ||
"created_at": "2022-06-04", | ||
"updated_at": "2022-06-04", | ||
"name": "Event 1", | ||
"date": "2022-06-10 11:16:09.184106+00:00", | ||
"time": "90" | ||
} | ||
}, | ||
{ | ||
"model": "register_events.event", | ||
"pk": 2, | ||
"fields": { | ||
"created_at": "2022-06-04", | ||
"updated_at": "2022-06-04", | ||
"name": "Event 2", | ||
"date": "2022-06-15 11:16:09.184106+00:00", | ||
"time": "90" | ||
} | ||
}, | ||
{ | ||
"model": "register_events.event", | ||
"pk": 3, | ||
"fields": { | ||
"created_at": "2022-06-04", | ||
"updated_at": "2022-06-04", | ||
"name": "Event 3", | ||
"date": "2022-06-20 11:16:09.184106+00:00", | ||
"time": "90" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[ | ||
{ | ||
"model": "register_events.participant", | ||
"pk": 1, | ||
"fields": { | ||
"created_at": "2022-06-04", | ||
"updated_at": "2022-06-04", | ||
"name": "Participant 1", | ||
"description": "" | ||
} | ||
}, | ||
{ | ||
"model": "register_events.participant", | ||
"pk": 2, | ||
"fields": { | ||
"created_at": "2022-06-04", | ||
"updated_at": "2022-06-04", | ||
"name": "Participant 2", | ||
"description": "" | ||
} | ||
}, | ||
{ | ||
"model": "register_events.participant", | ||
"pk": 3, | ||
"fields": { | ||
"created_at": "2022-06-04", | ||
"updated_at": "2022-06-04", | ||
"name": "Participant 3", | ||
"description": "" | ||
} | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import datetime | ||
from django import forms | ||
from .models import Event, Participant | ||
from .utils import available_events | ||
|
||
today = datetime.datetime.now() | ||
today = today.replace(hour=0, minute=0, second=0, microsecond=0) | ||
tomorrow = today + datetime.timedelta(1) | ||
|
||
class ParticipantForms(forms.ModelForm): | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(ParticipantForms, self).__init__(*args, **kwargs) | ||
for field in self.visible_fields(): | ||
field.field.widget.attrs['class'] = 'form-control' | ||
|
||
event = forms.ModelChoiceField(queryset=Event.objects.all()) | ||
# event = forms.ModelChoiceField(queryset=Event.objects.filter(date__gte=datetime.now())) | ||
# event = forms.ModelChoiceField(queryset=available_events()) | ||
|
||
class Meta: | ||
model = Participant | ||
fields = ['name', 'description', 'event'] | ||
|
||
widgets = { | ||
'name': forms.TextInput(attrs={ | ||
'disabled': '', | ||
}), | ||
'description': forms.Textarea(attrs={ | ||
'disabled': '', | ||
'rows': '5', | ||
}), | ||
} | ||
|
||
|
||
def clean(self): | ||
return self.cleaned_data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Generated by Django 3.2 on 2022-06-04 22:48 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Event', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateField(auto_now_add=True)), | ||
('updated_at', models.DateField(auto_now=True)), | ||
('name', models.CharField(max_length=50)), | ||
('date', models.DateTimeField()), | ||
('time', models.SmallIntegerField()), | ||
('is_active', models.BooleanField(default=False)), | ||
], | ||
options={ | ||
'verbose_name': 'Event', | ||
'verbose_name_plural': 'Events', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Participant', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateField(auto_now_add=True)), | ||
('updated_at', models.DateField(auto_now=True)), | ||
('name', models.CharField(max_length=100)), | ||
('description', models.TextField(blank=True)), | ||
('events', models.ManyToManyField(blank=True, to='register_events.Event')), | ||
], | ||
options={ | ||
'verbose_name': 'Participant', | ||
'verbose_name_plural': 'Participants', | ||
}, | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from django.db import models | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
class Event(models.Model): | ||
created_at = models.DateField(auto_now_add=True) | ||
updated_at = models.DateField(auto_now=True) | ||
name = models.CharField(max_length=50) | ||
date = models.DateTimeField() | ||
time = models.SmallIntegerField() | ||
is_active = models.BooleanField(default=False) | ||
|
||
class Meta: | ||
verbose_name = _('Event') | ||
verbose_name_plural = _('Events') | ||
|
||
def __str__(self): | ||
return f'{ self.name }' | ||
|
||
|
||
class Participant(models.Model): | ||
created_at = models.DateField(auto_now_add=True) | ||
updated_at = models.DateField(auto_now=True) | ||
name = models.CharField(max_length=100) | ||
description = models.TextField(blank=True) | ||
events = models.ManyToManyField(Event, blank=True) | ||
|
||
class Meta: | ||
verbose_name = _('Participant') | ||
verbose_name_plural = _('Participants') | ||
|
||
def __str__(self): | ||
return f'{ self.name }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.urls import path | ||
from .views import * | ||
|
||
urlpatterns = [ | ||
path('register_participant', view_render_partipant, name='register_participant'), | ||
path('submit_participant/<int:participant_id>', view_submit_partipant, name='submit_participant'), | ||
path('register_success', view_register_success, name='register_success'), | ||
path('register_error', view_register_error, name='register_error'), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import datetime | ||
from django.db.models import QuerySet | ||
from .models import Event | ||
|
||
|
||
def available_events() -> QuerySet: | ||
'''Retorna eventos disponíveis hoje''' | ||
today = datetime.datetime.now() | ||
today = today.replace(hour=0, minute=0, second=0, microsecond=0) | ||
tomorrow = today + datetime.timedelta(1) | ||
events = Event.objects.filter( | ||
date__range=(today, tomorrow), | ||
is_active=True | ||
) | ||
return events |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .views import * |
Oops, something went wrong.