class ClubInfoForm(forms.ModelForm):
club_address2 = forms.CharField(required=False)
club_address3 = forms.CharField(required=False)
class Meta():
model = ClubInfo
fields = ('club_name', 'club_logo', 'club_address1', 'club_address2',
'club_address3', 'club_town', 'club_county', 'club_country',)
def clean_club_name(self):
club_name = self.cleaned_data['club_name']
if ClubInfo.objects.filter(club_name=club_name).exists():
raise ValidationError(_("Club already exists"))
return club_name
def register(request):
registered = False
if request.method == 'POST':
user_form = UserForm(data=request.POST)
profile_form = ClubInfoForm(data=request.POST)
if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
if 'profile_pic' in request.FILES:
print('found it')
profile.profile_pic = request.FILES['profile_pic']
profile.save()
registered = True
else:
print(user_form.errors, profile_form.errors)
else:
user_form = UserForm()
profile_form = ClubInfoForm()
return render(request,
'registration.html',
{'user_form': user_form,
'profile_form': profile_form,
'registered': registered})
class ClubInfo(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
club_name = models.CharField(max_length=50, default='', unique=True)
club_logo = models.ImageField(upload_to='profile_pics', blank=True)
club_address1 = models.CharField(max_length=30)
club_address2 = models.CharField(max_length=30, default='')
club_address3 = models.CharField(max_length=30, default='')
club_town = models.CharField(max_length=30)
club_county = models.CharField(max_length=30)
club_country = models.CharField(max_length=30)
created_date = models.DateTimeField(default=timezone.now)
def set_default_packages(sender, **kwargs):
if kwargs['created']:
ClubPackages.objects.create(club_id=kwargs['instance'])
post_save.connect(set_default_packages, sender=club_name)
def __str__(self):
return self.club_name
class ClubPackages(models.Model):
club_id = models.ForeignKey(ClubInfo, on_delete=models.CASCADE)
PACKAGE_STATUS = (
('0', 'Active'),
('1', 'Not Active')
)
player_register_package = models.CharField(default='1', max_length=1, choices=PACKAGE_STATUS)
player_register_price = models.DecimalField(default=100.00, max_digits=8, decimal_places=2)
player_register_expiry = models.DateField(default=timezone.now)
roster_package = models.CharField(default='1', max_length=1, choices=PACKAGE_STATUS)
roster_price = models.DecimalField(default=50.00, max_digits=8, decimal_places=2)
roster_expiry = models.DateField(default=timezone.now)
rent_a_pitch_package = models.CharField(default='1', max_length=1, choices=PACKAGE_STATUS)
rent_a_pitch_price = models.DecimalField(default=100.00, max_digits=8, decimal_places=2)
rent_a_pitch_expiry = models.DateField(default=timezone.now)
shop_package = models.CharField(default='1', max_length=1, choices=PACKAGE_STATUS)
shop_price = models.DecimalField(default=50.00, max_digits=8, decimal_places=2)
shop_expiry = models.DateField(default=timezone.now).
Séanadh Ríomhphoist/
Email Disclaimer
Tá an ríomhphost seo agus aon chomhad a sheoltar leis faoi rún agus is lena úsáid ag an seolaí agus sin amháin é. Is féidir tuilleadh a léamh anseo.
This e-mail and any files transmitted with it are confidential and are intended solely for use by the addressee. Read more here.
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Employee Records</title>
- {% load staticfiles %}
- <link rel="stylesheet" href="{% static 'css/style.css' %}"/>
- </head>
- <body>
- <table class="table table-striped table-bordered table-sm">
- <thead class="thead-dark">
- <tr>
- <th>Employee ID</th>
- <th>Employee Name</th>
- <th>Employee Email</th>
- <th>Employee Contact</th>
- <th>Actions</th>
- </tr>
- </thead>
- <tbody>
- {% for employee in employees %}
- <tr>
- <td>{{ employee.eid }}</td>
- <td>{{ employee.ename }}</td>
- <td>{{ employee.eemail }}</td>
- <td>{{ employee.econtact }}</td>
- <td>
- <a href="/edit/{{ employee.id }}"><span class="glyphicon glyphicon-pencil" >Edit</span></a>
- <a href="/delete/{{ employee.id }}">Delete</a>
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- <br>
- <br>
- <center><a href="/emp" class="btn btn-primary">Add New Record</a></center>
- </body>
- </html>
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ee8481f0-f3ed-41f8-a047-bdff7ee54580%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.