<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>LICENSE</filename>
    </added>
    <added>
      <filename>management.py</filename>
    </added>
    <added>
      <filename>templates/notification/pasteditem_received/full.txt</filename>
    </added>
    <added>
      <filename>templates/notification/pasteditem_received/notice.html</filename>
    </added>
    <added>
      <filename>templates/notification/pasteditem_received/short.txt</filename>
    </added>
    <added>
      <filename>templates/notification/pasteditem_sent/full.txt</filename>
    </added>
    <added>
      <filename>templates/notification/pasteditem_sent/notice.html</filename>
    </added>
    <added>
      <filename>templates/notification/pasteditem_sent/short.txt</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,7 +1,12 @@
-from django import forms 
-from django.utils.translation import ugettext_lazy as _ 
+from django import forms
+from django.contrib.auth.models import User
+from django.utils.translation import ugettext_lazy as _
+from oxybeles.models import PastedItem
 
-from oxybeles.models import PastedItem 
+try:
+    from notification import models as notification
+except ImportError:
+    notification = None
 
 class PastedItemForm(forms.ModelForm):
     class Meta():
@@ -12,3 +17,34 @@ class PastedItemForm(forms.ModelForm):
         self.user = user
         super(PastedItemForm, self).__init__(*args, **kwargs)
 
+class SendItemForm(forms.Form):
+    uuid = forms.CharField(max_length=36)
+    recipient = forms.CharField(max_length=30)
+
+    def __init__(self, sender = None, *args, **kwargs):
+        super(SendItemForm, self).__init__(*args, **kwargs)
+        self.sender = sender
+
+    def clean_uuid(self):
+        try:
+            return PastedItem.objects.get(uuid=self.cleaned_data['uuid'])
+        except PastedItem.DoesNotExist:
+            raise forms.ValidationError(_(&quot;The pasted items was not found.&quot;))
+
+    def clean_recipient(self):
+        recipient = self.cleaned_data['recipient']
+        try:
+            return User.objects.get(username=recipient)
+        except User.DoesNotExist:
+            raise forms.ValidationError(&quot;There is no user named %s.&quot; % recipient)
+
+    def save(self):
+        self.pasted_item = self.cleaned_data['uuid']
+        self.recipient_user = self.cleaned_data['recipient']
+        if notification:
+            notification.send([self.sender], &quot;pasteditem_sent&quot;,
+                              {'pasted_item': self.pasted_item,
+                               'recipient': self.recipient_user,})
+            notification.send([self.recipient_user], &quot;pasteditem_received&quot;,
+                              {'pasted_item': self.pasted_item,
+                               'sender': self.sender,})</diff>
      <filename>forms.py</filename>
    </modified>
    <modified>
      <diff>@@ -25,6 +25,6 @@ class PastedItem(models.Model):
         super(PastedItem, self).save()
 
     def get_absolute_url(self):
-        return ('oxybeles_detail', (), { 'slug': self.uuid })
+        return ('oxybeles_detail', (), { 'uuid': self.uuid })
     get_absolute_url = models.permalink(get_absolute_url)
 </diff>
      <filename>models.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,16 +1,10 @@
 from django.conf.urls.defaults import *
-from oxybeles.models import PastedItem
-
-info_dict = {
-    'queryset': PastedItem.objects.all(),
-    'slug_field': 'uuid',
-}
 
 urlpatterns = patterns('',
-    url(r'^$', 'oxybeles.views.new', name='oxybeles_new'),
-    url(r'^(?P&lt;slug&gt;[-0-9a-f]{36})/$',
-        'django.views.generic.list_detail.object_detail', 
-        info_dict, 
-        'oxybeles_detail'),
+    url(r'^$',
+        'oxybeles.views.new',
+        name='oxybeles_new'),
+    url(r'^(?P&lt;uuid&gt;[-0-9a-f]{36})/$',
+        'oxybeles.views.detail',
+        name='oxybeles_detail'),
 )
-</diff>
      <filename>urls.py</filename>
    </modified>
    <modified>
      <diff>@@ -7,7 +7,7 @@ from django.contrib.auth.models import User
 from django.contrib.auth.decorators import login_required
 
 from oxybeles.models import PastedItem
-from oxybeles.forms import PastedItemForm
+from oxybeles.forms import PastedItemForm, SendItemForm
 
 def new(request, form_class=PastedItemForm, template_name=&quot;oxybeles/new.html&quot;):
     &quot;&quot;&quot;
@@ -24,10 +24,26 @@ def new(request, form_class=PastedItemForm, template_name=&quot;oxybeles/new.html&quot;):
                 request.user.message_set.create(
                     message=ugettext(&quot;The new pasted item was saved.&quot;))
                     # some problem with ugettext_lazy here
-                return HttpResponseRedirect(reverse('oxybeles_detail', 
+                return HttpResponseRedirect(reverse('oxybeles_detail',
                                             args=(item.uuid,)))
-    return render_to_response(template_name, 
-                              { &quot;form&quot;: form, }, 
+    return render_to_response(template_name,
+                              { &quot;form&quot;: form, },
                               context_instance=RequestContext(request))
 new = login_required(new)
 
+def detail(request, uuid, form_class=SendItemForm, template_name='oxybeles/pasteditem_detail.html'):
+    form = form_class()
+    if request.method == 'POST':
+        if request.POST[&quot;action&quot;] == &quot;send&quot;:
+            form = form_class(sender=request.user, data=request.POST)
+            if form.is_valid():
+                form.save()
+                request.user.message_set.create(
+                    message=ugettext(&quot;The pasted item was sent.&quot;))
+                url = form.pasted_item.get_absolute_url()
+                return HttpResponseRedirect(url)
+    pasted_item = get_object_or_404(PastedItem, uuid=uuid)
+    return render_to_response(template_name,
+                              { 'object': pasted_item, 'form': form },
+                              context_instance=RequestContext(request))
+detail = login_required(detail)</diff>
      <filename>views.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1af5676234f4ea1a29da3662e57fde92c052b2eb</id>
    </parent>
  </parents>
  <author>
    <name>Fernando Correia</name>
    <email>fernandoacorreia@gmail.com</email>
  </author>
  <url>http://github.com/fernandoacorreia/oxybeles/commit/225476e42b28d91fecbd664746afabb91a5fc538</url>
  <id>225476e42b28d91fecbd664746afabb91a5fc538</id>
  <committed-date>2008-11-08T03:00:32-08:00</committed-date>
  <authored-date>2008-11-08T03:00:32-08:00</authored-date>
  <message>Part 7</message>
  <tree>7fc6e019ff0666eebde8436cb5809568da9b7444</tree>
  <committer>
    <name>Fernando Correia</name>
    <email>fernandoacorreia@gmail.com</email>
  </committer>
</commit>
