Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

727743 add field wiki profile #8

Merged
merged 1 commit into from over 2 years ago

2 participants

Giorgos Logiotatidis Jen Fong-Adwent
remo/profiles/templates/profiles_edit.html
... ... @@ -135,7 +135,14 @@
135 135 {{ profileform.mozillians_profile_url.errors }}
136 136 </small>
137 137 {% endif %}
138   - <select name="mentor">
  138 + <input type="text" placeholder="Wiki profile" value="{{ profileform.wiki_profile_url.value }}"
1

line up 'value' attr and the other ones below 'type'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
remo/profiles/templates/profiles_view.html
... ... @@ -297,4 +303,4 @@ <h5 class="grayed">
297 303 markers.addMarker(new OpenLayers.Marker(lonlat, icon.clone()));
298 304 markers.setOpacity(0.7);
299 305 </script>
1

is there any way to non-inline this javascript, even if it has to be an additional js file? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
media/js/profiles_view.js
((2 lines not shown))
  2 + var map = new OpenLayers.Map('map', {
  3 + controls: [
  4 + new OpenLayers.Control.Navigation(),
  5 + new OpenLayers.Control.ArgParser(),
  6 + new OpenLayers.Control.Attribution()],
  7 + projection: new OpenLayers.Projection('EPSG:900913')
  8 + });
  9 + var panel = new OpenLayers.Control.Panel();
  10 + var markers = new OpenLayers.Layer.Markers('Reps');
  11 + var osm = new OpenLayers.Layer.OSM();
  12 +
  13 + map.addLayers([osm]);
  14 + map.zoomToMaxExtent();
  15 + map.addLayer(markers);
  16 +
  17 + var lonlat = new OpenLayers.LonLat($('#map').data('lon'),
1

one small nit! :) set $('#map') in a var so it's cached once and not called twice. e.g. var map_el = $('#map');

new OpenLayers.LonLat(map_el.data('lon') ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Giorgos Logiotatidis glogiotatidis merged commit f85f9e6 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Feb 21, 2012
Giorgos Logiotatidis glogiotatidis Add wiki_profile_url field. 49ebc0a
This page is out of date. Refresh to see the latest.
27 media/js/profiles_view.js
... ... @@ -0,0 +1,27 @@
  1 +$(document).ready( function () {
  2 + var map = new OpenLayers.Map('map', {
  3 + controls: [
  4 + new OpenLayers.Control.Navigation(),
  5 + new OpenLayers.Control.ArgParser(),
  6 + new OpenLayers.Control.Attribution()],
  7 + projection: new OpenLayers.Projection('EPSG:900913')
  8 + });
  9 + var panel = new OpenLayers.Control.Panel();
  10 + var markers = new OpenLayers.Layer.Markers('Reps');
  11 + var osm = new OpenLayers.Layer.OSM();
  12 +
  13 + map.addLayers([osm]);
  14 + map.zoomToMaxExtent();
  15 + map.addLayer(markers);
  16 +
  17 + var map_el = $('#map');
  18 + var lonlat = new OpenLayers.LonLat(map_el.data('lon'),
  19 + map_el.data('lat'));
  20 + map.setCenter(lonlat, 8); // Zoom level
  21 + var size = new OpenLayers.Size(21, 33);
  22 + var offset = new OpenLayers.Pixel(-(size.w / 2), -size.h);
  23 + var icon = new OpenLayers.Icon(map_el.data('mediaurl') +
  24 + 'img/remo/marker.png', size, offset);
  25 + markers.addMarker(new OpenLayers.Marker(lonlat, icon.clone()));
  26 + markers.setOpacity(0.7);
  27 +})
7 remo/profiles/fixtures/demo_users.json
@@ -112,6 +112,7 @@
112 112 "region":"attika",
113 113 "country": "Greece",
114 114 "mozillians_profile_url":"http://mozillians.org/en-US/about/",
  115 + "wiki_profile_url": "https://wiki.mozilla.org/User:",
115 116 "irc_name": "admin",
116 117 "irc_channels": "",
117 118 "lon": 13.41,
@@ -139,6 +140,7 @@
139 140 "region": "CA",
140 141 "country": "USA",
141 142 "mozillians_profile_url":"http://mozillians.org/en-US/about/",
  143 + "wiki_profile_url": "https://wiki.mozilla.org/User:",
142 144 "irc_name": "babis",
143 145 "irc_channels": "",
144 146 "lon": 13.41,
@@ -167,6 +169,7 @@
167 169 "region": "NY",
168 170 "country": "USA",
169 171 "mozillians_profile_url":"http://mozillians.org/en-US/about/",
  172 + "wiki_profile_url": "https://wiki.mozilla.org/User:",
170 173 "irc_name": "md",
171 174 "irc_channels": "",
172 175 "lon": 13.41,
@@ -175,7 +178,7 @@
175 178 "user": 6,
176 179 "birth_date": "1992-03-09",
177 180 "personal_website_url": "",
178   - "diaspora_url": "http://joindiaspora.com/md",
  181 + "diaspora_url": "https://joindiaspora.com/",
179 182 "personal_blog_feed": "",
180 183 "facebook_url": "",
181 184 "mentor": 4,
@@ -196,6 +199,7 @@
196 199 "region": "Marmara",
197 200 "country": "Turkey",
198 201 "mozillians_profile_url":"http://mozillians.org/en-US/about/",
  202 + "wiki_profile_url": "https://wiki.mozilla.org/User:",
199 203 "irc_name": "koki",
200 204 "irc_channels": "",
201 205 "lon": 13.41,
@@ -236,6 +240,7 @@
236 240 "diaspora_url": "",
237 241 "personal_blog_feed": "",
238 242 "mozillians_profile_url": "",
  243 + "wiki_profile_url": "",
239 244 "mentor": 6,
240 245 "added_by": 5,
241 246 "bio": "This is my bio",
2  remo/profiles/forms.py
@@ -66,7 +66,7 @@ class Meta:
66 66 'twitter_account', 'jabber_id', 'irc_name',
67 67 'irc_channels', 'facebook_url', 'linkedin_url',
68 68 'diaspora_url', 'personal_website_url', 'personal_blog_feed',
69   - 'bio', 'gender', 'mentor')
  69 + 'bio', 'gender', 'mentor', 'wiki_profile_url')
70 70
71 71 def clean_twitter_account(self):
72 72 """Make sure that twitter_account does not start with a '@'."""
90 remo/profiles/migrations/0014_auto__add_field_userprofile_wiki_profile_url.py
... ... @@ -0,0 +1,90 @@
  1 +# encoding: utf-8
  2 +import datetime
  3 +from south.db import db
  4 +from south.v2 import SchemaMigration
  5 +from django.db import models
  6 +
  7 +class Migration(SchemaMigration):
  8 +
  9 + def forwards(self, orm):
  10 +
  11 + # Adding field 'UserProfile.wiki_profile_url'
  12 + db.add_column('profiles_userprofile', 'wiki_profile_url', self.gf('django.db.models.fields.URLField')(default='', max_length=200), keep_default=False)
  13 +
  14 +
  15 + def backwards(self, orm):
  16 +
  17 + # Deleting field 'UserProfile.wiki_profile_url'
  18 + db.delete_column('profiles_userprofile', 'wiki_profile_url')
  19 +
  20 +
  21 + models = {
  22 + 'auth.group': {
  23 + 'Meta': {'object_name': 'Group'},
  24 + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  25 + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
  26 + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
  27 + },
  28 + 'auth.permission': {
  29 + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
  30 + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
  31 + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
  32 + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  33 + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
  34 + },
  35 + 'auth.user': {
  36 + 'Meta': {'object_name': 'User'},
  37 + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
  38 + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
  39 + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
  40 + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
  41 + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  42 + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
  43 + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  44 + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  45 + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
  46 + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
  47 + 'password': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
  48 + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
  49 + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
  50 + },
  51 + 'contenttypes.contenttype': {
  52 + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
  53 + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
  54 + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  55 + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
  56 + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
  57 + },
  58 + 'profiles.userprofile': {
  59 + 'Meta': {'object_name': 'UserProfile'},
  60 + 'added_by': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'users_added'", 'null': 'True', 'to': "orm['auth.User']"}),
  61 + 'bio': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
  62 + 'birth_date': ('django.db.models.fields.DateField', [], {'null': 'True'}),
  63 + 'city': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '30'}),
  64 + 'country': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '30'}),
  65 + 'diaspora_url': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}),
  66 + 'display_name': ('django.db.models.fields.CharField', [], {'default': "''", 'unique': 'True', 'max_length': '15', 'blank': 'True'}),
  67 + 'facebook_url': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}),
  68 + 'gender': ('django.db.models.fields.NullBooleanField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
  69 + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
  70 + 'irc_channels': ('django.db.models.fields.TextField', [], {'default': "''", 'blank': 'True'}),
  71 + 'irc_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '30'}),
  72 + 'jabber_id': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
  73 + 'lat': ('django.db.models.fields.FloatField', [], {'null': 'True'}),
  74 + 'linkedin_url': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}),
  75 + 'local_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50', 'blank': 'True'}),
  76 + 'lon': ('django.db.models.fields.FloatField', [], {'null': 'True'}),
  77 + 'mentor': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'mentors_users'", 'null': 'True', 'to': "orm['auth.User']"}),
  78 + 'mozillians_profile_url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
  79 + 'personal_blog_feed': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}),
  80 + 'personal_website_url': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200', 'blank': 'True'}),
  81 + 'private_email': ('django.db.models.fields.EmailField', [], {'default': "''", 'max_length': '75', 'null': 'True'}),
  82 + 'region': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '30'}),
  83 + 'registration_complete': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
  84 + 'twitter_account': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '16', 'blank': 'True'}),
  85 + 'user': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['auth.User']", 'unique': 'True'}),
  86 + 'wiki_profile_url': ('django.db.models.fields.URLField', [], {'default': "''", 'max_length': '200'})
  87 + }
  88 + }
  89 +
  90 + complete_apps = ['profiles']
5 remo/profiles/models.py
@@ -86,6 +86,11 @@ class UserProfile(models.Model):
86 86 verify_exists=True)
87 87 personal_blog_feed = models.URLField(blank=True, null=False, default='',
88 88 verify_exists=True)
  89 + wiki_profile_url = models.URLField(
  90 + blank=False, null=False, default='', verify_exists=True,
  91 + validators=[
  92 + RegexValidator(regex=r'^http(s)?://wiki.mozilla.org/User:',
  93 + message='Please provide a valid wiki url.')])
89 94 added_by = models.ForeignKey(User, null=True, blank=True,
90 95 related_name='users_added')
91 96 bio = models.TextField(blank=True, default='')
20 remo/profiles/templates/profiles_edit.html
@@ -128,21 +128,31 @@
128 128 {{ userform.email.errors }}
129 129 </small>
130 130 {% endif %}
131   - <input type="text" placeholder="Mozillians.org profile" value="{{ profileform.mozillians_profile_url.value }}"
  131 + <input type="text" placeholder="Mozillians.org profile"
  132 + value="{{ profileform.mozillians_profile_url.value }}"
132 133 name="mozillians_profile_url" class="input-text big">
133 134 {% if profileform.mozillians_profile_url.errors %}
134 135 <small class="error">
135 136 {{ profileform.mozillians_profile_url.errors }}
136 137 </small>
137 138 {% endif %}
  139 + <input type="text" placeholder="Wiki profile"
  140 + value="{{ profileform.wiki_profile_url.value }}"
  141 + name="wiki_profile_url" class="input-text big">
  142 + {% if profileform.wiki_profile_url.errors %}
  143 + <small class="error">
  144 + {{ profileform.wiki_profile_url.errors }}
  145 + </small>
  146 + {% endif %}
138 147 <select name="mentor">
139 148 {% if not profileform.mentor.value %}
140 149 <option selected="selected" value="">
141 150 Choose mentor
142 151 </option>
143   - {% endif %} {% for mentor in mentors %}
144   - <option value="{{ mentor.id }}" {% if mentor.id == profileform.mentor.value %} selected="selected"
145   - {% endif %}>
  152 + {% endif %}
  153 + {% for mentor in mentors %}
  154 + <option value="{{ mentor.id }}" {% if mentor.id == profileform.mentor.value %}
  155 + selected="selected" {% endif %}>
146 156 {{ mentor.get_full_name }}
147 157 </option>
148 158 {% endfor %}
@@ -412,4 +422,4 @@
412 422 {% block bottomextra %}
413 423 <script src="{{ MEDIA_URL }}openlayers/OpenLayers.js"></script>
414 424 <script src="{{ MEDIA_URL }}js/map-point.js" type="text/javascript"></script>
415   -{% endblock %}
  425 +{% endblock %}
44 remo/profiles/templates/profiles_view.html
... ... @@ -1,7 +1,7 @@
1 1 {% extends "base.html" %}
2 2 {% load markup %}
3 3
4   -{% block pagetitle %} Mozilla Reps - Profile of {{ pageuser.userprofile.display_name }} {% endblock %}
  4 +{% block pagetitle %} Mozilla Reps - Profile of {{ pageuser.userprofile.display_name }} {% endblock %}
5 5
6 6 {% block content %}
7 7 <div class="row">
@@ -47,7 +47,10 @@ <h5 class="grayed">
47 47 <img src="{{ pageuser.userprofile.get_avatar_url }}" width="128">
48 48 </div>
49 49 <div class="eight columns smallmap-profile-container">
50   - <div id="map" class="smallmap-profile">
  50 + <div id="map" class="smallmap-profile"
  51 + data-lon="{{ pageuser.userprofile.lon }}"
  52 + data-lat="{{ pageuser.userprofile.lat }}"
  53 + data-mediaurl="{{ MEDIA_URL}}">
51 54 </div>
52 55 </div>
53 56 </div>
@@ -122,9 +125,15 @@ <h5 class="grayed">
122 125 <span class="white radius label">
123 126 Mozillians Profile
124 127 </span>
125   - &nbsp;<a href="{{ pageuser.userprofile.mozillians_profile_url }}">{{ pageuser.userprofile.mozillians_profile_url }}</a>
  128 + &nbsp;{{ pageuser.userprofile.mozillians_profile_url|urlizetrunc:50 }}
126 129 </p>
127   - {% if pageuser.userprofile.mentor %}
  130 + <p class="profile-item">
  131 + <span class="white radius label">
  132 + Wiki Profile
  133 + </span>
  134 + &nbsp;{{ pageuser.userprofile.wiki_profile_url|urlizetrunc:50 }}
  135 + </p>
  136 + {% if pageuser.userprofile.mentor %}
128 137 <p class="profile-item">
129 138 <span class="white radius label">
130 139 Mentor
@@ -273,28 +282,5 @@ <h5 class="grayed">
273 282
274 283 {% block bottomextra %}
275 284 <script type="text/javascript" src="{{ MEDIA_URL }}openlayers/OpenLayers.js"></script>
276   -<script type="text/javascript">
277   - var map = new OpenLayers.Map('map', {
278   - controls: [
279   - new OpenLayers.Control.Navigation(),
280   - new OpenLayers.Control.ArgParser(),
281   - new OpenLayers.Control.Attribution()],
282   - projection: new OpenLayers.Projection("EPSG:900913")
283   - });
284   - var panel = new OpenLayers.Control.Panel();
285   - var markers = new OpenLayers.Layer.Markers("Reps");
286   - var osm = new OpenLayers.Layer.OSM();
287   -
288   - map.addLayers([osm]);
289   - map.zoomToMaxExtent();
290   - map.addLayer(markers);
291   -
292   - var lonlat = new OpenLayers.LonLat({{ pageuser.userprofile.lon }}, {{ pageuser.userprofile.lat }});
293   - map.setCenter(lonlat, 8); // Zoom level
294   - var size = new OpenLayers.Size(21, 33);
295   - var offset = new OpenLayers.Pixel(-(size.w / 2), -size.h);
296   - var icon = new OpenLayers.Icon('{{ MEDIA_URL }}img/remo/marker.png', size, offset);
297   - markers.addMarker(new OpenLayers.Marker(lonlat, icon.clone()));
298   - markers.setOpacity(0.7);
299   -</script>
300   -{% endblock %}
  285 +<script type="text/javascript" src="{{ MEDIA_URL }}js/profiles_view.js"></script>
  286 +{% endblock %}
5 remo/profiles/tests/test_views.py
@@ -29,11 +29,12 @@ def setUp(self):
29 29 'lon': 12.23,
30 30 'lat': 12.23,
31 31 'mozillians_profile_url': u'http://mozillians.org/',
  32 + 'wiki_profile_url': u'https://wiki.mozilla.org/User:',
32 33 'jabber_id': u'foo@jabber.org',
33 34 'irc_name': u'ircname',
34 35 'linkedin_url': u'http://www.linkedin.com/',
35 36 'facebook_url': u'http://www.facebook.com/',
36   - 'diaspora_url': u'http://www.example.com/',
  37 + 'diaspora_url': u'https://joindiaspora.com/',
37 38 'personal_website_url': u'http://www.example.com/',
38 39 'personal_blog_feed': u'http://example.com/',
39 40 'bio': u'bio foo',
@@ -170,7 +171,7 @@ def test_edit_profile(self):
170 171 mandatory_fields = ['first_name', 'last_name', 'email',
171 172 'birth_date', 'private_email', 'city', 'region',
172 173 'country', 'lon', 'lat', 'mozillians_profile_url',
173   - 'irc_name']
  174 + 'irc_name', 'wiki_profile_url']
174 175 for field in mandatory_fields:
175 176 # remove a mandatory field and ensure that edit fails
176 177 temp_data = self.data.copy()

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.