From 4e823cfb8ab43cc9cbf3f1a19a835a9db0a3f2eb Mon Sep 17 00:00:00 2001 From: Michael Farrell Date: Fri, 29 Apr 2011 20:00:37 +0930 Subject: [PATCH] Made reset excuses optional for users via a setting. Changed language to allow purchase of resets as an option. Made option that changes default quota amount. --- frontend/forms.py | 5 +++-- frontend/models.py | 5 ++++- frontend/views.py | 1 + settings.py | 7 +++++++ templates/frontend/internet_login.html | 9 +++------ templates/frontend/quota.html | 12 ++++++++++-- templates/frontend/reset-lecture.html | 27 ++++++++++---------------- 7 files changed, 38 insertions(+), 28 deletions(-) diff --git a/frontend/forms.py b/frontend/forms.py index 518d40e..c1f50a7 100644 --- a/frontend/forms.py +++ b/frontend/forms.py @@ -44,7 +44,8 @@ class ResetLectureForm(forms.Form): excuse = forms.CharField( label=_('Why did you exceed your quota usage?'), min_length=3, - max_length=256 + max_length=256, + required=settings.RESET_EXCUSE_REQUIRED ) def check_answers(self): @@ -97,7 +98,7 @@ class SignInForm3(forms.Form): label=_('Quota Amount'), help_text=_('The amount of quota to give to the user, in megabytes.'), min_value=1, - initial=150L + initial=long(settings.DEFAULT_QUOTA_AMOUNT) ) quota_unlimited = forms.BooleanField( diff --git a/frontend/models.py b/frontend/models.py index 0777f84..254bad4 100644 --- a/frontend/models.py +++ b/frontend/models.py @@ -129,12 +129,15 @@ class Meta: user_profile = ForeignKey(UserProfile) quota_used = PositiveIntegerField(default=0) quota_multiplier = PositiveIntegerField(default=1) - quota_amount = PositiveIntegerField(default=100000000) + quota_amount = PositiveIntegerField(default=long(settings.DEFAULT_QUOTA_AMOUNT)*1048576L) quota_unmetered = BooleanField(default=False) # ALTER TABLE `tollgate`.`frontend_eventattendance` ADD COLUMN `coffee` TINYINT(1) NOT NULL DEFAULT 0 AFTER `quota_unmetered`; coffee = BooleanField(default=False) + registered_by = ForeignKey(UserProfile, null=True, blank=True, related_name="registered_by") + registered_on = DateTimeField(auto_now_add=True) + def is_unmetered(self): return self.quota_unmetered diff --git a/frontend/views.py b/frontend/views.py index 696981f..d79c786 100644 --- a/frontend/views.py +++ b/frontend/views.py @@ -269,6 +269,7 @@ def host_refresh(request): # pass #return HttpResponseRedirect('/') +@login_required def host_refresh_quick(request): refresh_networkhost_quick() return HttpResponseRedirect('/internet/') diff --git a/settings.py b/settings.py index 88df745..ce33aaa 100644 --- a/settings.py +++ b/settings.py @@ -114,6 +114,13 @@ LAN_IFACE = 'eth1' LOGIN_URL = '/login/' LOGOUT_URL = '/logout/' +# the default amount of quota +DEFAULT_QUOTA_AMOUNT = 150 +# are reset excuses required? +RESET_EXCUSE_REQUIRED = True +# changes some texts to imply that quota resets are purchasable +RESET_PURCHASE = False + ONLY_CONSOLE = False SOURCE_URL = None diff --git a/templates/frontend/internet_login.html b/templates/frontend/internet_login.html index a3091cd..251f565 100644 --- a/templates/frontend/internet_login.html +++ b/templates/frontend/internet_login.html @@ -1,7 +1,7 @@ {% extends "frontend/base-internet.html" %} {% comment %} tollgate login success page -Copyright 2008-2010 Michael Farrell +Copyright 2008-2011 Michael Farrell This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -21,16 +21,13 @@ {% block title %}internet login success{% endblock %} {% block content %} - -

{{ u.username }} has been logged in for the MAC address {{ mac }}.

You should be able to access the internet now, if you have quota available.

-

Warning: All internet access is metered. You have a limited amount of quota available, please see the quota page to show the current status.

+

Warning: All internet access is metered, including uploads and downloads. You have a limited amount of quota available, please see the quota page to show the current status.

-

Disable programs that are downloading in the background, pause Steam updates, and shut down peer to peer programs, including Bear Share, Bittorrent, Gnutella, Hamachi, Limewire and Skype. Both uploads and downloads are counted, and the unmetered sites list is not the same as what is available on your ISP, nor the same as the ISP we are using. Failure to comply with this will result in termination of your internet connectivity after you exceed your quota.

+

Disable programs that are downloading in the background, pause Steam updates, and shut down peer to peer programs, such as Bear Share, Bittorrent, Gnutella, Hamachi, Limewire, Skype and World of Warcraft (under some configurations). Both uploads and downloads are counted, and the unmetered sites list is not the same as what is available on your ISP, nor the same as the ISP we are using. Failure to comply with this will result in termination of your internet connectivity after you exceed your quota.

Downloads from local file shares on the LAN are unmetered.

diff --git a/templates/frontend/quota.html b/templates/frontend/quota.html index 5ef2889..5af9dc0 100644 --- a/templates/frontend/quota.html +++ b/templates/frontend/quota.html @@ -73,14 +73,22 @@

Quota Details

{% endif %}   {% if could_get_a_reset_later %} - You could get one free reset later. However you have to have used a certain percentage of your quota before this option is available to you. After you have used the reset, no more quota will be available. + You could get one free reset later. However you have to have used a certain percentage of your quota before this option is available to you. After you have used the reset, no more free resets will be available. {% endif %} {% if has_free_reset %} - You have one free reset available. No more quota will be available after you have used it. + You have one free reset available. No more free resets will be available after you have used it. {% endif %} + + {% if attendance.reset_count >= 1 %} + {% if settings.RESET_PURCHASE %} + + No more free resets are available. You may purchase additional quota resets from the admins. + + {% endif %} + {% endif %} diff --git a/templates/frontend/reset-lecture.html b/templates/frontend/reset-lecture.html index f4c5db2..18151e9 100644 --- a/templates/frontend/reset-lecture.html +++ b/templates/frontend/reset-lecture.html @@ -1,7 +1,7 @@ {% extends "frontend/base.html" %} {% comment %} tollgate reset lecture page -Copyright 2008-2010 Michael Farrell +Copyright 2008-2011 Michael Farrell This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by @@ -21,12 +21,11 @@ {% block title %}request usage reset{% endblock %} {% block content %} - -

Just so you know, you're about to use your only free reset. After this, there will be no additional resets available, and when you have used your quota you will no longer have internet connectivity for the remainder of the LAN.

+

Just so you know, you're about to use your only free reset. After this, there will be no additional resets available, and when you have used your quota you will {% if settings.RESET_PURCHASE %}need to purchase additional resets to{% else %}no longer{% endif %} have internet connectivity for the remainder of the LAN.

-

Now is your only chance to make sure something isn't siphoning away your internet usage without you knowing, that you haven't logged in to someone else's computer and they're using all your quota, making sure you've disabled automatic updates or redirected them to local sources, and so-forth.

+

Now is your only chance to make sure something isn't siphoning away your internet usage without you knowing, that you haven't logged in to someone else's computer and they're using all your quota, making sure you've disabled automatic updates or redirected them to local sources, disabling any peer-to-peer applications (eg: BitTorrent, Skype, World of Warcraft...), and so-forth.

-

To make sure you're really sure you want to do this, you'll need to enter the text in the image below (remembering to include the punctuation as well), and provide a short reason (less than 250 characters) as to why you exceeded your quota usage this time.

+

To make sure you're really sure you want to do this, you'll need to enter the text in the image below (remembering to include the punctuation as well){% if settings.RESET_EXCUSE_REQUIRED %}, and provide a short reason (less than 250 characters) as to why you exceeded your quota usage this time{% endif %}.

If you believe there are extenuating circumstances as to why you're perhaps using the internet a lot faster than you should be, then now is the time to approach an admin about it.

@@ -41,17 +40,11 @@ {% endif %} -
- - {{ reset_form.as_table }} - - - - -
+ {% csrf_token %} +

{{ reset_form.q1.label_tag }} {{ reset_form.q1 }}

+ {% if settings.RESET_EXCUSE_REQUIRED %} +

{{ reset_form.excuse.label_tag }} {{ reset_form.excuse }}

+ {% endif %} +

- - - - {% endblock %}