add remove connection button for person to person connections
This commit is contained in:
parent
85a28bb220
commit
41441d1739
|
@ -28,7 +28,7 @@ class Person(ItfModel):
|
||||||
form_names = ['PersonForm', 'PopupPersonForm']
|
form_names = ['PersonForm', 'PopupPersonForm']
|
||||||
fts_fields = ['first_name', 'last_name', 'email', 'about']
|
fts_fields = ['first_name', 'last_name', 'email', 'about']
|
||||||
#Basic Info
|
#Basic Info
|
||||||
user = models.OneToOneField(User, blank=True, null=True, db_index=True, editable=False)
|
user = models.OneToOneField(User, blank=True, null=True, db_index=True)
|
||||||
first_name = models.CharField(max_length=255)
|
first_name = models.CharField(max_length=255)
|
||||||
last_name = models.CharField(max_length=255)
|
last_name = models.CharField(max_length=255)
|
||||||
email = models.EmailField(blank=True, null=True, unique=True, db_index=True)
|
email = models.EmailField(blank=True, null=True, unique=True, db_index=True)
|
||||||
|
@ -79,6 +79,26 @@ class Person(ItfModel):
|
||||||
def main_image(self):
|
def main_image(self):
|
||||||
return self.image
|
return self.image
|
||||||
|
|
||||||
|
|
||||||
|
def info_dict(self, request):
|
||||||
|
'''
|
||||||
|
Ideally you should not over-ride this - over-ride .get_dict() to pass custom data.
|
||||||
|
'''
|
||||||
|
d = self.get_dict()
|
||||||
|
# d['add_form'] = self.__class__.get_add_form()
|
||||||
|
d['forms'] = self.__class__.get_forms()
|
||||||
|
d['obj'] = self
|
||||||
|
d['content_type'] = self.get_content_type()
|
||||||
|
if (request.user and self.user) and request.user.id == self.user.id:
|
||||||
|
d['is_own_profile'] = True
|
||||||
|
try:
|
||||||
|
edit_url = self.get_edit_url()
|
||||||
|
d['edit_url'] = edit_url
|
||||||
|
d['user_has_perms'] = self.user_has_perms(request.user)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return d
|
||||||
|
|
||||||
def get_dict(self):
|
def get_dict(self):
|
||||||
#lconnections = [obj for obj in self.connections.all()]
|
#lconnections = [obj for obj in self.connections.all()]
|
||||||
#rconnections = [ obj for obj in PersonPerson.objects.filter(person2=self)
|
#rconnections = [ obj for obj in PersonPerson.objects.filter(person2=self)
|
||||||
|
|
|
@ -11,6 +11,22 @@ from django.contrib.auth.decorators import login_required
|
||||||
from django.views.decorators.csrf import csrf_exempt
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
|
def remove_personperson(request):
|
||||||
|
connection_id = request.GET.get('id', None)
|
||||||
|
conn = PersonPerson.objects.get(pk=connection_id)
|
||||||
|
if not request.user or not request.user.is_authenticated():
|
||||||
|
return render_to_json_response({'error': 'Not authenticated'})
|
||||||
|
if request.user.id != conn.person1.user.id and request.user.id != conn.person2.user.id:
|
||||||
|
return render_to_json_response({'error': 'User not involved'})
|
||||||
|
if request.user.id == conn.person1.user.id or request.user.id == conn.person2.user.id:
|
||||||
|
conn.delete()
|
||||||
|
# if request.user.id == conn.person2.user.id:
|
||||||
|
# conn.delete()
|
||||||
|
#ideally one would mark as disapproved here.
|
||||||
|
return render_to_json_response({'success': 'ok'})
|
||||||
|
|
||||||
|
|
||||||
def person_form(request):
|
def person_form(request):
|
||||||
person = Person.objects.all()[0]
|
person = Person.objects.all()[0]
|
||||||
form = PersonForm(instance=person)
|
form = PersonForm(instance=person)
|
||||||
|
|
|
@ -182,6 +182,11 @@ $(function() {
|
||||||
<div>{{ connection.person2.about|truncatewords:40 }}</div>
|
<div>{{ connection.person2.about|truncatewords:40 }}</div>
|
||||||
<div>{{ connection.person2.locations.0.city.name }}</div>
|
<div>{{ connection.person2.locations.0.city.name }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if is_own_profile %}
|
||||||
|
<div class="disapprove" data-connection="{{ connection.id }}">
|
||||||
|
X
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
|
||||||
</div> <!-- end production each -->
|
</div> <!-- end production each -->
|
||||||
|
@ -197,6 +202,11 @@ $(function() {
|
||||||
<div>{{ connection.person1.locations.0.city.name }}</div>
|
<div>{{ connection.person1.locations.0.city.name }}</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
{% if is_own_profile %}
|
||||||
|
<div class="disapprove" data-connection="{{ connection.id }}">
|
||||||
|
X
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
|
||||||
</div> <!-- end production each -->
|
</div> <!-- end production each -->
|
||||||
|
@ -211,7 +221,22 @@ $(function() {
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
-->
|
-->
|
||||||
|
<script>
|
||||||
|
$('.disapprove').click(function() {
|
||||||
|
var $that = $(this);
|
||||||
|
if (confirm("Are you sure you wish to remove this connection?")) {
|
||||||
|
var url = "/profiles/remove_connection";
|
||||||
|
var id = $(this).attr("data-connection");
|
||||||
|
$.getJSON(url, {'id': id}, function(response) {
|
||||||
|
if (response.hasOwnProperty('error')) {
|
||||||
|
alert(response.error);
|
||||||
|
} else {
|
||||||
|
$that.parents('.productionEach').slideUp();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</div> <!-- end connections -->
|
</div> <!-- end connections -->
|
||||||
|
|
||||||
{% if productions %}
|
{% if productions %}
|
||||||
|
|
|
@ -48,6 +48,7 @@ urlpatterns = patterns('',
|
||||||
(r'edit_profile', 'itfprofiles.views.edit_profile'),
|
(r'edit_profile', 'itfprofiles.views.edit_profile'),
|
||||||
# (r'^mediagallery/upload', 'mediagallery.views.edit_gallery'),
|
# (r'^mediagallery/upload', 'mediagallery.views.edit_gallery'),
|
||||||
(r'^autocomplete/(?P<ctype_id>\d+)', 'app.views.autocomplete'),
|
(r'^autocomplete/(?P<ctype_id>\d+)', 'app.views.autocomplete'),
|
||||||
|
(r'^profiles/remove_connection/', 'itfprofiles.views.remove_personperson'),
|
||||||
(r'^popup_form/(?P<ctype_id>\d+)', 'app.views.popup_form'),
|
(r'^popup_form/(?P<ctype_id>\d+)', 'app.views.popup_form'),
|
||||||
# (r'^autocompletes/itfprofiles/$', 'itfprofiles.views.autocomplete'),
|
# (r'^autocompletes/itfprofiles/$', 'itfprofiles.views.autocomplete'),
|
||||||
(r'^popup/person', 'itfprofiles.views.personpopup'), (r'^popup/theatregroup', 'itfprofiles.views.grouppopup'),
|
(r'^popup/person', 'itfprofiles.views.personpopup'), (r'^popup/theatregroup', 'itfprofiles.views.grouppopup'),
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
Django==1.3
|
#Django==1.3
|
||||||
|
Django==1.4.6
|
||||||
ox>=2.1.0
|
ox>=2.1.0
|
||||||
|
|
||||||
-e bzr+http://firefogg.org/dev/python-firefogg/#egg=python-firefogg
|
-e bzr+http://firefogg.org/dev/python-firefogg/#egg=python-firefogg
|
||||||
|
@ -20,6 +21,7 @@ django-crispy-forms==1.1.4
|
||||||
django-floppyforms==1.0
|
django-floppyforms==1.0
|
||||||
django-markitup==1.0.0
|
django-markitup==1.0.0
|
||||||
twitter
|
twitter
|
||||||
|
twython
|
||||||
#-e git+git://github.com/pennersr/django-allauth.git#egg=django-allauth
|
#-e git+git://github.com/pennersr/django-allauth.git#egg=django-allauth
|
||||||
-e git://github.com/pennersr/django-allauth.git@92f3ebe231267bffba53c6c0c1d4eb6e13755bb5#egg=django_allauth-0.6.0-py2.7-dev
|
-e git://github.com/pennersr/django-allauth.git@92f3ebe231267bffba53c6c0c1d4eb6e13755bb5#egg=django_allauth-0.6.0-py2.7-dev
|
||||||
-e git+git://github.com/pythonforfacebook/facebook-sdk.git#egg=facebook-sdk
|
-e git+git://github.com/pythonforfacebook/facebook-sdk.git#egg=facebook-sdk
|
||||||
|
|
Loading…
Reference in New Issue
Block a user