<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -134,9 +134,6 @@ class Snapshot(models.Model):
             if options.count() == 1:
                 current = get_object_or_404(Charge,snapshot=self,name=slugs[0])
             else:
-                print &quot;Multiple charges found with the same slug&quot;
-                for c in options:
-                    print c.id,c.name,c.label
                 raise &quot;Oh No!!!&quot;
 
         if len(slugs) == 1:</diff>
      <filename>law/models.py</filename>
    </modified>
    <modified>
      <diff>@@ -260,10 +260,23 @@ def edit_classification_index(request):
 def add_classification(request):
     f = AddClassificationForm(request.POST)
     snapshot = working_snapshot()
+    slug = slugify(request.POST['label'])[:50]
+    # need to check for duplicate slugs and fix
+    try:
+        ct = Classification.objects.get(name=slug)
+        # uh oh. there's already a charge with that slug
+        # need to come up with a relatively unique new one
+        # this is the most reasonable approach I can think of
+        slug = slug[:-3] + &quot;%03d&quot; % (Classification.objects.count() % 1000)
+        # any better ideas?
+    except Classification.DoesNotExist:
+        # that's good
+        pass
+
     c = Classification.objects.create(snapshot=snapshot,
                                       label=request.POST['label'],
                                       description=request.POST['description'],
-                                      name=slugify(request.POST['label'])[:50],
+                                      name=slug,
                                       )
     e = Event.objects.create(snapshot=snapshot,
                              user=request.user,</diff>
      <filename>law/views.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>843b744312b2e47c3af7f122eb30acc6d08e75fc</id>
    </parent>
  </parents>
  <author>
    <name>Anders Pearson</name>
    <email>anders@columbia.edu</email>
  </author>
  <url>http://github.com/thraxil/ccdb/commit/9d72e9f7baf641e43c135237c858e23f75646f29</url>
  <id>9d72e9f7baf641e43c135237c858e23f75646f29</id>
  <committed-date>2009-05-22T12:39:48-07:00</committed-date>
  <authored-date>2009-05-22T12:39:48-07:00</authored-date>
  <message>try to avoid duplicate slugs on classifications</message>
  <tree>2642191b768d004abd26bea852b2658c8aa887f7</tree>
  <committer>
    <name>Anders Pearson</name>
    <email>anders@columbia.edu</email>
  </committer>
</commit>
