Repository: carpentries/amy

Issue:
Rename Person.active to show that it's about allowing contact
Spun off from #147.  See also, #127 and #130.

On Wed, Jan 21, 2015 at 06:35:50AM -0800, Scott Burns wrote:

> > The "active" flag in the Person class indicates whether they're
> > currently interested in being contacted, taking part in workshops,
> > etc.
> 
> @wking the help text on this field is good, but we need to make sure
> future selves/others don't mix this up w/ the `is_active` attr that
> subclassing `AbstractUser` requires that the django auth machinery
> uses behind the scenes.

I'm fine renaming the field to something else. `contactable` sounds like “is it possible to contact them?” to me. How about `away` (or `away_until`) as a DateField, with the following
semantics:
- `away == Null`, for “feel free to contact me”
- `away > today()`, for “I expect I'll be away until ‘away’.  Don't
  contact me”
- `away <= today()`, for “I thought I'd be back by now, but I'm not.
  Don't contact me”

If we want to stick with the boolean, maybe `open_to_communication`?

Rename Person.active to show that it's about allowing contact
Spun off from #147.  See also, #127 and #130.

On Wed, Jan 21, 2015 at 06:35:50AM -0800, Scott Burns wrote:

> > The "active" flag in the Person class indicates whether they're
> > currently interested in being contacted, taking part in workshops,
> > etc.
> 
> @wking the help text on this field is good, but we need to make sure
> future selves/others don't mix this up w/ the `is_active` attr that
> subclassing `AbstractUser` requires that the django auth machinery
> uses behind the scenes.

I'm fine renaming the field to something else. `contactable` sounds like “is it possible to contact them?” to me. How about `away` (or `away_until`) as a DateField, with the following
semantics:
- `away == Null`, for “feel free to contact me”
- `away > today()`, for “I expect I'll be away until ‘away’.  Don't
  contact me”
- `away <= today()`, for “I thought I'd be back by now, but I'm not.
  Don't contact me”

If we want to stick with the boolean, maybe `open_to_communication`?



Discussion:
I don't know the dates for any of the people marked as "don't contact".  
`participating` ?  (I think were over-thinking this :-)

On Wed, Jan 21, 2015 at 12:28:22PM -0800, Greg Wilson wrote:

> I don't know the dates for any of the people marked as "don't
> contact".

Ok, so we'll stick with a boolean.

> `participating` ?  (I think were over-thinking this :-)

I think so far I like your ‘may_contact’ best [1](https://github.com/swcarpentry/amy/pull/147#issuecomment-70853436).  I'd missed that
suggestion when writing up the initial post for this issue.

On Wed, Jan 21, 2015 at 12:28:22PM -0800, Greg Wilson wrote:

> I think were over-thinking this :-)

And this issue is because we think ‘active’ is too easily confused
with ‘in_active’, not because the code doesn't work.  If we're going
to bikeshed for clarity, we might as well try and find a most-popular
color.  At least that reduces the chance of a “Rename
Person.<whatever> …” issue later ;).

+1 for 'may_contact' - shall I do the PR?
G

On Wed, Jan 21, 2015 at 01:36:24PM -0800, Greg Wilson wrote:

> +1 for 'may_contact' - shall I do the PR?

Sure.  I wouldn't bother about migrations though, since #147 is
blowing them away (currently in commit 1125402a).  Alternatively, this
can be our first migration after landing #147 (once we finish writing
it ;).

I don't know the dates for any of the people marked as "don't contact".  
`participating` ?  (I think were over-thinking this :-)

On Wed, Jan 21, 2015 at 12:28:22PM -0800, Greg Wilson wrote:

> I don't know the dates for any of the people marked as "don't
> contact".

Ok, so we'll stick with a boolean.

> `participating` ?  (I think were over-thinking this :-)

I think so far I like your ‘may_contact’ best [1](https://github.com/swcarpentry/amy/pull/147#issuecomment-70853436).  I'd missed that
suggestion when writing up the initial post for this issue.

On Wed, Jan 21, 2015 at 12:28:22PM -0800, Greg Wilson wrote:

> I think were over-thinking this :-)

And this issue is because we think ‘active’ is too easily confused
with ‘in_active’, not because the code doesn't work.  If we're going
to bikeshed for clarity, we might as well try and find a most-popular
color.  At least that reduces the chance of a “Rename
Person.<whatever> …” issue later ;).

+1 for 'may_contact' - shall I do the PR?
G

On Wed, Jan 21, 2015 at 01:36:24PM -0800, Greg Wilson wrote:

> +1 for 'may_contact' - shall I do the PR?

Sure.  I wouldn't bother about migrations though, since #147 is
blowing them away (currently in commit 1125402a).  Alternatively, this
can be our first migration after landing #147 (once we finish writing
it ;).


Resolving patch:
diff --git a/migrater.py b/migrater.py
--- a/migrater.py
+++ b/migrater.py
@@ -150,7 +150,7 @@ def insert(cursor, table, fields):
     if person in facts_lookup:
         gender, active, airport, github, twitter, url = facts_lookup[person]
     else:
-        gender, active, airport, github, twitter, url = None, None, None, None, None, None
+        gender, active, airport, github, twitter, url = None, True, None, None, None, None
 
     person, personal, middle, family, email, gender, github, twitter, url = \
         fake(i, person, personal, middle, family, email, gender, github, twitter, url)
@@ -169,7 +169,7 @@ def insert(cursor, table, fields):
                   'github' : github,
                   'twitter' : twitter,
                   'url' : url,
-                  'active' : True if active else False}
+                  'may_contact' : True if active else False}
         insert(new_crs, 'workshops_person', fields)
     except Exception, e:
         fail('person', fields, e)
diff --git a/workshops/migrations/0045_auto_20150122_0957.py b/workshops/migrations/0045_auto_20150122_0957.py
new file mode 100644
--- /dev/null
+++ b/workshops/migrations/0045_auto_20150122_0957.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('workshops', '0044_merge'),
+    ]
+
+    operations = [
+        migrations.RemoveField(
+            model_name='person',
+            name='active',
+        ),
+        migrations.AddField(
+            model_name='person',
+            name='may_contact',
+            field=models.BooleanField(default=True),
+            preserve_default=True,
+        ),
+    ]
diff --git a/workshops/models.py b/workshops/models.py
--- a/workshops/models.py
+++ b/workshops/models.py
@@ -59,18 +59,17 @@ class Person(models.Model):
         (OTHER, 'Other'),
         )
 
-    personal   = models.CharField(max_length=STR_LONG)
-    middle     = models.CharField(max_length=STR_LONG, null=True, blank=True)
-    family     = models.CharField(max_length=STR_LONG)
-    email      = models.CharField(max_length=STR_LONG, unique=True, null=True, blank=True)
-    gender     = models.CharField(max_length=1, choices=GENDER_CHOICES, null=True, blank=True)
-    active     = models.BooleanField(default=True,
-                                     help_text='Are we currently allowed to contact this person?')
-    airport    = models.ForeignKey(Airport, null=True, blank=True)
-    github     = models.CharField(max_length=STR_MED, unique=True, null=True, blank=True)
-    twitter    = models.CharField(max_length=STR_MED, unique=True, null=True, blank=True)
-    url        = models.CharField(max_length=STR_LONG, null=True, blank=True)
-    slug       = models.CharField(max_length=STR_LONG, null=True, blank=True)
+    personal    = models.CharField(max_length=STR_LONG)
+    middle      = models.CharField(max_length=STR_LONG, null=True, blank=True)
+    family      = models.CharField(max_length=STR_LONG)
+    email       = models.CharField(max_length=STR_LONG, unique=True, null=True, blank=True)
+    gender      = models.CharField(max_length=1, choices=GENDER_CHOICES, null=True, blank=True)
+    may_contact = models.BooleanField(default=True)
+    airport     = models.ForeignKey(Airport, null=True, blank=True)
+    github      = models.CharField(max_length=STR_MED, unique=True, null=True, blank=True)
+    twitter     = models.CharField(max_length=STR_MED, unique=True, null=True, blank=True)
+    url         = models.CharField(max_length=STR_LONG, null=True, blank=True)
+    slug        = models.CharField(max_length=STR_LONG, null=True, blank=True)
 
     def fullname(self):
         middle = ''


Test patch:
diff --git a/workshops/test/base.py b/workshops/test/base.py
--- a/workshops/test/base.py
+++ b/workshops/test/base.py
@@ -75,7 +75,7 @@ def _setUpInstructors(self):
         '''Set up person objects representing instructors.'''
 
         self.hermione = Person.objects.create(personal='Hermione', middle=None, family='Granger',
-                                              email='hermione@granger.co.uk', gender='F', active=True,
+                                              email='hermione@granger.co.uk', gender='F', may_contact=True,
                                               airport=self.airport_0_0, github='herself',
                                               twitter='herself', url='http://hermione.org', slug='granger.h')
         Award.objects.create(person=self.hermione,
@@ -85,7 +85,7 @@ def _setUpInstructors(self):
         Qualification.objects.create(person=self.hermione, skill=self.sql)
 
         self.harry = Person.objects.create(personal='Harry', middle=None, family='Potter',
-                                           email='harry@hogwarts.edu', gender='M', active=True,
+                                           email='harry@hogwarts.edu', gender='M', may_contact=True,
                                            airport=self.airport_0_50, github='hpotter',
                                            twitter=None, url=None, slug='potter.h')
         Award.objects.create(person=self.harry,
@@ -94,7 +94,7 @@ def _setUpInstructors(self):
         Qualification.objects.create(person=self.harry, skill=self.sql)
 
         self.ron = Person.objects.create(personal='Ron', middle=None, family='Weasley',
-                                         email='rweasley@ministry.gov.uk', gender='M', active=False,
+                                         email='rweasley@ministry.gov.uk', gender='M', may_contact=False,
                                          airport=self.airport_50_100, github=None,
                                          twitter=None, url='http://geocities.com/ron_weas', slug='weasley.ron')
         Award.objects.create(person=self.ron,
@@ -106,13 +106,13 @@ def _setUpNonInstructors(self):
         '''Set up person objects representing non-instructors.'''
 
         self.spiderman = Person.objects.create(personal='Peter', middle='Q.', family='Parker',
-                                               email='peter@webslinger.net', gender='O', active=True)
+                                               email='peter@webslinger.net', gender='O', may_contact=True)
 
         self.ironman = Person.objects.create(personal='Tony', middle=None, family='Stark',
-                                             email='me@stark.com', gender=None, active=True)
+                                             email='me@stark.com', gender=None, may_contact=True)
 
         self.blackwidow = Person.objects.create(personal='Natasha', middle=None, family='Romanova',
-                                                email=None, gender='F', active=False)
+                                                email=None, gender='F', may_contact=False)
 
     def _parse(self, response, save_to=None):
         """
diff --git a/workshops/test/test_person.py b/workshops/test/test_person.py
--- a/workshops/test/test_person.py
+++ b/workshops/test/test_person.py
@@ -64,7 +64,7 @@ def _check_person(self, doc, person):
                   ('family', person.family),
                   ('email', person.email),
                   ('gender', person.get_gender_display()),
-                  ('active', person.active),
+                  ('may_contact', person.may_contact),
                   ('airport', person.airport),
                   ('github', person.github),
                   ('twitter', person.twitter),