code: def attachment_form(context, obj):
      
      if context['user'].has_perm('attachments.add_attachment'):
          return {
              'form': AttachmentForm(),
              'form_url': add_url_for_obj(obj),
              'next': context.request.build_absolute_uri(),
          }
      else:
          return {'form': None}
docs: Renders a "upload attachment" form.
  
      The user must own ``attachments.add_attachment permission`` to add
      attachments.