Skip to content

Commit

Permalink
Merge pull request #1 from magfest/master
Browse files Browse the repository at this point in the history
re-sync to upstream
  • Loading branch information
ksonney committed Sep 17, 2014
2 parents 8ce7958 + fd19dc0 commit a23bddf
Show file tree
Hide file tree
Showing 11 changed files with 1,813 additions and 1,780 deletions.
54 changes: 32 additions & 22 deletions INSTALL.vagrant.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
Setting up Ubersystem to run on Vagrant
==================
Windows instructions, if you're on linux/etc the process will be similar.
Windows instructions, if you're on Linux/etc the process will be similar.

[Vagrant](http://www.vagrantup.com/) is a great way to provide portable development environments by letting you install a local VM and have it automatically configured with all of the software and dependencies you need to start developing. If you're already running Linux, we recommend you just develop locally, so this section assumes you are using Windows. Here's what you'll need to install to get your dev environment up and running:
* [TortoiseGit](https://code.google.com/p/tortoisegit/) for checking out this repo. You can also use any other git tool you like.
* [VirtualBox](https://www.virtualbox.org/wiki/Downloads) for running your development VM
* [Vagrant](http://www.vagrantup.com/downloads.html) itself
* [Putty](http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html) for SSH-ing into your development machine once it's up and running
[Vagrant](http://www.vagrantup.com/) is a great way to provide portable development environments by letting you install a local VM and have it automatically configured with all of the software and dependencies you need to start developing.

First, use TortoiseGit to check out this repo. It's probably a good idea to fork this repo and then clone your fork, to do that:
* make an account (or log in to your existing account) on [GitHub](https://github.com/)
* go to https://github.com/magfest/ubersystem and click the "Fork" button at the top right of the page
* tell TortoiseGit to clone your new repo, which will be at ``https://github.com/<YOUR-USERNAME>/magfest``
## What you'll need
* [Git](http://git-scm.com/) to check out this repo and to provide SSH.
* [TortoiseGit](https://code.google.com/p/tortoisegit/) or [GitHub for Windows](https://windows.github.com/) to use as an interface for Git. You can also use any other git tool you like, or simply use the command line.
* [VirtualBox](https://www.virtualbox.org/wiki/Downloads) for running your development VM.
* [Vagrant](http://www.vagrantup.com/downloads.html) itself.

Next open a DOS prompt run as an administrator. go to Start->Accessories->Command Prompt, right click, run as administrator
## Fork ubersystem (optional)
Forking ubersystem allows you to develop on your own and then submit pull requests. It's useful if you want to develop a custom system where not everything will be merged upstream.
1. Make an account (or log in to your existing account) on [GitHub](https://github.com/).
2. Go to [MAGFest Ubersystem](https://github.com/magfest/ubersystem) and click the "Fork" button at the top right of the page.
3. Clone your new repo, which will be at ``https://github.com/<YOUR-USERNAME>/magfest``.

Change into the ``magfest`` directory that was created when you cloned your repo, and type ``vagrant up``. This does a bunch of different things:
* downloads a VirtualBox image of an Ubuntu server from the internet
* starts up the VM and installs all necessary OS dependencies
* creates a database filled with test data
* sets up a Python virtualenv with all of the necessary Python packages needed to run Uber
## Clone ubersystem
1. Create the folder that you want ubersystem to live in.
2. If you're using TortoiseGit, right-click inside the folder and select "Git Clone." Paste the GitHub URL to the repository (e.g., ``https://github.com/magfest/ubersystem``) and press OK.
3. If you're using GitHub for Windows, simply start GfW, log in to GitHub, and click the "+" button in the upper-left hand corner. Select "Clone" and set the cloning directory.

Now that you have your VM, the only thing left to do is log into your server and start Uber. First, make sure Git is in your Windows PATH. Use this if you're not sure how:
## Running Vagrant
Open a cmd or bash prompt run as an administrator.

Change into the ``ubersystem`` directory that was created when you cloned your repo, and type ``vagrant up``. This does a bunch of different things:
* Downloads a VirtualBox image of an Ubuntu server from the internet.
* Starts up the VM and installs all necessary OS dependencies.
* Sets up a Python virtualenv with all of the necessary Python packages needed to run Uber.

Now that you have your VM, the only thing left to do is log into your server and start Uber.

If you're on Windows, make sure Git is in your PATH. Use this if you're not sure how:
http://blog.countableset.ch/2012/06/07/adding-git-to-windows-7-path/

Next, run
Expand All @@ -48,13 +58,13 @@ bg

to run the server in the background.

Vagrant troubleshooting notes:
Vagrant Troubleshooting:
==========================

Note1: shared folders are very slow on Windows. Don't be suprised that things run a bit slower.
1. Shared folders are very slow on Windows. Don't be suprised that things run a bit slower.

Note2: you probably should use the virtualbox application to increase the CPU and Memory size of the image to make it run smoother. 4CPU and 4GB of mem is a good start.
2. You probably should use the virtualbox application to increase the CPU and Memory size of the image to make it run smoother. 4CPU and 4GB of mem is a good start.

Note3: If virtualbox hangs on startup with a message about "Clearing port forwarding", it's misleading and probably having a silent issue with the shared folder mount (https://github.com/mitchellh/vagrant/issues/3139)
3. If VirtualBox hangs on startup with a message about "Clearing port forwarding", it's misleading and probably having a silent issue with the shared folder mount (https://github.com/mitchellh/vagrant/issues/3139)

A workaround for this is to install Powershell v3, which seems to fix it. http://www.microsoft.com/en-us/download/details.aspx?id=34595
A workaround for this is to install Powershell v3, which seems to fix it. http://www.microsoft.com/en-us/download/details.aspx?id=34595
5 changes: 5 additions & 0 deletions dbutils.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,9 @@ psql -d mydbname -f backupfile.sql
# select from an attende (this exact syntax is super-important)
SELECT * FROM "Attendee";
# create a database cluster if you blew it up
/usr/lib/postgresql/9.3/bin/initdb /var/lib/postgresql/9.3/main
or as root:
su - postgres -c "/usr/lib/postgresql/9.3/bin/initdb /var/lib/postgresql/9.3/main"
```
23 changes: 16 additions & 7 deletions uber/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1327,19 +1327,28 @@ def search(self, text, *filters):
checks.append(getattr(Attendee, attr).ilike('%' + text + '%'))
return attendees.filter(or_(*checks))

def assign_badges(self, group, new_badge_count):
def delete_from_group(self, attendee, group):
'''
Sometimes we want to delete an attendee badge which is part of a group. In most cases, we could just
say "session.delete(attendee)" but sometimes we need to make sure that the attendee is ALSO removed
from the "group.attendees" list before we commit, since the number of attendees in a group is used in
our presave_adjustments() code to update the group price. So anytime we delete an attendee in a group,
we should use this method.
'''
self.delete(attendee)
group.attendees.remove(attendee)

def assign_badges(self, group, new_badge_count, **extra_create_args):
diff = int(new_badge_count) - group.badges
if diff > 0:
for i in range(diff):
group.attendees.append(Attendee(badge_type=group.new_badge_type, ribbon=group.new_ribbon, paid=PAID_BY_GROUP))
group.attendees.append(Attendee(badge_type=group.new_badge_type, ribbon=group.new_ribbon, paid=PAID_BY_GROUP, **extra_create_args))
elif diff < 0:
floating = group.floating
if len(floating) < abs(diff):
if len(group.floating) < abs(diff):
return 'You cannot reduce the number of badges for a group to below the number of assigned badges'
else:
for i in range(abs(diff)):
self.delete(floating[i])
group.attendees.remove(floating[i])
for attendee in group.floating[:abs(diff)]:
self.delete_from_group(attendee, group)

def assign(self, attendee_id, job_id):
job = self.job(job_id)
Expand Down
13 changes: 6 additions & 7 deletions uber/site_sections/preregistration.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,15 @@ def register_group_member(self, session, group_id, message='', **params):

badge_being_claimed = group.floating[0]
attendee.registered = badge_being_claimed.registered
group.attendees.remove(badge_being_claimed)
session.delete(badge_being_claimed)
session.delete_from_group(badge_being_claimed, group)

group.attendees.append(attendee)
attendee.paid = PAID_BY_GROUP
session.add(attendee)
if attendee.amount_unpaid:
raise HTTPRedirect('group_extra_payment_form?id={}', attendee.id)
else:
raise HTTPRedirect('group_members?id={}&message={}', attendee.group.id, 'Badge registered successfully')
raise HTTPRedirect('group_members?id={}&message={}', attendee.group_id, 'Badge registered successfully')
else:
attendee.can_spam = True # only defaults to true for these forms

Expand All @@ -272,7 +271,7 @@ def group_extra_payment_form(self, session, id):
def group_undo_extra_payment(self, session, id):
attendee = session.attendee(id)
attendee.amount_extra -= attendee.amount_unpaid
raise HTTPRedirect('group_members?id={}&message={}', attendee.group.id, 'Extra payment undone')
raise HTTPRedirect('group_members?id={}&message={}', attendee.group_id, 'Extra payment undone')

@credit_card
def process_group_payment(self, session, payment_id, stripeToken):
Expand Down Expand Up @@ -308,9 +307,9 @@ def unset_group_member(self, session, id):
except:
log.error('unable to send group unset email', exc_info=True)

session.assign_badges(attendee.group, attendee.group.badges + 1)
session.delete(attendee)
raise HTTPRedirect('group_members?id={}&message={}', attendee.group.id, 'Attendee unset; you may now assign their badge to someone else')
session.assign_badges(attendee.group, attendee.group.badges + 1, registered=attendee.registered)
session.delete_from_group(attendee, attendee.group)
raise HTTPRedirect('group_members?id={}&message={}', attendee.group_id, 'Attendee unset; you may now assign their badge to someone else')

def add_group_members(self, session, id, count):
group = session.group(id)
Expand Down
14 changes: 8 additions & 6 deletions uber/site_sections/registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,14 @@ def history(self, session, id):
@csrf_protected
def delete(self, session, id, return_to = 'index?'):
attendee = session.attendee(id)
session.delete(attendee)
message = 'Attendee deleted'
if attendee.group:
session.add(Attendee(group=attendee.group, paid=attendee.paid,
session.delete_from_group(attendee, attendee.group)
session.add(Attendee(group=attendee.group, paid=attendee.paid, registered=attendee.registered,
badge_type=attendee.badge_type, badge_num=attendee.badge_num))
message = 'Attendee deleted, but badge ' + attendee.badge + ' is still available to be assigned to someone else'
else:
session.delete(attendee)
message = 'Attendee deleted'

raise HTTPRedirect(return_to + ('' if return_to[-1] == '?' else '&') + 'message={}', message)

Expand Down Expand Up @@ -333,14 +335,14 @@ def take_back_merch(self, session, id):
attendee.got_merch = False
if attendee.no_shirt:
session.delete(attendee.no_shirt)
session.delete()
session.commit()
return '{a.full_name} ({a.badge}) merch handout canceled'.format(a=attendee)

if AT_THE_CON or DEV_BOX:
@unrestricted
def register(self, message='', **params):
def register(self, session, message='', **params):
params['id'] = 'None'
attendee = Attendee.get(params, bools=['international'], checkgroups=['interests'], restricted=True, ignore_csrf=True)
attendee = session.attendee(params, bools=['international'], checkgroups=['interests'], restricted=True, ignore_csrf=True)
if 'first_name' in params:
if not attendee.payment_method:
message = 'Please select a payment type'
Expand Down
16 changes: 8 additions & 8 deletions uber/static/lib/date/date.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a23bddf

Please sign in to comment.