Repository: dotkom/onlineweb4

Issue:
There should be a "Eldsterådet" and "Æresmedlem" category for members



Discussion:
I suggest adding pangKom as well. This is a simple matter of changing the tuple in authentication/models.py

This is user positions we are talking about here? This introduces a problem. While common positions is fair to update each year until you quit. Eldsterådet and Æresmedlem is a life long position you don't really want to update every year.

People with this "field of study" (that's what I interpreted it as), don't need to return a year, just return 0 or -1 or something. I think the main problem was that a user who's currently part of any of the three possible "lifelong" memberships has to list themselves as "Other member", which is slightly degrading?

If you are thinking of membership lengths, we could do every 5 years for pangKom (or longer), and lifetime for Eldsterådet and Æresmedlem. 

I see what you are thinking. We should prolly have some alumni-shit as well as the internal Online-stuff? That way normal members can also set their status to something when they quit. I am also worried that a lot of these regular users will not update their profile when they quit NTNU. Maybe we should have some sort of middleware stuff that automatically sets the user to FOS=Inactive/Alumni/whatever when their shit has expired a while ago. This to ensure we have some decent data in the profiles of people.

Main intention was for events of type immball, studenterhytta and the like. 

Could/should of course be extended to user positions as well. 

For eldsteraadet, pangkom and æresmedlemmer can't we just add django groups and place them there. Then on events we make UserGroupRules for these groups and make a rule bundle with them called "Old guys" or something. Problem solved.


Resolving patch:
diff --git a/apps/authentication/admin.py b/apps/authentication/admin.py
--- a/apps/authentication/admin.py
+++ b/apps/authentication/admin.py
@@ -3,7 +3,7 @@
 from django.contrib import admin
 from django.utils.translation import ugettext as _
 
-from apps.authentication.models import AllowedUsername, Email, OnlineUser, Position
+from apps.authentication.models import AllowedUsername, Email, OnlineUser, Position, SpecialPosition
 
 
 class EmailInline(admin.TabularInline):
@@ -49,3 +49,9 @@ class PositionAdmin(admin.ModelAdmin):
     model = Position
 
 admin.site.register(Position, PositionAdmin)
+
+
+class SpecialPositionAdmin(admin.ModelAdmin):
+    model = SpecialPosition
+
+admin.site.register(SpecialPosition, SpecialPositionAdmin)
diff --git a/apps/authentication/migrations/0023_auto__add_specialposition.py b/apps/authentication/migrations/0023_auto__add_specialposition.py
new file mode 100644
--- /dev/null
+++ b/apps/authentication/migrations/0023_auto__add_specialposition.py
@@ -0,0 +1,119 @@
+# -*- coding: utf-8 -*-
+from south.utils import datetime_utils as datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        # Adding model 'SpecialPosition'
+        db.create_table(u'authentication_specialposition', (
+            (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('position', self.gf('django.db.models.fields.CharField')(max_length=50)),
+            ('since_year', self.gf('django.db.models.fields.IntegerField')(max_length=4)),
+            ('user', self.gf('django.db.models.fields.related.ForeignKey')(related_name='special_positions', to=orm['authentication.OnlineUser'])),
+        ))
+        db.send_create_signal(u'authentication', ['SpecialPosition'])
+
+
+    def backwards(self, orm):
+        # Deleting model 'SpecialPosition'
+        db.delete_table(u'authentication_specialposition')
+
+
+    models = {
+        u'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': u"orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        u'auth.permission': {
+            'Meta': {'ordering': "(u'content_type__app_label', u'content_type__model', u'codename')", 'unique_together': "((u'content_type', u'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['contenttypes.ContentType']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        u'authentication.allowedusername': {
+            'Meta': {'ordering': "(u'username',)", 'object_name': 'AllowedUsername'},
+            'description': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'expiration_date': ('django.db.models.fields.DateField', [], {}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'note': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'registered': ('django.db.models.fields.DateField', [], {}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '10'})
+        },
+        u'authentication.email': {
+            'Meta': {'object_name': 'Email'},
+            'email': ('django.db.models.fields.EmailField', [], {'unique': 'True', 'max_length': '75'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'primary': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'email_user'", 'to': u"orm['authentication.OnlineUser']"}),
+            'verified': ('django.db.models.fields.BooleanField', [], {'default': 'False'})
+        },
+        u'authentication.onlineuser': {
+            'Meta': {'ordering': "['first_name', 'last_name']", 'object_name': 'OnlineUser'},
+            'address': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}),
+            'allergies': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'compiled': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'field_of_study': ('django.db.models.fields.SmallIntegerField', [], {'default': '0'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'gender': ('django.db.models.fields.CharField', [], {'default': "'male'", 'max_length': '10'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Group']"}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'infomail': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'mark_rules': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'nickname': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
+            'ntnu_username': ('django.db.models.fields.CharField', [], {'max_length': '10', 'unique': 'True', 'null': 'True', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'phone_number': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}),
+            'rfid': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}),
+            'started_date': ('django.db.models.fields.DateField', [], {'default': 'datetime.datetime(2014, 2, 19, 0, 0)'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'related_name': "u'user_set'", 'blank': 'True', 'to': u"orm['auth.Permission']"}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}),
+            'website': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}),
+            'zip_code': ('django.db.models.fields.CharField', [], {'max_length': '4', 'null': 'True', 'blank': 'True'})
+        },
+        u'authentication.position': {
+            'Meta': {'ordering': "('user', 'period')", 'object_name': 'Position'},
+            'committee': ('django.db.models.fields.CharField', [], {'default': "'hs'", 'max_length': '10'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'period': ('django.db.models.fields.CharField', [], {'default': "'2013-2014'", 'max_length': '9'}),
+            'position': ('django.db.models.fields.CharField', [], {'default': "'medlem'", 'max_length': '10'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'positions'", 'to': u"orm['authentication.OnlineUser']"})
+        },
+        u'authentication.registertoken': {
+            'Meta': {'object_name': 'RegisterToken'},
+            'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '254'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'token': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'register_user'", 'to': u"orm['authentication.OnlineUser']"})
+        },
+        u'authentication.specialposition': {
+            'Meta': {'ordering': "('user', 'since_year')", 'object_name': 'SpecialPosition'},
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'position': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
+            'since_year': ('django.db.models.fields.IntegerField', [], {'max_length': '4'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'special_positions'", 'to': u"orm['authentication.OnlineUser']"})
+        },
+        u'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        }
+    }
+
+    complete_apps = ['authentication']
\ No newline at end of file
diff --git a/apps/authentication/models.py b/apps/authentication/models.py
--- a/apps/authentication/models.py
+++ b/apps/authentication/models.py
@@ -276,7 +276,25 @@ def __unicode__(self):
     class Meta:
         verbose_name = _(u'posisjon')
         verbose_name_plural = _(u'posisjoner')
-        ordering = (u'user', u'period', )
+        ordering = ('user', 'period', )
+
+
+class SpecialPosition(models.Model):
+    """
+    Special object to represent special positions that typically lasts for life.
+    """
+    position   = models.CharField(_(u'Posisjon'), max_length=50, blank=False)
+    since_year = models.IntegerField(_(u'Medlem siden'), max_length=4, blank=False)
+    user       = models.ForeignKey(OnlineUser, related_name='special_positions', blank=False)
+
+    def __unicode__(self):
+        return '%s, %s' % (self.user.get_full_name(), self.position)
+
+    class Meta:
+        verbose_name = _(u'spesialposisjon')
+        verbose_name_plural = _(u'spesialposisjoner')
+        ordering = ('user', 'since_year',)
+
 
 # Static method for resetting all users mark rules accepted field to false due to changes in mark rules
 def reset_marks_acceptance():


Test patch: