From d4e80b0d979037b9c5581ab620fe2de9e4a9c87c Mon Sep 17 00:00:00 2001
From: Branson Stephens <branson.stephens@ligo.org>
Date: Fri, 20 Feb 2015 12:46:14 -0600
Subject: [PATCH] Window-dressing changes for GlitchDB.

---
 .../migrations/0015_add_gstlal_user_and_dn.py | 121 ++++++++++++++++++
 templates/base.html                           |   6 +-
 templates/gracedb/index.html                  |  11 +-
 templates/rest_framework/api.html             |   4 +-
 4 files changed, 132 insertions(+), 10 deletions(-)
 create mode 100644 ligoauth/migrations/0015_add_gstlal_user_and_dn.py

diff --git a/ligoauth/migrations/0015_add_gstlal_user_and_dn.py b/ligoauth/migrations/0015_add_gstlal_user_and_dn.py
new file mode 100644
index 000000000..abf5e5f9a
--- /dev/null
+++ b/ligoauth/migrations/0015_add_gstlal_user_and_dn.py
@@ -0,0 +1,121 @@
+# -*- coding: utf-8 -*-
+import datetime
+from south.db import db
+from south.v2 import DataMigration
+from django.db import models
+
+
+users = [
+        {
+            'username' : 'gstlal-spiir',
+            'first_name' : '',
+            'last_name' : 'GSTLAL SPIIR Analysis',
+            'email' : 'qi.chu@ligo.org',
+            'dns' : [
+                "/DC=org/DC=ligo/O=LIGO/OU=Services/CN=gstlal-spiir/ldas-pcdev1.ligo.caltech.edu",
+            ]
+        },
+]
+
+
+class Migration(DataMigration):
+
+    def forwards(self, orm):
+        LocalUser = orm['ligoauth.LocalUser']
+        X509Cert = orm['ligoauth.X509Cert']
+
+        # Local Users
+        for entry in users:
+            user, created = LocalUser.objects.get_or_create(username=entry['username'])
+            if created:
+                user.first_name = entry['first_name']
+                user.last_name = entry['last_name']
+                user.email = entry['email']
+                user.is_active = True
+                user.is_staff = False
+                user.is_superuser = False
+                user.save()
+            current_dns = set([cert.subject for cert in user.x509cert_set.all()])
+            new_dns = set(entry['dns'])
+
+            missing_dns = new_dns - current_dns
+            redundant_dns = current_dns - new_dns
+
+            for dn in missing_dns:
+                cert, created = X509Cert.objects.get_or_create(subject=dn)
+                if created:
+                    cert.save()
+                cert.users.add(user)
+
+            for dn in redundant_dns:
+                cert = X509Cert.objects.get(subject=dn)
+                cert.users.remove(user)
+
+    def backwards(self, orm):
+        LocalUser = orm['ligoauth.LocalUser']
+        X509Cert = orm['ligoauth.X509Cert']
+        for entry in users:
+            for dn in entry['dns']:
+                cert = X509Cert.objects.get(subject=dn)
+                cert.delete()
+
+            user = LocalUser.objects.get(username=entry['username'])
+            user.delete()                   
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            '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': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': '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'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
+        },
+        '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'}),
+            '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'})
+        },
+        'ligoauth.ligoldapuser': {
+            'Meta': {'object_name': 'LigoLdapUser', '_ormbases': ['auth.User']},
+            'ldap_dn': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
+            'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'})
+        },
+        'ligoauth.localuser': {
+            'Meta': {'object_name': 'LocalUser', '_ormbases': ['auth.User']},
+            'user_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True', 'primary_key': 'True'})
+        },
+        'ligoauth.x509cert': {
+            'Meta': {'object_name': 'X509Cert'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'subject': ('django.db.models.fields.CharField', [], {'max_length': '200'}),
+            'users': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.User']", 'symmetrical': 'False'})
+        }
+    }
+
+    complete_apps = ['ligoauth']
+    symmetrical = True
diff --git a/templates/base.html b/templates/base.html
index 5d918ff4c..b9fdaa9da 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -4,7 +4,7 @@
 <head>
 {% block headcontents %}
     <link rel="stylesheet" href="{{STATIC_URL}}css/style.css" />
-    <title>GraceDb | {% block title %}{% endblock %}</title>
+    <title>GlitchDD | {% block title %}{% endblock %}</title>
 <!-- START TESTING -->
 <script type="text/javascript">
 function changeTime(obj, label) {
@@ -27,7 +27,7 @@ function changeTime(obj, label) {
 <div id="content">
 
 <center>
-<h1> GraceDB &mdash; Gravitational Wave Candidate Event Database</h1>
+<h1> GlitchDB &mdash; Glitch Candidate Event Database</h1>
 </center>
 
 {% block nav %}
@@ -51,9 +51,11 @@ function changeTime(obj, label) {
 </ul>
 <center>
     {% if config_name %}
+<!--
       <h1 style="color: red;">
           {{config_name}}
       </h1>
+-->
     {% endif %}
 </center>
 {% endblock %}
diff --git a/templates/gracedb/index.html b/templates/gracedb/index.html
index 3760eac13..050699c13 100644
--- a/templates/gracedb/index.html
+++ b/templates/gracedb/index.html
@@ -1,6 +1,6 @@
 {% extends "base.html" %}
 {% block title %}Home{% endblock %}
-{% block heading %}GraceDB Overview{% endblock %}
+{% block heading %}GlitchDB Overview{% endblock %}
 {% block pageid %}home{% endblock %}
 {% block jscript %}
     <style>
@@ -32,15 +32,14 @@
 
 <div class="text">
 
-<p> The gravitational-wave candidate event database (GraceDB) is a
-prototype system to organize candidate events from gravitational-wave
-searches and to provide an environment to record information about
-follow-ups. </p>
+<p> The glitch database (GlitchDB) is a
+prototype system to organize candidate glitch events
+and to provide an environment to record information about
+follow-ups. This project is based on <a href="https://gracedb.ligo.org">GraceDB</a>. </p>
 
 <ul>
 
 <li><a href="https://www.lsc-group.phys.uwm.edu/daswg/wiki/GraceDBER6">Recent changes</a> <font color="red">(IMPORTANT!) </font></li>
-<li><a href="https://gw-astronomy.org/wiki/LV_EM/ElectroMagneticBulletinBoard">Prototype EMBB description</a></li>
 <li><a href="https://www.lsc-group.phys.uwm.edu/daswg/wiki/HowtoGraceDb">Howto page</a></li>
 <li><a href="https://www.lsc-group.phys.uwm.edu/daswg/projects/gracedb.html">DASWG Project page</a></li>
 <li><a href="{% url "shib:api-root" %}">Browseable REST API</a>
diff --git a/templates/rest_framework/api.html b/templates/rest_framework/api.html
index 66e196a07..4d0025bcb 100644
--- a/templates/rest_framework/api.html
+++ b/templates/rest_framework/api.html
@@ -1,9 +1,9 @@
 {% extends "rest_framework/base.html" %}
 
-{% block title %}GraceDB REST API{% endblock %}
+{% block title %}GlitchDB REST API{% endblock %}
 
 {% block branding %}
-GraceDB &mdash; REST API
+GlitchDB &mdash; REST API
     {% if config_name %}
       <span style="color: red;">
           {{config_name}}
-- 
GitLab